Skip to content

Commit 6960bc9

Browse files
only run RemoveZsts at mir-opt-level 3 and above
1 parent 46fd49c commit 6960bc9

14 files changed

+55
-25
lines changed

Diff for: compiler/rustc_mir/src/transform/remove_zsts.rs

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ pub struct RemoveZsts;
88

99
impl<'tcx> MirPass<'tcx> for RemoveZsts {
1010
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
11+
if tcx.sess.mir_opt_level() < 3 {
12+
return;
13+
}
1114
let param_env = tcx.param_env(body.source.def_id());
1215
let (basic_blocks, local_decls) = body.basic_blocks_and_local_decls_mut();
1316
for block in basic_blocks.iter_mut() {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
}
3030

3131
bb2: {
32-
nop; // scope 0 at $DIR/control-flow-simplification.rs:14:6: 14:6
32+
_0 = const (); // scope 0 at $DIR/control-flow-simplification.rs:14:6: 14:6
3333
StorageDead(_1); // scope 0 at $DIR/control-flow-simplification.rs:14:5: 14:6
3434
return; // scope 0 at $DIR/control-flow-simplification.rs:15:2: 15:2
3535
}

Diff for: src/test/mir-opt/const_prop/control_flow_simplification.hello.PreCodegen.before.mir

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ fn hello() -> () {
44
let mut _0: (); // return place in scope 0 at $DIR/control-flow-simplification.rs:11:14: 11:14
55

66
bb0: {
7+
_0 = const (); // scope 0 at $DIR/control-flow-simplification.rs:14:6: 14:6
78
return; // scope 0 at $DIR/control-flow-simplification.rs:15:2: 15:2
89
}
910
}

Diff for: src/test/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.diff

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
StorageLive(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:21:5: 21:12
1515
StorageLive(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:21:10: 21:11
1616
_3 = move _1; // scope 0 at $DIR/remove_unneeded_drops.rs:21:10: 21:11
17+
nop; // scope 1 at $DIR/remove_unneeded_drops.rs:21:5: 21:12
1718
drop(_3) -> [return: bb2, unwind: bb1]; // scope 1 at $DIR/remove_unneeded_drops.rs:21:5: 21:12
1819
}
1920

Diff for: src/test/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.diff

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
StorageLive(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:9:5: 9:12
1515
StorageLive(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:9:10: 9:11
1616
_3 = move _1; // scope 0 at $DIR/remove_unneeded_drops.rs:9:10: 9:11
17+
nop; // scope 1 at $DIR/remove_unneeded_drops.rs:9:5: 9:12
1718
drop(_3) -> [return: bb2, unwind: bb1]; // scope 1 at $DIR/remove_unneeded_drops.rs:9:5: 9:12
1819
}
1920

Diff for: src/test/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.diff

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
StorageLive(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:4:5: 4:12
1515
StorageLive(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:4:10: 4:11
1616
_3 = _1; // scope 0 at $DIR/remove_unneeded_drops.rs:4:10: 4:11
17+
- nop; // scope 1 at $DIR/remove_unneeded_drops.rs:4:5: 4:12
1718
- drop(_3) -> bb1; // scope 1 at $DIR/remove_unneeded_drops.rs:4:5: 4:12
1819
- }
1920
-

Diff for: src/test/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.diff

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
StorageLive(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:14:5: 14:12
1515
StorageLive(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:14:10: 14:11
1616
_3 = _1; // scope 0 at $DIR/remove_unneeded_drops.rs:14:10: 14:11
17+
- nop; // scope 1 at $DIR/remove_unneeded_drops.rs:14:5: 14:12
1718
- drop(_3) -> bb1; // scope 1 at $DIR/remove_unneeded_drops.rs:14:5: 14:12
1819
- }
1920
-

Diff for: src/test/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals.diff

+34-15
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
let mut _4: isize; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:22: 4:26
1010
let mut _5: isize; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:13: 4:20
1111
let _6: u8; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:18: 4:19
12-
- let mut _7: bool; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:20
13-
- let mut _8: u8; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:13
12+
let mut _7: bool; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:20
13+
let mut _8: u8; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:13
1414
scope 1 {
1515
debug a => _6; // in scope 1 at $DIR/simplify-locals-fixedpoint.rs:4:18: 4:19
1616
}
@@ -26,32 +26,51 @@
2626
StorageDead(_3); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:68: 4:69
2727
StorageDead(_2); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:68: 4:69
2828
_5 = discriminant((_1.0: std::option::Option<u8>)); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:13: 4:20
29-
switchInt(move _5) -> [1_isize: bb1, otherwise: bb3]; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:13: 4:20
29+
switchInt(move _5) -> [1_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:13: 4:20
3030
}
3131

3232
bb1: {
33-
_4 = discriminant((_1.1: std::option::Option<T>)); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:22: 4:26
34-
switchInt(move _4) -> [0_isize: bb2, otherwise: bb3]; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:22: 4:26
33+
_0 = const (); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:8:6: 8:6
34+
goto -> bb7; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:5: 8:6
3535
}
3636

3737
bb2: {
38+
_4 = discriminant((_1.1: std::option::Option<T>)); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:22: 4:26
39+
switchInt(move _4) -> [0_isize: bb3, otherwise: bb1]; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:22: 4:26
40+
}
41+
42+
bb3: {
3843
StorageLive(_6); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:18: 4:19
3944
_6 = (((_1.0: std::option::Option<u8>) as Some).0: u8); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:18: 4:19
40-
- StorageLive(_7); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:20
41-
- StorageLive(_8); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:13
42-
- _8 = _6; // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:13
43-
- _7 = Gt(move _8, const 42_u8); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:20
44-
- StorageDead(_8); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:19: 5:20
45-
- StorageDead(_7); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:7:9: 7:10
45+
StorageLive(_7); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:20
46+
StorageLive(_8); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:13
47+
_8 = _6; // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:13
48+
_7 = Gt(move _8, const 42_u8); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:20
49+
StorageDead(_8); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:19: 5:20
50+
switchInt(move _7) -> [false: bb5, otherwise: bb4]; // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:9: 7:10
51+
}
52+
53+
bb4: {
54+
_0 = const (); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:21: 7:10
55+
goto -> bb6; // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:9: 7:10
56+
}
57+
58+
bb5: {
59+
_0 = const (); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:7:10: 7:10
60+
goto -> bb6; // scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:9: 7:10
61+
}
62+
63+
bb6: {
64+
StorageDead(_7); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:7:9: 7:10
4665
StorageDead(_6); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:8:5: 8:6
47-
goto -> bb3; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:5: 8:6
66+
goto -> bb7; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:5: 8:6
4867
}
4968

50-
bb3: {
51-
drop(_1) -> bb4; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:9:1: 9:2
69+
bb7: {
70+
drop(_1) -> bb8; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:9:1: 9:2
5271
}
5372

54-
bb4: {
73+
bb8: {
5574
StorageDead(_1); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:9:1: 9:2
5675
return; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:9:2: 9:2
5776
}

Diff for: src/test/run-make/const_fn_mir/dump.mir

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ fn main() -> () {
1212
}
1313

1414
bb1: {
15+
_0 = const (); // scope 0 at main.rs:8:11: 10:2
1516
return; // scope 0 at main.rs:10:2: 10:2
1617
}
1718
}

Diff for: src/test/ui/consts/const-eval/panic-assoc-never-type.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ impl PrintName {
1515

1616
fn main() {
1717
let _ = PrintName::VOID;
18-
//~^ ERROR erroneous constant encountered
18+
//~^ ERROR erroneous constant used
1919
}

Diff for: src/test/ui/consts/const-eval/panic-assoc-never-type.stderr

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ LL | #![warn(const_err)]
1515
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
1616
= note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
1717

18-
error: erroneous constant encountered
18+
error[E0080]: erroneous constant used
1919
--> $DIR/panic-assoc-never-type.rs:17:13
2020
|
2121
LL | let _ = PrintName::VOID;
22-
| ^^^^^^^^^^^^^^^
22+
| ^^^^^^^^^^^^^^^ referenced constant has errors
2323

2424
error: aborting due to previous error; 1 warning emitted
2525

26+
For more information about this error, try `rustc --explain E0080`.

Diff for: src/test/ui/consts/const-eval/panic-never-type.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ const VOID: ! = panic!();
1111

1212
fn main() {
1313
let _ = VOID;
14-
//~^ ERROR erroneous constant encountered
14+
//~^ ERROR erroneous constant used
1515
}

Diff for: src/test/ui/consts/const-eval/panic-never-type.stderr

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ LL | #![warn(const_err)]
1515
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
1616
= note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
1717

18-
error: erroneous constant encountered
18+
error[E0080]: erroneous constant used
1919
--> $DIR/panic-never-type.rs:13:13
2020
|
2121
LL | let _ = VOID;
22-
| ^^^^
22+
| ^^^^ referenced constant has errors
2323

2424
error: aborting due to previous error; 1 warning emitted
2525

26+
For more information about this error, try `rustc --explain E0080`.

Diff for: src/test/ui/recursion/issue-26548-recursion-via-normalize.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
error[E0391]: cycle detected when computing layout of `std::option::Option<S>`
1+
error[E0391]: cycle detected when computing layout of `S`
22
|
3-
= note: ...which requires computing layout of `S`...
4-
= note: ...which again requires computing layout of `std::option::Option<S>`, completing the cycle
3+
= note: ...which requires computing layout of `std::option::Option<S>`...
4+
= note: ...which again requires computing layout of `S`, completing the cycle
55
note: cycle used when optimizing MIR for `main`
66
--> $DIR/issue-26548-recursion-via-normalize.rs:15:1
77
|

0 commit comments

Comments
 (0)