Skip to content

Commit 0369ff2

Browse files
committed
Simplify generator_drop since it won't be optimized.
1 parent 75121fc commit 0369ff2

File tree

2 files changed

+10
-45
lines changed

2 files changed

+10
-45
lines changed

compiler/rustc_mir_transform/src/generator.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,8 @@ fn create_generator_drop_shim<'tcx>(
967967

968968
// Make sure we remove dead blocks to remove
969969
// unrelated code from the resume part of the function
970-
simplify::remove_dead_blocks(tcx, &mut body);
970+
simplify::simplify_cfg(tcx, &mut body);
971+
simplify::simplify_locals(&mut body, tcx);
971972

972973
body
973974
}

src/test/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.mir

+8-44
Original file line numberDiff line numberDiff line change
@@ -17,69 +17,33 @@
1717

1818
fn main::{closure#0}(_1: *mut [generator@$DIR/generator-drop-cleanup.rs:10:15: 10:17]) -> () {
1919
let mut _0: (); // return place in scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17
20-
let mut _2: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17
21-
let _3: std::string::String; // in scope 0 at $DIR/generator-drop-cleanup.rs:11:13: 11:15
22-
let _4: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:12:9: 12:14
23-
let mut _5: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:12:9: 12:14
24-
let mut _6: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:10:18: 10:18
25-
let mut _7: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17
26-
let mut _8: u32; // in scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17
20+
let mut _2: u32; // in scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17
2721
scope 1 {
2822
debug _s => (((*_1) as variant#3).0: std::string::String); // in scope 1 at $DIR/generator-drop-cleanup.rs:11:13: 11:15
2923
}
3024

3125
bb0: {
32-
_8 = discriminant((*_1)); // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17
33-
switchInt(move _8) -> [0_u32: bb7, 3_u32: bb10, otherwise: bb11]; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17
26+
_2 = discriminant((*_1)); // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17
27+
switchInt(move _2) -> [0_u32: bb3, 3_u32: bb4, otherwise: bb5]; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17
3428
}
3529

3630
bb1: {
37-
StorageDead(_5); // scope 1 at $DIR/generator-drop-cleanup.rs:12:13: 12:14
38-
StorageDead(_4); // scope 1 at $DIR/generator-drop-cleanup.rs:12:14: 12:15
39-
drop((((*_1) as variant#3).0: std::string::String)) -> [return: bb2, unwind: bb5]; // scope 0 at $DIR/generator-drop-cleanup.rs:13:5: 13:6
40-
}
41-
42-
bb2: {
43-
nop; // scope 0 at $DIR/generator-drop-cleanup.rs:13:5: 13:6
44-
goto -> bb8; // scope 0 at $DIR/generator-drop-cleanup.rs:13:5: 13:6
45-
}
46-
47-
bb3: {
4831
return; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17
4932
}
5033

51-
bb4 (cleanup): {
34+
bb2 (cleanup): {
5235
resume; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17
5336
}
5437

55-
bb5 (cleanup): {
56-
nop; // scope 0 at $DIR/generator-drop-cleanup.rs:13:5: 13:6
57-
goto -> bb4; // scope 0 at $DIR/generator-drop-cleanup.rs:13:5: 13:6
58-
}
59-
60-
bb6: {
38+
bb3: {
6139
return; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17
6240
}
6341

64-
bb7: {
65-
goto -> bb9; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17
66-
}
67-
68-
bb8: {
69-
goto -> bb3; // scope 0 at $DIR/generator-drop-cleanup.rs:13:5: 13:6
70-
}
71-
72-
bb9: {
73-
goto -> bb6; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17
74-
}
75-
76-
bb10: {
77-
StorageLive(_4); // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17
78-
StorageLive(_5); // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17
79-
goto -> bb1; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17
42+
bb4: {
43+
drop((((*_1) as variant#3).0: std::string::String)) -> [return: bb1, unwind: bb2]; // scope 0 at $DIR/generator-drop-cleanup.rs:13:5: 13:6
8044
}
8145

82-
bb11: {
46+
bb5: {
8347
return; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17
8448
}
8549
}

0 commit comments

Comments
 (0)