Skip to content

Commit 585e4ae

Browse files
Run RemoveZsts at mir-opt-level=1
Effectively reverts commit 6960bc9.
1 parent 5ad7389 commit 585e4ae

13 files changed

+21
-56
lines changed

compiler/rustc_mir/src/transform/remove_zsts.rs

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

1010
impl<'tcx> MirPass<'tcx> for RemoveZsts {
1111
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
12-
if tcx.sess.mir_opt_level() < 3 {
13-
return;
14-
}
1512
let param_env = tcx.param_env(body.source.def_id());
1613
let (basic_blocks, local_decls) = body.basic_blocks_and_local_decls_mut();
1714
for block in basic_blocks.iter_mut() {

src/test/incremental/hashes/trait_impls.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl ChangeMethodBodyTrait for Foo {
6262
#[rustc_clean(cfg="cfail2")]
6363
#[rustc_clean(cfg="cfail3")]
6464
impl ChangeMethodBodyTrait for Foo {
65-
#[rustc_clean(except="hir_owner_nodes,typeck,optimized_mir", cfg="cfail2")]
65+
#[rustc_clean(except="hir_owner_nodes,typeck", cfg="cfail2")]
6666
#[rustc_clean(cfg="cfail3")]
6767
fn method_name() {
6868
()

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-
_0 = const (); // scope 0 at $DIR/control-flow-simplification.rs:14:6: 14:6
32+
nop; // 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
}

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

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ 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
87
return; // scope 0 at $DIR/control-flow-simplification.rs:15:2: 15:2
98
}
109
}

src/test/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.diff

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
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
1817
drop(_3) -> [return: bb2, unwind: bb1]; // scope 1 at $DIR/remove_unneeded_drops.rs:21:5: 21:12
1918
}
2019

src/test/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.diff

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
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
1817
drop(_3) -> [return: bb2, unwind: bb1]; // scope 1 at $DIR/remove_unneeded_drops.rs:9:5: 9:12
1918
}
2019

src/test/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.diff

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
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
1817
- drop(_3) -> bb1; // scope 1 at $DIR/remove_unneeded_drops.rs:4:5: 4:12
1918
- }
2019
-

src/test/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.diff

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
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
1817
- drop(_3) -> bb1; // scope 1 at $DIR/remove_unneeded_drops.rs:14:5: 14:12
1918
- }
2019
-

src/test/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals.diff

+15-34
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,51 +26,32 @@
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: bb2, otherwise: bb1]; // 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
3030
}
3131

3232
bb1: {
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
35-
}
36-
37-
bb2: {
3833
_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
34+
switchInt(move _4) -> [0_isize: bb2, otherwise: bb3]; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:22: 4:26
4035
}
4136

42-
bb3: {
37+
bb2: {
4338
StorageLive(_6); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:18: 4:19
4439
_6 = (((_1.0: std::option::Option<u8>) as Some).0: u8); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:18: 4:19
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
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
6546
StorageDead(_6); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:8:5: 8:6
66-
goto -> bb7; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:5: 8:6
47+
goto -> bb3; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:5: 8:6
6748
}
6849

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

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

src/test/run-make/const_fn_mir/dump.mir

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

1414
bb1: {
15-
_0 = const (); // scope 0 at main.rs:8:11: 10:2
1615
return; // scope 0 at main.rs:10:2: 10:2
1716
}
1817
}

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

-1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@ impl PrintName {
1414

1515
fn main() {
1616
let _ = PrintName::VOID;
17-
//~^ ERROR erroneous constant used
1817
}

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

+1-7
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ LL | const VOID: ! = panic!();
66
|
77
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
88

9-
error[E0080]: erroneous constant used
10-
--> $DIR/panic-assoc-never-type.rs:16:13
11-
|
12-
LL | let _ = PrintName::VOID;
13-
| ^^^^^^^^^^^^^^^ referenced constant has errors
14-
15-
error: aborting due to 2 previous errors
9+
error: aborting due to previous error
1610

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

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 `S`
1+
error[E0391]: cycle detected when computing layout of `std::option::Option<S>`
22
|
3-
= note: ...which requires computing layout of `std::option::Option<S>`...
4-
= note: ...which again requires computing layout of `S`, completing the cycle
3+
= note: ...which requires computing layout of `S`...
4+
= note: ...which again requires computing layout of `std::option::Option<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)