-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
incr.comp.: Turn translation-related attributes into a query #48712
Conversation
☔ The latest upstream changes (presumably #48125) made this pull request unmergeable. Please resolve the merge conflicts. |
8824ae1
to
7327c91
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the very thorough PR, @wesleywiser! This makes a lot of things much nicer, I think, and probably more efficient too.
I added some comments where things need addressing. Just minor things though.
One thing left to do is caching the new query. Doing so is a bit more involved than it should be but it's pretty simple nonetheless:
- Mark the query as cacheable like here:
rust/src/librustc/ty/maps/config.rs
Line 685 in e2746d8
impl_disk_cacheable_query!(def_symbol_name, |_| true); - Allow for the query to be "refreshed" before writing back out to disk:
rust/src/librustc/ty/maps/plumbing.rs
Line 999 in e2746d8
ContainsExternIndicator => contains_extern_indicator, - Actually write query results to disk, like here:
rust/src/librustc/ty/maps/on_disk_cache.rs
Line 220 in e2746d8
encode_query_results::<contains_extern_indicator, _>(tcx, enc, qri)?;
src/librustc_trans/attributes.rs
Outdated
} else if trans_fn_attrs.flags.contains(TransFnAttrFlags::UNWIND) { | ||
unwind(llfn, true); | ||
} else if trans_fn_attrs.flags.contains(TransFnAttrFlags::RUSTC_ALLOCATOR_NOUNWIND) { | ||
unwind(llfn, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This transformation isn't quite right: We need to always go through all of the if
s instead of chaining them via else
. The previous version used else
because the body of the for
loop would be executed for each attribute individually.
src/librustc/ich/impls_hir.rs
Outdated
@@ -1156,6 +1158,14 @@ impl<'hir> HashStable<StableHashingContext<'hir>> for hir::TransFnAttrFlags | |||
} | |||
} | |||
|
|||
impl<'hir> HashStable<StableHashingContext<'hir>> for attr::InlineAttr { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be able to use the impl_stable_hash_for!
macro, like here:
rust/src/librustc/ich/impls_hir.rs
Lines 144 to 149 in e2746d8
impl_stable_hash_for!(enum hir::LifetimeName { | |
Implicit, | |
Underscore, | |
Static, | |
Name(name) | |
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that but the macro doesn't seem to like the path to that enum. Trying impl_stable_hash_for!(enum attr::InlineAttr { ... })
yields error[E0433]: failed to resolve. Did you mean syntax::attr?
but changing that to impl_stable_hash_for!(enum syntax::attr::InlineAttr { ... })
yields error[E0433]: failed to resolve. Use of undeclared type or module syntax
. I'm not sure where to go from here...
src/librustc/ich/impls_hir.rs
Outdated
@@ -1144,6 +1145,7 @@ impl<'hir> HashStable<StableHashingContext<'hir>> for hir::TransFnAttrs | |||
hcx: &mut StableHashingContext<'hir>, | |||
hasher: &mut StableHasher<W>) { | |||
self.flags.hash_stable(hcx, hasher); | |||
self.inline.hash_stable(hcx, hasher); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We usually de-structure the data types in these implementations:
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'hir>,
hasher: &mut StableHasher<W>) {
let hir::TransFnAttrs {
flags,
inline,
} = *self;
flags.hash_stable(hcx, hasher);
inline.hash_stable(hcx, hasher);
}
This way the code contains an exhaustive list of all fields and one cannot add or remove a field without also updating the impl
here. It's a bit more verbose but it is a good way of letting the compiler help keeping things consistent.
src/librustc_mir/transform/inline.rs
Outdated
@@ -207,7 +207,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> { | |||
} | |||
|
|||
let attrs = tcx.get_attrs(callsite.callee); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be able to get rid of this attrs
entirely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just saw that this is fixed in a later commit :)
Lrc::new(Vec::new()) // Just a dummy | ||
|
||
providers.target_features_whitelist = |_tcx, _cnum| { | ||
Rc::new(FxHashSet()) // Just a dummy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will probably need updating to Lrc
too.
☔ The latest upstream changes (presumably #48208) made this pull request unmergeable. Please resolve the merge conflicts. |
7327c91
to
628818c
Compare
@michaelwoerister I resolved all of your feedback except for the issue I mentioned above with the |
628818c
to
fbcdef5
Compare
📌 Commit fbcdef5 has been approved by |
⌛ Trying commit fbcdef582ec8be6eeef06d90463b226166d07d22 with merge b773dbdc99823e59733116d290342079ba1ca26e... |
☀️ Test successful - status-travis |
⌛ Testing commit fbcdef582ec8be6eeef06d90463b226166d07d22 with merge f24577a22bd6f638589992267b87d23fde912871... |
@bors r- |
I seems that bors has decided to push this PR to the front of the queue (and kill the one that was almost finished |
@bors r+ (so that bors doesn't suddenly decide to not merge even though all tests have passed) |
📌 Commit fbcdef5 has been approved by |
@Mark-Simulacrum, could you do a perf run please? |
☔ The latest upstream changes (presumably #48611) made this pull request unmergeable. Please resolve the merge conflicts. |
Perf started for b773dbdc99823e59733116d290342079ba1ca26e. |
Thanks, @Mark-Simulacrum! Here's the link: http://perf.rust-lang.org/compare.html?start=1733a61141d125beb45587dd89d54cd4a01cdd5a&end=b773dbdc99823e59733116d290342079ba1ca26e&stat=instructions%3Au Will this work? Are there build artifacts for the commit? The try-build was f24577a. |
fbcdef5
to
e0f7527
Compare
Rebased |
There were two try builds, of which bors seems to think only one completed so I ran perf for that one. The URL you provided looks correct. |
@bors r+ (after rebase) |
📌 Commit e0f7527 has been approved by |
Thanks, @Mark-Simulacrum, yes the link works now, it's all good The numbers look good too! Pretty much in line with what I expected. |
@michaelwoerister Are you concerned about the |
No, that's fine, the clean-incremental benchmark for style-servo is not stable: #48184 |
Got it. Thanks! |
Fixes #47320
r? @michaelwoerister