Skip to content
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

Merged
merged 3 commits into from
Oct 24, 2021

Conversation

cjgillot
Copy link
Contributor

Fixes #78442

@rust-highfive
Copy link
Collaborator

r? @lcnr

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 13, 2021
@bjorn3
Copy link
Member

bjorn3 commented May 13, 2021

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.

@lcnr
Copy link
Contributor

lcnr commented May 24, 2021

I am not able to review any PRs in the near future.

r? @ecstatic-morse

@rust-highfive rust-highfive assigned ecstatic-morse and unassigned lcnr May 24, 2021
@crlf0710 crlf0710 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 11, 2021
@tmiasko
Copy link
Contributor

tmiasko commented Jun 11, 2021

FYI: This introduces new test failures related to validation in sanitize_witness when building with: ./x.py test --rustc-args -Zinline-mir src/test/ui/async-await/

@bors
Copy link
Contributor

bors commented Jun 22, 2021

☔ The latest upstream changes (presumably #86383) made this pull request unmergeable. Please resolve the merge conflicts.

@lcnr
Copy link
Contributor

lcnr commented Jun 23, 2021

going to reassign this to myself, considering that I am slowly starting to become active again

r? @lcnr

@rust-highfive rust-highfive assigned lcnr and unassigned ecstatic-morse Jun 23, 2021
Copy link
Contributor

@lcnr lcnr left a 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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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(
Copy link
Contributor

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.

@crlf0710 crlf0710 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 9, 2021
@bjorn3
Copy link
Member

bjorn3 commented Jul 10, 2021

Won't this break specialization by normalizing associated types when a specialization may cause a different type to be used?

@rust-log-analyzer

This comment has been minimized.

@lcnr
Copy link
Contributor

lcnr commented Jul 12, 2021

Won't this break specialization by normalizing associated types when a specialization may cause a different type to be used?

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.

@cjgillot
Copy link
Contributor Author

FYI: This introduces new test failures related to validation in sanitize_witness when building with: ./x.py test --rustc-args -Zinline-mir src/test/ui/async-await/

Latest CI runs show this ICE. I have no idea what is happening.

@tmiasko
Copy link
Contributor

tmiasko commented Jul 14, 2021

FYI: This introduces new test failures related to validation in sanitize_witness when building with: ./x.py test --rustc-args -Zinline-mir src/test/ui/async-await/

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 sanitize_witness.

@crlf0710
Copy link
Member

@cjgillot Ping from triage, CI is still red here. Mind fixing that?

@crlf0710 crlf0710 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 31, 2021
@JohnCSimon JohnCSimon added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 15, 2021
@JohnCSimon
Copy link
Member

@cjgillot Ping again from triage, CI is still red here

@bors

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@cjgillot
Copy link
Contributor Author

@bors r=lcnr

@bors
Copy link
Contributor

bors commented Oct 23, 2021

📌 Commit 70aeced has been approved by lcnr

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 23, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 23, 2021
Normalize MIR with RevealAll before optimizations.

Fixes rust-lang#78442
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 24, 2021
Normalize MIR with RevealAll before optimizations.

Fixes rust-lang#78442
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 24, 2021
Normalize MIR with RevealAll before optimizations.

Fixes rust-lang#78442
This was referenced Oct 24, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 24, 2021
Normalize MIR with RevealAll before optimizations.

Fixes rust-lang#78442
@bors
Copy link
Contributor

bors commented Oct 24, 2021

⌛ Testing commit 70aeced with merge ed08a67...

@bors
Copy link
Contributor

bors commented Oct 24, 2021

☀️ Test successful - checks-actions
Approved by: lcnr
Pushing ed08a67 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Oct 24, 2021
@bors bors merged commit ed08a67 into rust-lang:master Oct 24, 2021
@rustbot rustbot added this to the 1.58.0 milestone Oct 24, 2021
@rust-timer
Copy link
Collaborator

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

@cjgillot cjgillot deleted the reveal-mir branch October 24, 2021 18:31
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 6, 2021
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`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 6, 2021
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``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ICE: broken mir with -Zinline-mir issue-50865-private-impl-trait/auxiliary/lib.rs