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

[mir-opt] Fix mis-optimization and other issues with the SimplifyArmIdentity pass #73949

Merged
merged 4 commits into from
Jul 4, 2020

Conversation

wesleywiser
Copy link
Member

@wesleywiser wesleywiser commented Jul 2, 2020

This does not yet attempt re-enabling the pass, but it does resolve a number of issues with the pass.

r? @oli-obk

I believe this closes #73223.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 2, 2020
@oli-obk
Copy link
Contributor

oli-obk commented Jul 2, 2020

I went through the commits each by its own, but I don't see how f00b337 can have the effect that it has (basically reverting most of the MIR opt diff from ed31211). Overall the diff lgtm, but I don't think anything beyond the debug info fixes is shown in MIR diffs. Maybe add the ui test also to MIR opt?

@wesleywiser
Copy link
Member Author

@oli-obk I think I forgot to re-bless the mir-opt tests after splitting this into different commits so that's probably part of the issue. I've implemented your suggestion and blessed each commit so you can see the changes.

@@ -397,7 +442,9 @@ impl LocalUseCounter {

impl<'tcx> Visitor<'tcx> for LocalUseCounter {
fn visit_local(&mut self, local: &Local, context: PlaceContext, _location: Location) {
if context.is_storage_marker() {
if context.is_storage_marker()
|| context == PlaceContext::NonUse(NonUseContext::VarDebugInfo)
Copy link
Contributor

Choose a reason for hiding this comment

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

are there any NonUseContext that are relevant here? The only one left that isn't covered is AscribeUserTy. So this could just be if let PlaceContext::NonUse(_) = context` I think.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm I guess those are unused after NLL runs right? Maybe we should have a separate pass that runs at the beginning of the optimization phase and removes all of those?

Copy link
Contributor

Choose a reason for hiding this comment

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

true, and then changing this site to the general match on NonUseContext doesn't actually change anything, anymore, so let's do that in a separate PR

_3 = move ((_1 as Some).0: std::boxed::Box<()>); // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:4:14: 4:15
((_0 as Some).0: std::boxed::Box<()>) = move _3; // scope 1 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:4:20: 4:27
discriminant(_0) = 1; // scope 1 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:4:20: 4:27
_0 = move _1; // scope 1 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:4:20: 4:27
Copy link
Contributor

Choose a reason for hiding this comment

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

oh now I realize how this is happening... we were missing optimizations because we were marking them as used because of debuginfo

@oli-obk
Copy link
Contributor

oli-obk commented Jul 3, 2020

I've implemented your suggestion and blessed each commit so you can see the changes.

Thanks! This is absolutely great. I have one more nit, r=me with that + reblessing aftwards.

@oli-obk
Copy link
Contributor

oli-obk commented Jul 3, 2020

@bors r+

@bors
Copy link
Contributor

bors commented Jul 3, 2020

📌 Commit e16d6a6 has been approved by oli-obk

@bors
Copy link
Contributor

bors commented Jul 3, 2020

🌲 The tree is currently closed for pull requests below priority 100, this pull request will be tested once the tree is reopened

@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 Jul 3, 2020
@wesleywiser
Copy link
Member Author

Since this messes with mir-opt stuff, I'm going to say

@bors rollup=never

Just in case 🙂

@Manishearth
Copy link
Member

@bors p=1

@Manishearth
Copy link
Member

Is the rollup=never for perf stuff or just because you think this will fail a rollup? Because I'm game for including this in a rollup, I typically include at least one iffy PR in a rollup -- if it fails we get early feedback on the PR.

@wesleywiser
Copy link
Member Author

@Manishearth More out of an abundance of caution although, since this pass is disabled, it shouldn't have any effect (performance or correctness).

@Manishearth
Copy link
Member

I'm gonna un-never it then, rollups take this kind of risk pretty typically 😄

@bors r- rollup=maybe

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 3, 2020
@Manishearth
Copy link
Member

@bors r=oli-obk p=0

oops

@bors
Copy link
Contributor

bors commented Jul 3, 2020

📌 Commit e16d6a6 has been approved by oli-obk

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 3, 2020
@wesleywiser
Copy link
Member Author

Sounds good. Thanks @Manishearth!

bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 4, 2020
…arth

Rollup of 12 pull requests

Successful merges:

 - rust-lang#73140 (Fallback to xml.etree.ElementTree)
 - rust-lang#73670 (Add `format_args_capture` feature)
 - rust-lang#73693 (Use exhaustive match in const_prop.rs)
 - rust-lang#73845 (Use &raw in A|Rc::as_ptr)
 - rust-lang#73861 (Create E0768)
 - rust-lang#73881 (Standardize bibliographic citations in rustc API docs)
 - rust-lang#73925 (Improve comments from rust-lang#72617, as suggested by RalfJung)
 - rust-lang#73949 ([mir-opt] Fix mis-optimization and other issues with the SimplifyArmIdentity pass)
 - rust-lang#73984 (Edit docs for rustc_data_structures::graph::scc)
 - rust-lang#73985 (Fix "getting started" link)
 - rust-lang#73997 (fix typo)
 - rust-lang#73999 (Bump mingw-check CI image from Ubuntu 16.04 to 18.04.)

Failed merges:

 - rust-lang#74000 (add `lazy_normalization_consts` feature gate)

r? @ghost
@bors bors merged commit 60cad20 into rust-lang:master Jul 4, 2020
@cuviper cuviper added this to the 1.46 milestone May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Slice index becomes wrong (beta regression)
6 participants