Skip to content

Commit 806b399

Browse files
committed
Auto merge of rust-lang#88056 - erikdesjardins:revertzst, r=oli-obk
Revert "Auto merge of rust-lang#83417 - erikdesjardins:enableremovezsts, r=oli-obk" This reverts commit 8007b50, reversing changes made to e55c13e. Fixes rust-lang#88043 r? `@oli-obk`
2 parents aa8f27b + b865a76 commit 806b399

14 files changed

+81
-21
lines changed

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

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ 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+
}
1215
let param_env = tcx.param_env(body.source.def_id());
1316
let (basic_blocks, local_decls) = body.basic_blocks_and_local_decls_mut();
1417
for block in basic_blocks.iter_mut() {

Diff for: 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", cfg="cfail2")]
65+
#[rustc_clean(except="hir_owner_nodes,typeck,optimized_mir", cfg="cfail2")]
6666
#[rustc_clean(cfg="cfail3")]
6767
fn method_name() {
6868
()

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 0 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:20
41-
- StorageLive(_8); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:13
42-
- _8 = _6; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:13
43-
- _7 = Gt(move _8, const 42_u8); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:20
44-
- StorageDead(_8); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:5:19: 5:20
45-
- StorageDead(_7); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:7:9: 7:10
46-
goto -> bb3; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:5: 8:6
45+
StorageLive(_7); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:20
46+
StorageLive(_8); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:13
47+
_8 = _6; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:13
48+
_7 = Gt(move _8, const 42_u8); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:20
49+
StorageDead(_8); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:5:19: 5:20
50+
switchInt(move _7) -> [false: bb5, otherwise: bb4]; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:5:9: 7:10
4751
}
4852

49-
bb3: {
53+
bb4: {
54+
_0 = const (); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:5:21: 7:10
55+
goto -> bb6; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:5:9: 7:10
56+
}
57+
58+
bb5: {
59+
_0 = const (); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:7:10: 7:10
60+
goto -> bb6; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:5:9: 7:10
61+
}
62+
63+
bb6: {
64+
StorageDead(_7); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:7:9: 7:10
65+
goto -> bb7; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:5: 8:6
66+
}
67+
68+
bb7: {
5069
StorageDead(_6); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:8:5: 8:6
51-
drop(_1) -> bb4; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:9:1: 9:2
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
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// build-pass
2+
// compile-flags: -Copt-level=0
3+
4+
// Regression test for #88043: LLVM crash when the RemoveZsts mir-opt pass is enabled.
5+
// We should not see the error:
6+
// `Basic Block in function '_ZN4main10take_until17h0067b8a660429bc9E' does not have terminator!`
7+
8+
fn bump() -> Option<usize> {
9+
unreachable!()
10+
}
11+
12+
fn take_until(terminate: impl Fn() -> bool) {
13+
loop {
14+
if terminate() {
15+
return;
16+
} else {
17+
bump();
18+
}
19+
}
20+
}
21+
22+
// CHECK-LABEL: @main
23+
fn main() {
24+
take_until(|| true);
25+
}

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

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

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

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

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ 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: aborting due to previous error
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
1016

1117
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)