about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-05-22 04:42:20 +0000
committerbors <bors@rust-lang.org>2019-05-22 04:42:20 +0000
commit1cc822c261f5c94a41eb725755fdda7ca6efbda2 (patch)
tree7cef8fc95f0d6c858dcebd6741f51db0b1be441e /src/test
parentdbfe70dfcdb0eab5e1e21f419c718e58cf62029b (diff)
parent26c37d7b168781d8be0236fdcdcb502b6c2b8ee2 (diff)
downloadrust-1cc822c261f5c94a41eb725755fdda7ca6efbda2.tar.gz
rust-1cc822c261f5c94a41eb725755fdda7ca6efbda2.zip
Auto merge of #60840 - tmandry:preserve-scope-in-generator-mir, r=cramertj
Preserve local scopes in generator MIR

Part of #52924, depended upon by the generator layout optimization #60187.

This PR adds `StorageDead` statements in more places in generators, so we can see when non-`Drop` locals have gone out of scope and recover their storage.

The reason this is only done for generators is compiler performance. See https://github.com/rust-lang/rust/pull/60187#issuecomment-485637811 for what happens when we do this for all functions.

For `Drop` locals, we modify the `MaybeStorageLive` analysis to use `drop` to indicate that storage is no longer live for the local. Once `drop` returns or unwinds to our function, we implicitly assume that the local is `StorageDead`.

Instead of using `drop`, it is possible to emit more `StorageDead` statements in the MIR for `Drop` locals so we can handle all locals the same. I am fine with doing it that way, but this was the simplest approach for my purposes. It is also likely to be more performant.

r? @Zoxc (feel free to reassign)
cc @cramertj @eddyb @RalfJung @rust-lang/wg-async-await
Diffstat (limited to 'src/test')
-rw-r--r--src/test/mir-opt/generator-drop-cleanup.rs1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/test/mir-opt/generator-drop-cleanup.rs b/src/test/mir-opt/generator-drop-cleanup.rs
index 9cc4272fafa..30f6d0deb91 100644
--- a/src/test/mir-opt/generator-drop-cleanup.rs
+++ b/src/test/mir-opt/generator-drop-cleanup.rs
@@ -17,6 +17,7 @@ fn main() {
 //     switchInt(move _5) -> [0u32: bb4, 3u32: bb7, otherwise: bb8];
 // }
 // bb1: {
+//     StorageDead(_3);
 //     goto -> bb5;
 // }
 // bb2: {