Skip to content

Commit 65a9c75

Browse files
committed
add explicit mir checks for mir-opt test
1 parent 27117a1 commit 65a9c75

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

tests/mir-opt/const_array_locals.main.GVN.diff

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,13 @@
3737
}
3838

3939
bb0: {
40-
StorageLive(_1);
40+
- StorageLive(_1);
4141
- _1 = [const 255_i32, const 105_i32, const 15_i32, const 39_i32, const 62_i32];
42+
+ nop;
4243
+ _1 = const [255_i32, 105_i32, 15_i32, 39_i32, 62_i32];
4344
StorageLive(_2);
4445
- _2 = [const 255_i32, const 105_i32, const 15_i32, const 39_i32, const 62_i32];
45-
+ _2 = const [255_i32, 105_i32, 15_i32, 39_i32, 62_i32];
46+
+ _2 = _1;
4647
StorageLive(_3);
4748
StorageLive(_4);
4849
- _4 = [const 178_i32, const 9_i32, const 4_i32, const 56_i32, const 221_i32];
@@ -63,9 +64,8 @@
6364
StorageLive(_9);
6465
StorageLive(_10);
6566
- _10 = [const 31_u32, const 96_u32, const 173_u32, const 50_u32, const 1_u32];
66-
- _9 = consume(move _10) -> [return: bb1, unwind continue];
6767
+ _10 = const [31_u32, 96_u32, 173_u32, 50_u32, 1_u32];
68-
+ _9 = consume(const [31_u32, 96_u32, 173_u32, 50_u32, 1_u32]) -> [return: bb1, unwind continue];
68+
_9 = consume(move _10) -> [return: bb1, unwind continue];
6969
}
7070

7171
bb1: {
@@ -94,7 +94,8 @@
9494
StorageDead(_6);
9595
StorageDead(_3);
9696
StorageDead(_2);
97-
StorageDead(_1);
97+
- StorageDead(_1);
98+
+ nop;
9899
return;
99100
}
100101
+ }

tests/mir-opt/const_array_locals.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,37 @@ struct F32x8([f32; 8]);
66

77
// EMIT_MIR const_array_locals.main.GVN.diff
88
// CHECK-LABEL: fn main(
9+
// CHECK: debug _arr => [[_arr:_[0-9]+]];
10+
// CHECK: debug _duplicated_arr => [[_duplicated_arr:_[0-9]+]];
11+
// CHECK: debug _foo => [[_foo:_[0-9]+]];
12+
// CHECK: debug _darr => [[_darr:_[0-9]+]];
13+
// CHECK: debug _f => [[_f:_[0-9]+]];
914
pub fn main() {
15+
// CHECK: [[_arr]] = const [255_i32, 105_i32, 15_i32, 39_i32, 62_i32];
1016
let _arr = [255, 105, 15, 39, 62];
17+
// CHECK: [[_duplicated_arr]] = [[_arr]];
1118
let _duplicated_arr = [255, 105, 15, 39, 62];
19+
// CHECK: [[subarray1:_[0-9]+]] = const [178_i32, 9_i32, 4_i32, 56_i32, 221_i32];
20+
// CHECK: [[subarray2:_[0-9]+]] = const [193_i32, 164_i32, 194_i32, 197_i32, 6_i32];
21+
// CHECK: [[_foo]] = [move [[subarray1]], move [[subarray2]]];
1222
let _foo = [[178, 9, 4, 56, 221], [193, 164, 194, 197, 6]];
23+
// CHECK: [[PROMOTED:_[0-9]+]] = const main::promoted[0];
24+
// CHECK: [[_darr]] = (*[[PROMOTED]]);
1325
let _darr = *&[254, 42, 15, 39, 62];
1426

27+
// CHECK: [[ARG:_[0-9]+]] = const [31_u32, 96_u32, 173_u32, 50_u32, 1_u32];
28+
// CHECK: consume(move [[ARG]])
1529
consume([31, 96, 173, 50, 1]);
1630

31+
// CHECK: [[OP:_[0-9]+]] = const [1f32, 2f32, 3f32, 1f32, 1f32, 1f32, 1f32, 42f32];
32+
// CHECK: [[_f]] = F32x8(move [[OP]]);
1733
let _f = F32x8([1.0, 2.0, 3.0, 1.0, 1.0, 1.0, 1.0, 42.0]);
1834

19-
// ice
35+
// ice with small arrays
36+
// CHECK: [[A:_[0-9]+]] = [const 1_i32, const 0_i32, const 0_i32];
37+
// CHECK: [[B:_[0-9]+]] = [const 0_i32, const 1_i32, const 0_i32];
38+
// CHECK: [[C:_[0-9]+]] = [const 0_i32, const 0_i32, const 1_i32];
39+
// CHECK: {{_[0-9]+}} = [move [[A]], move [[B]], move [[C]]];
2040
[[1, 0, 0], [0, 1, 0], [0, 0, 1]]; // 2D array
2141
}
2242

0 commit comments

Comments
 (0)