Skip to content

Commit 7a30d3e

Browse files
committed
Bless mir_opt tests that were broken by DSE.
Adding the DSE pass changed the emitted MIR for a bunch of other test. This commit blesses/fixes these changes. In some cases, this required adding some `black_box` calls to inhibit the DSE optimizations.
1 parent 81f8c12 commit 7a30d3e

15 files changed

+136
-119
lines changed

src/test/mir-opt/const_debuginfo.main.ConstDebugInfo.diff

+95-82
Large diffs are not rendered by default.

src/test/mir-opt/const_debuginfo.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// compile-flags: -C overflow-checks=no -Zunsound-mir-opts
22

3+
#![feature(bench_black_box)]
4+
35
struct Point {
46
x: u32,
57
y: u32,
@@ -19,6 +21,8 @@ fn main() {
1921

2022
let p = Point { x: 32, y: 32 };
2123
let a = p.x + p.y;
24+
25+
core::hint::black_box(());
2226
}
2327

2428
// EMIT_MIR const_debuginfo.main.ConstDebugInfo.diff

src/test/mir-opt/const_prop/optimizes_into_variable.main.SimplifyLocals.after.32bit.mir

-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ fn main() -> () {
1919
StorageLive(_1); // scope 0 at $DIR/optimizes_into_variable.rs:12:9: 12:10
2020
_1 = const 4_i32; // scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18
2121
StorageLive(_2); // scope 1 at $DIR/optimizes_into_variable.rs:13:9: 13:10
22-
_2 = const 3_i32; // scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34
2322
StorageLive(_3); // scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10
24-
_3 = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:38
2523
StorageDead(_3); // scope 2 at $DIR/optimizes_into_variable.rs:15:1: 15:2
2624
StorageDead(_2); // scope 1 at $DIR/optimizes_into_variable.rs:15:1: 15:2
2725
StorageDead(_1); // scope 0 at $DIR/optimizes_into_variable.rs:15:1: 15:2

src/test/mir-opt/const_prop/optimizes_into_variable.main.SimplifyLocals.after.64bit.mir

-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ fn main() -> () {
1919
StorageLive(_1); // scope 0 at $DIR/optimizes_into_variable.rs:12:9: 12:10
2020
_1 = const 4_i32; // scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18
2121
StorageLive(_2); // scope 1 at $DIR/optimizes_into_variable.rs:13:9: 13:10
22-
_2 = const 3_i32; // scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34
2322
StorageLive(_3); // scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10
24-
_3 = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:38
2523
StorageDead(_3); // scope 2 at $DIR/optimizes_into_variable.rs:15:1: 15:2
2624
StorageDead(_2); // scope 1 at $DIR/optimizes_into_variable.rs:15:1: 15:2
2725
StorageDead(_1); // scope 0 at $DIR/optimizes_into_variable.rs:15:1: 15:2

src/test/mir-opt/lower_array_len.array_bound.SimplifyLocals.diff

-3
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@
2525
StorageLive(_5); // scope 0 at $DIR/lower_array_len.rs:7:16: 7:27
2626
- StorageLive(_6); // scope 0 at $DIR/lower_array_len.rs:7:16: 7:27
2727
- StorageLive(_7); // scope 0 at $DIR/lower_array_len.rs:7:16: 7:27
28-
- _7 = _2; // scope 0 at $DIR/lower_array_len.rs:7:16: 7:27
2928
- StorageLive(_11); // scope 0 at $DIR/lower_array_len.rs:7:16: 7:27
30-
- _11 = _7; // scope 0 at $DIR/lower_array_len.rs:7:16: 7:27
31-
- _6 = move _7 as &[u8] (Pointer(Unsize)); // scope 0 at $DIR/lower_array_len.rs:7:16: 7:27
3229
- StorageDead(_7); // scope 0 at $DIR/lower_array_len.rs:7:20: 7:21
3330
_5 = const N; // scope 0 at $DIR/lower_array_len.rs:7:16: 7:27
3431
- StorageDead(_11); // scope 0 at $DIR/lower_array_len.rs:7:16: 7:27

src/test/mir-opt/lower_array_len.array_bound_mut.SimplifyLocals.diff

-3
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@
3131
StorageLive(_5); // scope 0 at $DIR/lower_array_len.rs:18:16: 18:27
3232
- StorageLive(_6); // scope 0 at $DIR/lower_array_len.rs:18:16: 18:27
3333
- StorageLive(_7); // scope 0 at $DIR/lower_array_len.rs:18:16: 18:27
34-
- _7 = &(*_2); // scope 0 at $DIR/lower_array_len.rs:18:16: 18:27
3534
- StorageLive(_14); // scope 0 at $DIR/lower_array_len.rs:18:16: 18:27
36-
- _14 = _7; // scope 0 at $DIR/lower_array_len.rs:18:16: 18:27
37-
- _6 = move _7 as &[u8] (Pointer(Unsize)); // scope 0 at $DIR/lower_array_len.rs:18:16: 18:27
3835
- StorageDead(_7); // scope 0 at $DIR/lower_array_len.rs:18:20: 18:21
3936
_5 = const N; // scope 0 at $DIR/lower_array_len.rs:18:16: 18:27
4037
- StorageDead(_14); // scope 0 at $DIR/lower_array_len.rs:18:16: 18:27

src/test/mir-opt/lower_array_len.array_len.SimplifyLocals.diff

-3
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111
bb0: {
1212
- StorageLive(_2); // scope 0 at $DIR/lower_array_len.rs:31:5: 31:14
1313
- StorageLive(_3); // scope 0 at $DIR/lower_array_len.rs:31:5: 31:14
14-
- _3 = _1; // scope 0 at $DIR/lower_array_len.rs:31:5: 31:14
1514
- StorageLive(_4); // scope 0 at $DIR/lower_array_len.rs:31:5: 31:14
16-
- _4 = _3; // scope 0 at $DIR/lower_array_len.rs:31:5: 31:14
17-
- _2 = move _3 as &[u8] (Pointer(Unsize)); // scope 0 at $DIR/lower_array_len.rs:31:5: 31:14
1815
- StorageDead(_3); // scope 0 at $DIR/lower_array_len.rs:31:7: 31:8
1916
_0 = const N; // scope 0 at $DIR/lower_array_len.rs:31:5: 31:14
2017
- StorageDead(_4); // scope 0 at $DIR/lower_array_len.rs:31:5: 31:14

src/test/mir-opt/lower_array_len.array_len_by_value.SimplifyLocals.diff

-3
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111
bb0: {
1212
- StorageLive(_2); // scope 0 at $DIR/lower_array_len.rs:38:5: 38:14
1313
- StorageLive(_3); // scope 0 at $DIR/lower_array_len.rs:38:5: 38:14
14-
- _3 = &_1; // scope 0 at $DIR/lower_array_len.rs:38:5: 38:14
1514
- StorageLive(_4); // scope 0 at $DIR/lower_array_len.rs:38:5: 38:14
16-
- _4 = _3; // scope 0 at $DIR/lower_array_len.rs:38:5: 38:14
17-
- _2 = move _3 as &[u8] (Pointer(Unsize)); // scope 0 at $DIR/lower_array_len.rs:38:5: 38:14
1815
- StorageDead(_3); // scope 0 at $DIR/lower_array_len.rs:38:7: 38:8
1916
_0 = const N; // scope 0 at $DIR/lower_array_len.rs:38:5: 38:14
2017
- StorageDead(_4); // scope 0 at $DIR/lower_array_len.rs:38:5: 38:14

src/test/mir-opt/separate_const_switch.too_complex.PreCodegen.after.mir

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ fn too_complex(_1: Result<i32, usize>) -> Option<i32> {
4141
StorageDead(_7); // scope 2 at $DIR/separate_const_switch.rs:17:43: 17:44
4242
StorageDead(_6); // scope 0 at $DIR/separate_const_switch.rs:17:43: 17:44
4343
StorageLive(_10); // scope 0 at $DIR/separate_const_switch.rs:21:28: 21:29
44-
_10 = ((_2 as Break).0: usize); // scope 0 at $DIR/separate_const_switch.rs:21:28: 21:29
4544
discriminant(_0) = 0; // scope 4 at $DIR/separate_const_switch.rs:21:34: 21:38
4645
StorageDead(_10); // scope 0 at $DIR/separate_const_switch.rs:21:37: 21:38
4746
goto -> bb3; // scope 0 at $DIR/separate_const_switch.rs:21:37: 21:38

src/test/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals.diff

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
- StorageLive(_10); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:30
4949
- StorageLive(_11); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:28
5050
- (_11.0: u8) = const 40_u8; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:28
51-
- _10 = const 40_u8; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:30
5251
- _9 = const 42_u8; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:34
5352
- StorageDead(_10); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:33: 16:34
5453
- _8 = use_u8(const 42_u8) -> bb2; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:5: 16:35

src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals.64bit.diff

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
}
1616

1717
bb0: {
18-
- _5 = const false; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:4:11: 4:12
1918
- _5 = const true; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:4:11: 4:12
2019
- _2 = discriminant(_1); // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:4:11: 4:12
2120
_0 = move _1; // scope 1 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:6:20: 6:27

src/test/mir-opt/tls-access.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![feature(thread_local)]
2+
#![feature(bench_black_box)]
23

34
#[thread_local]
45
static mut FOO: u8 = 3;
@@ -7,6 +8,7 @@ fn main() {
78
unsafe {
89
let a = &FOO;
910
FOO = 42;
11+
core::hint::black_box(());
1012
}
1113
}
1214

Original file line numberDiff line numberDiff line change
@@ -1,27 +1,46 @@
11
// MIR for `main` after SimplifyCfg-final
22

33
fn main() -> () {
4-
let mut _0: (); // return place in scope 0 at $DIR/tls-access.rs:6:11: 6:11
5-
let _2: *mut u8; // in scope 0 at $DIR/tls-access.rs:8:18: 8:21
6-
let mut _3: *mut u8; // in scope 0 at $DIR/tls-access.rs:9:9: 9:12
4+
let mut _0: (); // return place in scope 0 at $DIR/tls-access.rs:7:11: 7:11
5+
let _2: *mut u8; // in scope 0 at $DIR/tls-access.rs:9:18: 9:21
6+
let mut _3: *mut u8; // in scope 0 at $DIR/tls-access.rs:10:9: 10:12
7+
let _4: (); // in scope 0 at $DIR/tls-access.rs:11:9: 11:34
8+
let mut _5: (); // in scope 0 at $DIR/tls-access.rs:11:31: 11:33
79
scope 1 {
8-
let _1: &u8; // in scope 1 at $DIR/tls-access.rs:8:13: 8:14
10+
let _1: &u8; // in scope 1 at $DIR/tls-access.rs:9:13: 9:14
911
scope 2 {
10-
debug a => _1; // in scope 2 at $DIR/tls-access.rs:8:13: 8:14
12+
debug a => _1; // in scope 2 at $DIR/tls-access.rs:9:13: 9:14
13+
scope 3 (inlined std::hint::black_box::<()>) { // at $DIR/tls-access.rs:11:9: 11:34
14+
debug dummy => _5; // in scope 3 at $DIR/tls-access.rs:11:9: 11:34
15+
let mut _6: (); // in scope 3 at $DIR/tls-access.rs:11:9: 11:34
16+
}
1117
}
1218
}
1319

1420
bb0: {
15-
StorageLive(_1); // scope 1 at $DIR/tls-access.rs:8:13: 8:14
16-
StorageLive(_2); // scope 1 at $DIR/tls-access.rs:8:18: 8:21
17-
_2 = &/*tls*/ mut FOO; // scope 1 at $DIR/tls-access.rs:8:18: 8:21
18-
_1 = &(*_2); // scope 1 at $DIR/tls-access.rs:8:17: 8:21
19-
StorageLive(_3); // scope 2 at $DIR/tls-access.rs:9:9: 9:12
20-
_3 = &/*tls*/ mut FOO; // scope 2 at $DIR/tls-access.rs:9:9: 9:12
21-
(*_3) = const 42_u8; // scope 2 at $DIR/tls-access.rs:9:9: 9:17
22-
StorageDead(_3); // scope 2 at $DIR/tls-access.rs:9:17: 9:18
23-
StorageDead(_2); // scope 1 at $DIR/tls-access.rs:10:5: 10:6
24-
StorageDead(_1); // scope 1 at $DIR/tls-access.rs:10:5: 10:6
25-
return; // scope 0 at $DIR/tls-access.rs:11:2: 11:2
21+
StorageLive(_1); // scope 1 at $DIR/tls-access.rs:9:13: 9:14
22+
StorageLive(_2); // scope 1 at $DIR/tls-access.rs:9:18: 9:21
23+
_2 = &/*tls*/ mut FOO; // scope 1 at $DIR/tls-access.rs:9:18: 9:21
24+
_1 = &(*_2); // scope 1 at $DIR/tls-access.rs:9:17: 9:21
25+
StorageLive(_3); // scope 2 at $DIR/tls-access.rs:10:9: 10:12
26+
_3 = &/*tls*/ mut FOO; // scope 2 at $DIR/tls-access.rs:10:9: 10:12
27+
(*_3) = const 42_u8; // scope 2 at $DIR/tls-access.rs:10:9: 10:17
28+
StorageDead(_3); // scope 2 at $DIR/tls-access.rs:10:17: 10:18
29+
StorageLive(_4); // scope 2 at $DIR/tls-access.rs:11:9: 11:34
30+
StorageLive(_5); // scope 2 at $DIR/tls-access.rs:11:31: 11:33
31+
StorageLive(_6); // scope 3 at $DIR/tls-access.rs:11:9: 11:34
32+
_4 = std::intrinsics::black_box::<()>(const ()) -> bb1; // scope 3 at $DIR/tls-access.rs:11:9: 11:34
33+
// mir::Constant
34+
// + span: $DIR/tls-access.rs:11:9: 11:34
35+
// + literal: Const { ty: extern "rust-intrinsic" fn(()) {std::intrinsics::black_box::<()>}, val: Value(Scalar(<ZST>)) }
36+
}
37+
38+
bb1: {
39+
StorageDead(_6); // scope 3 at $DIR/tls-access.rs:11:9: 11:34
40+
StorageDead(_5); // scope 2 at $DIR/tls-access.rs:11:33: 11:34
41+
StorageDead(_4); // scope 2 at $DIR/tls-access.rs:11:34: 11:35
42+
StorageDead(_2); // scope 1 at $DIR/tls-access.rs:12:5: 12:6
43+
StorageDead(_1); // scope 1 at $DIR/tls-access.rs:12:5: 12:6
44+
return; // scope 0 at $DIR/tls-access.rs:13:2: 13:2
2645
}
2746
}

src/test/mir-opt/uninhabited_enum.process_never.SimplifyLocals.after.mir

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ fn process_never(_1: *const !) -> () {
1212

1313
bb0: {
1414
StorageLive(_2); // scope 0 at $DIR/uninhabited-enum.rs:8:8: 8:14
15-
_2 = &(*_1); // scope 2 at $DIR/uninhabited-enum.rs:8:26: 8:33
1615
StorageDead(_2); // scope 0 at $DIR/uninhabited-enum.rs:9:1: 9:2
1716
unreachable; // scope 0 at $DIR/uninhabited-enum.rs:7:39: 9:2
1817
}

src/test/mir-opt/uninhabited_enum.process_void.SimplifyLocals.after.mir

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ fn process_void(_1: *const Void) -> () {
1212

1313
bb0: {
1414
StorageLive(_2); // scope 0 at $DIR/uninhabited-enum.rs:14:8: 14:14
15-
_2 = &(*_1); // scope 2 at $DIR/uninhabited-enum.rs:14:26: 14:33
1615
StorageDead(_2); // scope 0 at $DIR/uninhabited-enum.rs:17:1: 17:2
1716
return; // scope 0 at $DIR/uninhabited-enum.rs:17:2: 17:2
1817
}

0 commit comments

Comments
 (0)