Uh oh!
There was an error while loading. Please reload this page.
Clean up MIR drop generation - #61872
Conversation
rust-highfive
commented
Jun 15, 2019
r? @eddyb (rust_highfive has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
N.B. As part of implementing while a && let b = c { ... } I'll make a PR to remove hir::ExprKind::While and then hair::ExprKind::Loop will presumably need to drop it's condition field and so the else branch would be floated out and the if branch would be removed... I hope the changes here do not cause problems for this...?
There was a problem hiding this comment.
That should be fine, this is only a problem because while loops are special cased. For any sensible HIR lowering this won't be a problem. The temporary will probably end up storage-live for the whole loop body, but that isn't observable. The following two functions generate almost identical optimized MIR after this PR, for example.
fnwhile_loop(c:bool){whileget_bool(c){ifget_bool(c){break;}}}// What the above should probably expand tofnexp_while_loop(c:bool){loop{matchget_bool(c){true => {{ifget_bool(c){break;}}continue;}
_ => {}}break;}}There was a problem hiding this comment.
Cool.
For any sensible HIR lowering this won't be a problem.
Specifically, the HIR lowering should likely be:
'label:while $cond $block==>
'label:loop{matchDropTemps($cond){true => $block,
_ => break,}}(is there a particular reason you are using continue; and an empty block?)
There was a problem hiding this comment.
It's slightly closer to what the RFC specified. What you're suggesting is probably better.
bors
commented
Jun 16, 2019
☔ The latest upstream changes (presumably #60730) made this pull request unmergeable. Please resolve the merge conflicts. |
5ae55a3 to
2c93002Compare2c93002 to
13218c2Comparebors
commented
Jun 18, 2019
☔ The latest upstream changes (presumably #61915) made this pull request unmergeable. Please resolve the merge conflicts. |
eddyb
commented
Jun 18, 2019
r? @pnkfelix |
Should be able to roll forward when rust-lang/rust#61872 is in a nightly.
13218c2 to
07e5297Compare
nikomatsakis
left a comment
There was a problem hiding this comment.
This looks very good. I left a few questions.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
nikomatsakis
commented
Jun 25, 2019
@bors r+ |
bors
commented
Jun 25, 2019
📌 Commit 07e5297faf2966a77c466b0b5ad936c0deb828ac has been approved by |
bors
commented
Jun 25, 2019
☔ The latest upstream changes (presumably #62119) made this pull request unmergeable. Please resolve the merge conflicts. |
07e5297 to
3131427Comparecramertj
commented
Jun 26, 2019
@bors r=nikomatsakis |
bors
commented
Jun 26, 2019
📌 Commit 3131427 has been approved by |
bors
commented
Jun 26, 2019
…sakis Clean up MIR drop generation * Don't assign twice to the destination of a `while` loop containing a `break` expression * Use `as_temp` to evaluate statement expression * Avoid consecutive `StorageLive`s for the condition of a `while` loop * Unify `return`, `break` and `continue` handling, and move it to `scopes.rs` * Make some of the `scopes.rs` internals private * Don't use `Place`s that are always `Local`s in MIR drop generation Closes#42371Closes#61579Closes#61731Closes#61834Closes#61910Closes#62115
bors
commented
Jun 26, 2019
☀️ Test successful - checks-travis, status-appveyor |
mati865
commented
Jul 3, 2019
Was this performance regression expected? |
matthewjasper
commented
Jul 7, 2019
The ctfe-stress benchmark is now generating more MIR, so I'm not surprised that it's slower. I can't really work out what's going on with |
…_mention, r=compiler-errors Fixup method doc that mentions removed param The param was removed in rust-lang#61872 (101a2f5)
whileloop containing abreakexpressionas_tempto evaluate statement expressionStorageLives for the condition of awhileloopreturn,breakandcontinuehandling, and move it toscopes.rsscopes.rsinternals privatePlaces that are alwaysLocals in MIR drop generationCloses#42371
Closes#61579
Closes#61731
Closes#61834
Closes#61910
Closes#62115