Skip to content

Commit a4b5bfe

Browse files
committed
Fix, bless
1 parent f085e7a commit a4b5bfe

7 files changed

+75
-4
lines changed

compiler/rustc_mir_transform/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,6 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
558558
&const_prop::ConstProp::new(true),
559559
&const_debuginfo::ConstDebugInfo,
560560
&o1(simplify_branches::SimplifyConstCondition::new("before-inline")),
561-
&o1(simplify::SimplifyCfg::new("before-inline")),
562561
&inline::Inline,
563562
&remove_storage_markers::RemoveStorageMarkers,
564563
&remove_zsts::RemoveZsts,

src/test/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.diff

+4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
+ _5 = const false; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
3636
_6 = const false; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
3737
_7 = const false; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
38+
goto -> bb2; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
39+
}
40+
41+
bb2: {
3842
- _2 = Rem(const 1_i32, move _3); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
3943
+ _2 = Rem(const 1_i32, const 0_i32); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
4044
StorageDead(_3); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:18: +2:19

src/test/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff

+15
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,21 @@
99
bb0: {
1010
StorageLive(_1); // scope 0 at $DIR/control_flow_simplification.rs:+1:8: +1:21
1111
_1 = const _; // scope 0 at $DIR/control_flow_simplification.rs:+1:8: +1:21
12+
goto -> bb2; // scope 0 at $DIR/control_flow_simplification.rs:+1:8: +1:21
13+
}
14+
15+
bb1: {
16+
StorageLive(_2); // scope 0 at $SRC_DIR/std/src/panic.rs:LL:COL
17+
_2 = begin_panic::<&str>(const "explicit panic"); // scope 0 at $SRC_DIR/std/src/panic.rs:LL:COL
18+
// mir::Constant
19+
// + span: $SRC_DIR/std/src/panic.rs:LL:COL
20+
// + literal: Const { ty: fn(&str) -> ! {begin_panic::<&str>}, val: Value(<ZST>) }
21+
// mir::Constant
22+
// + span: $SRC_DIR/std/src/panic.rs:LL:COL
23+
// + literal: Const { ty: &str, val: Value(Slice(..)) }
24+
}
25+
26+
bb2: {
1227
nop; // scope 0 at $DIR/control_flow_simplification.rs:+3:6: +3:6
1328
StorageDead(_1); // scope 0 at $DIR/control_flow_simplification.rs:+3:5: +3:6
1429
return; // scope 0 at $DIR/control_flow_simplification.rs:+4:2: +4:2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// MIR for `main` after Inline
2+
3+
fn main() -> () {
4+
let mut _0: (); // return place in scope 0 at $DIR/dead_code_does_not_inline.rs:+0:15: +0:15
5+
let mut _1: bool; // in scope 0 at $DIR/dead_code_does_not_inline.rs:+1:8: +1:13
6+
let _2: (); // in scope 0 at $DIR/dead_code_does_not_inline.rs:+2:9: +2:17
7+
8+
bb0: {
9+
StorageLive(_1); // scope 0 at $DIR/dead_code_does_not_inline.rs:+1:8: +1:13
10+
_1 = const false; // scope 0 at $DIR/dead_code_does_not_inline.rs:+1:8: +1:13
11+
goto -> bb3; // scope 0 at $DIR/dead_code_does_not_inline.rs:+1:8: +1:13
12+
}
13+
14+
bb1: {
15+
StorageLive(_2); // scope 0 at $DIR/dead_code_does_not_inline.rs:+2:9: +2:17
16+
_2 = callee() -> bb2; // scope 0 at $DIR/dead_code_does_not_inline.rs:+2:9: +2:17
17+
// mir::Constant
18+
// + span: $DIR/dead_code_does_not_inline.rs:4:9: 4:15
19+
// + literal: Const { ty: fn() {callee}, val: Value(<ZST>) }
20+
}
21+
22+
bb2: {
23+
StorageDead(_2); // scope 0 at $DIR/dead_code_does_not_inline.rs:+2:17: +2:18
24+
_0 = const (); // scope 0 at $DIR/dead_code_does_not_inline.rs:+1:14: +3:6
25+
goto -> bb4; // scope 0 at $DIR/dead_code_does_not_inline.rs:+1:5: +3:6
26+
}
27+
28+
bb3: {
29+
_0 = const (); // scope 0 at $DIR/dead_code_does_not_inline.rs:+3:6: +3:6
30+
goto -> bb4; // scope 0 at $DIR/dead_code_does_not_inline.rs:+1:5: +3:6
31+
}
32+
33+
bb4: {
34+
StorageDead(_1); // scope 0 at $DIR/dead_code_does_not_inline.rs:+3:5: +3:6
35+
return; // scope 0 at $DIR/dead_code_does_not_inline.rs:+4:2: +4:2
36+
}
37+
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
//EMIT_MIR dead_code_does_not_inline.main.Inline.after.mir
2-
fn main() {
1+
// EMIT_MIR dead_code_does_not_inline.main.Inline.after.mir
2+
pub fn main() {
33
if false {
44
callee();
55
}
66
}
77

8-
fn callee() {
8+
pub fn callee() {
99
println!("Wooooo I'm invisible");
1010
}

src/test/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.diff

+8
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,15 @@
99
bb0: {
1010
StorageLive(_1); // scope 0 at $DIR/simplify_if.rs:+1:8: +1:13
1111
_1 = const false; // scope 0 at $DIR/simplify_if.rs:+1:8: +1:13
12+
goto -> bb1; // scope 0 at $DIR/simplify_if.rs:+1:8: +1:13
13+
}
14+
15+
bb1: {
1216
nop; // scope 0 at $DIR/simplify_if.rs:+3:6: +3:6
17+
goto -> bb2; // scope 0 at $DIR/simplify_if.rs:+1:5: +3:6
18+
}
19+
20+
bb2: {
1321
StorageDead(_1); // scope 0 at $DIR/simplify_if.rs:+3:5: +3:6
1422
return; // scope 0 at $DIR/simplify_if.rs:+4:2: +4:2
1523
}

src/test/mir-opt/simplify_match.main.ConstProp.diff

+8
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,15 @@
1515
_2 = const false; // scope 0 at $DIR/simplify_match.rs:+1:21: +1:26
1616
_1 = const false; // scope 1 at $DIR/simplify_match.rs:+1:28: +1:29
1717
StorageDead(_2); // scope 0 at $DIR/simplify_match.rs:+1:30: +1:31
18+
goto -> bb1; // scope 0 at $DIR/simplify_match.rs:+1:5: +1:31
19+
}
20+
21+
bb1: {
1822
nop; // scope 0 at $DIR/simplify_match.rs:+3:18: +3:20
23+
goto -> bb2; // scope 0 at $DIR/simplify_match.rs:+3:18: +3:20
24+
}
25+
26+
bb2: {
1927
StorageDead(_1); // scope 0 at $DIR/simplify_match.rs:+5:1: +5:2
2028
return; // scope 0 at $DIR/simplify_match.rs:+5:2: +5:2
2129
}

0 commit comments

Comments
 (0)