Skip to content

Commit

Permalink
Simplify generator_drop since it won't be optimized.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Sep 7, 2022
1 parent 75121fc commit 0369ff2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 45 deletions.
3 changes: 2 additions & 1 deletion compiler/rustc_mir_transform/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,8 @@ fn create_generator_drop_shim<'tcx>(

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

body
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,69 +17,33 @@

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

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

bb1: {
StorageDead(_5); // scope 1 at $DIR/generator-drop-cleanup.rs:12:13: 12:14
StorageDead(_4); // scope 1 at $DIR/generator-drop-cleanup.rs:12:14: 12:15
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
}

bb2: {
nop; // scope 0 at $DIR/generator-drop-cleanup.rs:13:5: 13:6
goto -> bb8; // scope 0 at $DIR/generator-drop-cleanup.rs:13:5: 13:6
}

bb3: {
return; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17
}

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

bb5 (cleanup): {
nop; // scope 0 at $DIR/generator-drop-cleanup.rs:13:5: 13:6
goto -> bb4; // scope 0 at $DIR/generator-drop-cleanup.rs:13:5: 13:6
}

bb6: {
bb3: {
return; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17
}

bb7: {
goto -> bb9; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17
}

bb8: {
goto -> bb3; // scope 0 at $DIR/generator-drop-cleanup.rs:13:5: 13:6
}

bb9: {
goto -> bb6; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17
}

bb10: {
StorageLive(_4); // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17
StorageLive(_5); // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17
goto -> bb1; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +0:17
bb4: {
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
}

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

0 comments on commit 0369ff2

Please sign in to comment.