-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Normalize MIR with RevealAll before optimizations. #85254
Conversation
r? @lcnr (rust-highfive has picked a reviewer for you, use r? to override) |
Would the performance effect of always doing this be positive or negative? Normalizing during mir opt and during codegen may increase the amount of work, but it may also make the second normalization cheaper which could be a net win for generic functions. |
I am not able to review any PRs in the near future. |
FYI: This introduces new test failures related to validation in |
☔ The latest upstream changes (presumably #86383) made this pull request unmergeable. Please resolve the merge conflicts. |
going to reassign this to myself, considering that I am slowly starting to become active again r? @lcnr |
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 think this is fine to land and might even be a perf improvement if enabled by default.
@cjgillot did you have the time to look into the test failure mentioned in #85254 (comment)?
impl<'tcx> MirPass<'tcx> for RevealAll { | ||
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { | ||
// This pass must run before inlining, since we insert callee bodies in RevealAll mode. | ||
if tcx.sess.mir_opt_level() < 3 && !super::inline::is_enabled(tcx) { |
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.
if tcx.sess.mir_opt_level() < 3 && !super::inline::is_enabled(tcx) { | |
if tcx.sess.mir_opt_level() >= 3 || super::inline::is_enabled(tcx) { | |
let param_env = tcx.param_env_reveal_all_normalized(body.source.def_id()); | |
RevealAllVisitor { tcx, param_env }.visit_body(body); | |
} |
seems slightly more understandable for me
} | ||
|
||
#[inline] | ||
fn process_projection_elem( |
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.
instead of overwriting process_projection_elem
, would it make sense to instead update the default impl to always update the type? Seems a bit scary to not visit that one by default.
Won't this break specialization by normalizing associated types when a specialization may cause a different type to be used? |
This comment has been minimized.
This comment has been minimized.
i would assume no 🤔 we shouldn't be able to normailze associated types if they are still specializable. So they remain unchanged in that case. |
Latest CI runs show this ICE. I have no idea what is happening. |
What happens now, I think, is that a generator witness is not normalized, while locals declaration are. When I originally mentioned the issue, I was thinking about resolving this by disabling inlining into generators altogether, rather than tinkering with the validation in |
@cjgillot Ping from triage, CI is still red here. Mind fixing that? |
@cjgillot Ping again from triage, CI is still red here |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@bors r=lcnr |
📌 Commit 70aeced has been approved by |
Normalize MIR with RevealAll before optimizations. Fixes rust-lang#78442
Normalize MIR with RevealAll before optimizations. Fixes rust-lang#78442
Normalize MIR with RevealAll before optimizations. Fixes rust-lang#78442
Normalize MIR with RevealAll before optimizations. Fixes rust-lang#78442
☀️ Test successful - checks-actions |
Finished benchmarking commit (ed08a67): comparison url. Summary: This benchmark run did not return any relevant changes. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression |
Run reveal_all on MIR when inlining is activated. Fix logic error in rust-lang#85254 which prevented the pass from running when needed. Fixes rust-lang#78442 r? `@lcnr`
Run reveal_all on MIR when inlining is activated. Fix logic error in rust-lang#85254 which prevented the pass from running when needed. Fixes rust-lang#78442 r? ``@lcnr``
Fixes #78442