Uh oh!
There was an error while loading. Please reload this page.
New mir-opt pass to simplify gotos with const values (reopening #77486) - #80475
Conversation
rust-highfive
commented
Dec 29, 2020
(rust-highfive has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
CC @oli-obk from #77486 (comment)
The MIR still contains two branches in the final MIR, so the optimization in this PR still messes this up. I'm wondering if this can be considered a bug in MatchBranchSimplification that it does not handle the _0 = const () case.
Tangentially, is _0 = const () ever needed in a function that returns unit? I think it would only make sense if _0 is considered uninitialized at the beginning of the function. But then, it would probably be a simplification to just set _0 = const () at the beginning of bb0.
There was a problem hiding this comment.
_0 = const () is never needed, and I thought it's actually eliminated by InstCombine or sth. Not sure why there's still one around at this point. No ZST assignment is ever needed, you can create references to locals before they are assigned if the local is a ZST (as long as it was StorageLived I think).
oli-obk
commented
Jan 1, 2021
cc @tmiasko if you have the time (and interest), could you have a look at this PR? |
Uh oh!
There was an error while loading. Please reload this page.
ecstatic-morse
commented
Jan 1, 2021
I'll set aside some time in the next week or so to review this. In the meantime, if you could squash your commits to remove refactorings/fixes to newly added code, it would make things a bit easier for me. |
There was a problem hiding this comment.
Compared to the earlier version the transform now supports switch blocks with statements. As a result it has to establish that the definition place = const reaches the switch, whereas previously it was trivially true.
Based on past experiences, I feel that doing this for an arbitrary place without a dedicated analysis will be challenging. If place is indirect it could be invalidated by other assignments, it can also contain indexing projections referencing other locals that could be modified, etc.
I would probably start with locals without any projections, and in addition to the existing check, also verify that either they never have their address taken or there are no indirect assignment in the switch block.
An example that doesn't work correctly right now:
pubfnmain(){letmut a = &mut0;if*a == 0{*a = 0;()};let b = &mut a;**b = 1;match*a {1 => {},
_ => panic!(),}}There was a problem hiding this comment.
Yeah, you are right. I'll revert the newest changes so that we only support statement-less targets. Then follow ups can improve the situation
bors
commented
Jan 14, 2021
☔ The latest upstream changes (presumably #79328) made this pull request unmergeable. Please resolve the merge conflicts. |
simonvandel
commented
Feb 12, 2021
Fixed merge conflicts. Hi @tmiasko, sorry for the long wait. Would you be able to do a review? |
Uh oh!
There was an error while loading. Please reload this page.
oli-obk
commented
Feb 13, 2021
@bors try @rust-timer queue |
rust-timer
commented
Feb 13, 2021
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
bors
commented
Feb 13, 2021
⌛ Trying commit 5734754fa175f74a0081ea2823b387013c54ee10 with merge 57512cbea2265af4686716b44fd0bb86358fbcdb... |
simonvandel
commented
Feb 13, 2021
@oli-obk the pass currently bails if mir opt level is less than 3 so I would expect no observable change in a perf run.If you want, I can remove the bail out so a perf run can be made. |
oli-obk
commented
Feb 13, 2021
oh... oops, didn't re-check, just read your comment and started the perf run. Do you still want that perf run? If so, yea let's change it back |
oli-obk
commented
Feb 13, 2021
@bors try- |
simonvandel
commented
Feb 13, 2021
@oli-obk Added a commit to disable the mir-opt-level check. Can you start the run again? |
oli-obk
commented
Feb 13, 2021
@bors try @rust-timer queue |
rust-timer
commented
Feb 13, 2021
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
oli-obk
commented
Feb 23, 2021
Yea, oops, should've rechecked. @bors r+ |
bors
commented
Feb 23, 2021
📌 Commit a6dccfe has been approved by |
bors
commented
Feb 23, 2021
⌛ Testing commit a6dccfe with merge 8aa2df00d8834c83aacfb232a83b3c160eeb4dae... |
rust-log-analyzer
commented
Feb 23, 2021
bors
commented
Feb 23, 2021
💔 Test failed - checks-actions |
bjorn3
commented
Feb 23, 2021
@bors retry |
bors
commented
Feb 23, 2021
⌛ Testing commit a6dccfe with merge c1357d951bac5da7640b3cc5adac992277a89c22... |
bors
commented
Feb 24, 2021
💥 Test timed out |
rust-log-analyzer
commented
Feb 24, 2021
bjorn3
commented
Feb 24, 2021
@bors retry Only a single runner timed out. The rest passed. |
bors
commented
Feb 24, 2021
bors
commented
Feb 24, 2021
☀️ Test successful - checks-actions |
Reopening PR #77486
Fixes#77355
This pass optimizes the following sequence
into