Skip to content

Commit 688a4dd

Browse files
committed
--bless more mir-opt tests.
1 parent ef88769 commit 688a4dd

File tree

66 files changed

+2254
-1013
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+2254
-1013
lines changed
Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,6 @@
11
// compile-flags: -O
22

3+
// EMIT_MIR rustc.main.ConstProp.diff
34
fn main() {
45
let x = (0, 1, 2).1 + 0;
56
}
6-
7-
// END RUST SOURCE
8-
// START rustc.main.ConstProp.before.mir
9-
// bb0: {
10-
// ...
11-
// _3 = (const 0i32, const 1i32, const 2i32);
12-
// _2 = (_3.1: i32);
13-
// _1 = Add(move _2, const 0i32);
14-
// ...
15-
// }
16-
// END rustc.main.ConstProp.before.mir
17-
// START rustc.main.ConstProp.after.mir
18-
// bb0: {
19-
// ...
20-
// _3 = (const 0i32, const 1i32, const 2i32);
21-
// _2 = const 1i32;
22-
// _1 = const 1i32;
23-
// ...
24-
// }
25-
// END rustc.main.ConstProp.after.mir
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
- // MIR for `main` before ConstProp
2+
+ // MIR for `main` after ConstProp
3+
4+
fn main() -> () {
5+
let mut _0: (); // return place in scope 0 at $DIR/aggregate.rs:4:11: 4:11
6+
let _1: i32; // in scope 0 at $DIR/aggregate.rs:5:9: 5:10
7+
let mut _2: i32; // in scope 0 at $DIR/aggregate.rs:5:13: 5:24
8+
let mut _3: (i32, i32, i32); // in scope 0 at $DIR/aggregate.rs:5:13: 5:22
9+
scope 1 {
10+
debug x => _1; // in scope 1 at $DIR/aggregate.rs:5:9: 5:10
11+
}
12+
13+
bb0: {
14+
StorageLive(_1); // bb0[0]: scope 0 at $DIR/aggregate.rs:5:9: 5:10
15+
StorageLive(_2); // bb0[1]: scope 0 at $DIR/aggregate.rs:5:13: 5:24
16+
StorageLive(_3); // bb0[2]: scope 0 at $DIR/aggregate.rs:5:13: 5:22
17+
_3 = (const 0i32, const 1i32, const 2i32); // bb0[3]: scope 0 at $DIR/aggregate.rs:5:13: 5:22
18+
// ty::Const
19+
// + ty: i32
20+
// + val: Value(Scalar(0x00000000))
21+
// mir::Constant
22+
// + span: $DIR/aggregate.rs:5:14: 5:15
23+
// + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
24+
// ty::Const
25+
// + ty: i32
26+
// + val: Value(Scalar(0x00000001))
27+
// mir::Constant
28+
// + span: $DIR/aggregate.rs:5:17: 5:18
29+
// + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
30+
// ty::Const
31+
// + ty: i32
32+
// + val: Value(Scalar(0x00000002))
33+
// mir::Constant
34+
// + span: $DIR/aggregate.rs:5:20: 5:21
35+
// + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) }
36+
- _2 = (_3.1: i32); // bb0[4]: scope 0 at $DIR/aggregate.rs:5:13: 5:24
37+
- _1 = Add(move _2, const 0i32); // bb0[5]: scope 0 at $DIR/aggregate.rs:5:13: 5:28
38+
+ _2 = const 1i32; // bb0[4]: scope 0 at $DIR/aggregate.rs:5:13: 5:24
39+
// ty::Const
40+
// + ty: i32
41+
- // + val: Value(Scalar(0x00000000))
42+
+ // + val: Value(Scalar(0x00000001))
43+
// mir::Constant
44+
- // + span: $DIR/aggregate.rs:5:27: 5:28
45+
- // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
46+
+ // + span: $DIR/aggregate.rs:5:13: 5:24
47+
+ // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
48+
+ _1 = const 1i32; // bb0[5]: scope 0 at $DIR/aggregate.rs:5:13: 5:28
49+
+ // ty::Const
50+
+ // + ty: i32
51+
+ // + val: Value(Scalar(0x00000001))
52+
+ // mir::Constant
53+
+ // + span: $DIR/aggregate.rs:5:13: 5:28
54+
+ // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
55+
StorageDead(_2); // bb0[6]: scope 0 at $DIR/aggregate.rs:5:27: 5:28
56+
StorageDead(_3); // bb0[7]: scope 0 at $DIR/aggregate.rs:5:28: 5:29
57+
_0 = (); // bb0[8]: scope 0 at $DIR/aggregate.rs:4:11: 6:2
58+
StorageDead(_1); // bb0[9]: scope 0 at $DIR/aggregate.rs:6:1: 6:2
59+
return; // bb0[10]: scope 0 at $DIR/aggregate.rs:6:2: 6:2
60+
}
61+
}
62+
Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,5 @@
1+
// EMIT_MIR rustc.main.ConstProp.diff
2+
13
fn main() {
24
let x: u32 = [0, 1, 2, 3][2];
35
}
4-
5-
// END RUST SOURCE
6-
// START rustc.main.ConstProp.before.mir
7-
// bb0: {
8-
// ...
9-
// _2 = [const 0u32, const 1u32, const 2u32, const 3u32];
10-
// ...
11-
// _3 = const 2usize;
12-
// _4 = const 4usize;
13-
// _5 = Lt(_3, _4);
14-
// assert(move _5, "index out of bounds: the len is move _4 but the index is _3") -> bb1;
15-
// }
16-
// bb1: {
17-
// _1 = _2[_3];
18-
// ...
19-
// return;
20-
// }
21-
// END rustc.main.ConstProp.before.mir
22-
// START rustc.main.ConstProp.after.mir
23-
// bb0: {
24-
// ...
25-
// _5 = const true;
26-
// assert(const true, "index out of bounds: the len is move _4 but the index is _3") -> bb1;
27-
// }
28-
// bb1: {
29-
// _1 = const 2u32;
30-
// ...
31-
// return;
32-
// }
33-
// END rustc.main.ConstProp.after.mir
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
- // MIR for `main` before ConstProp
2+
+ // MIR for `main` after ConstProp
3+
4+
fn main() -> () {
5+
let mut _0: (); // return place in scope 0 at $DIR/array_index.rs:3:11: 3:11
6+
let _1: u32 as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/array_index.rs:4:9: 4:10
7+
let mut _2: [u32; 4]; // in scope 0 at $DIR/array_index.rs:4:18: 4:30
8+
let _3: usize; // in scope 0 at $DIR/array_index.rs:4:31: 4:32
9+
let mut _4: usize; // in scope 0 at $DIR/array_index.rs:4:18: 4:33
10+
let mut _5: bool; // in scope 0 at $DIR/array_index.rs:4:18: 4:33
11+
scope 1 {
12+
debug x => _1; // in scope 1 at $DIR/array_index.rs:4:9: 4:10
13+
}
14+
15+
bb0: {
16+
StorageLive(_1); // bb0[0]: scope 0 at $DIR/array_index.rs:4:9: 4:10
17+
StorageLive(_2); // bb0[1]: scope 0 at $DIR/array_index.rs:4:18: 4:30
18+
_2 = [const 0u32, const 1u32, const 2u32, const 3u32]; // bb0[2]: scope 0 at $DIR/array_index.rs:4:18: 4:30
19+
// ty::Const
20+
// + ty: u32
21+
// + val: Value(Scalar(0x00000000))
22+
// mir::Constant
23+
// + span: $DIR/array_index.rs:4:19: 4:20
24+
// + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) }
25+
// ty::Const
26+
// + ty: u32
27+
// + val: Value(Scalar(0x00000001))
28+
// mir::Constant
29+
// + span: $DIR/array_index.rs:4:22: 4:23
30+
// + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) }
31+
// ty::Const
32+
// + ty: u32
33+
// + val: Value(Scalar(0x00000002))
34+
// mir::Constant
35+
// + span: $DIR/array_index.rs:4:25: 4:26
36+
// + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) }
37+
// ty::Const
38+
// + ty: u32
39+
// + val: Value(Scalar(0x00000003))
40+
// mir::Constant
41+
// + span: $DIR/array_index.rs:4:28: 4:29
42+
// + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) }
43+
StorageLive(_3); // bb0[3]: scope 0 at $DIR/array_index.rs:4:31: 4:32
44+
_3 = const 2usize; // bb0[4]: scope 0 at $DIR/array_index.rs:4:31: 4:32
45+
// ty::Const
46+
// + ty: usize
47+
// + val: Value(Scalar(0x0000000000000002))
48+
// mir::Constant
49+
// + span: $DIR/array_index.rs:4:31: 4:32
50+
// + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000002)) }
51+
_4 = const 4usize; // bb0[5]: scope 0 at $DIR/array_index.rs:4:18: 4:33
52+
// ty::Const
53+
// + ty: usize
54+
// + val: Value(Scalar(0x0000000000000004))
55+
// mir::Constant
56+
// + span: $DIR/array_index.rs:4:18: 4:33
57+
// + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000004)) }
58+
- _5 = Lt(_3, _4); // bb0[6]: scope 0 at $DIR/array_index.rs:4:18: 4:33
59+
- assert(move _5, "index out of bounds: the len is move _4 but the index is _3") -> bb1; // bb0[7]: scope 0 at $DIR/array_index.rs:4:18: 4:33
60+
+ _5 = const true; // bb0[6]: scope 0 at $DIR/array_index.rs:4:18: 4:33
61+
+ // ty::Const
62+
+ // + ty: bool
63+
+ // + val: Value(Scalar(0x01))
64+
+ // mir::Constant
65+
+ // + span: $DIR/array_index.rs:4:18: 4:33
66+
+ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
67+
+ assert(const true, "index out of bounds: the len is move _4 but the index is _3") -> bb1; // bb0[7]: scope 0 at $DIR/array_index.rs:4:18: 4:33
68+
+ // ty::Const
69+
+ // + ty: bool
70+
+ // + val: Value(Scalar(0x01))
71+
+ // mir::Constant
72+
+ // + span: $DIR/array_index.rs:4:18: 4:33
73+
+ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
74+
}
75+
76+
bb1: {
77+
- _1 = _2[_3]; // bb1[0]: scope 0 at $DIR/array_index.rs:4:18: 4:33
78+
+ _1 = const 2u32; // bb1[0]: scope 0 at $DIR/array_index.rs:4:18: 4:33
79+
+ // ty::Const
80+
+ // + ty: u32
81+
+ // + val: Value(Scalar(0x00000002))
82+
+ // mir::Constant
83+
+ // + span: $DIR/array_index.rs:4:18: 4:33
84+
+ // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) }
85+
StorageDead(_3); // bb1[1]: scope 0 at $DIR/array_index.rs:4:33: 4:34
86+
StorageDead(_2); // bb1[2]: scope 0 at $DIR/array_index.rs:4:33: 4:34
87+
_0 = (); // bb1[3]: scope 0 at $DIR/array_index.rs:3:11: 5:2
88+
StorageDead(_1); // bb1[4]: scope 0 at $DIR/array_index.rs:5:1: 5:2
89+
return; // bb1[5]: scope 0 at $DIR/array_index.rs:5:2: 5:2
90+
}
91+
}
92+

src/test/mir-opt/const_prop/boxes.rs

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,50 +7,7 @@
77

88
// Note: this test verifies that we, in fact, do not const prop `box`
99

10+
// EMIT_MIR rustc.main.ConstProp.diff
1011
fn main() {
1112
let x = *(box 42) + 0;
1213
}
13-
14-
// END RUST SOURCE
15-
// START rustc.main.ConstProp.before.mir
16-
// bb0: {
17-
// ...
18-
// _4 = Box(i32);
19-
// (*_4) = const 42i32;
20-
// _3 = move _4;
21-
// ...
22-
// _2 = (*_3);
23-
// _1 = Add(move _2, const 0i32);
24-
// ...
25-
// drop(_3) -> [return: bb2, unwind: bb1];
26-
// }
27-
// bb1 (cleanup): {
28-
// resume;
29-
// }
30-
// bb2: {
31-
// ...
32-
// _0 = ();
33-
// ...
34-
// }
35-
// END rustc.main.ConstProp.before.mir
36-
// START rustc.main.ConstProp.after.mir
37-
// bb0: {
38-
// ...
39-
// _4 = Box(i32);
40-
// (*_4) = const 42i32;
41-
// _3 = move _4;
42-
// ...
43-
// _2 = (*_3);
44-
// _1 = Add(move _2, const 0i32);
45-
// ...
46-
// drop(_3) -> [return: bb2, unwind: bb1];
47-
// }
48-
// bb1 (cleanup): {
49-
// resume;
50-
// }
51-
// bb2: {
52-
// ...
53-
// _0 = ();
54-
// ...
55-
// }
56-
// END rustc.main.ConstProp.after.mir
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
- // MIR for `main` before ConstProp
2+
+ // MIR for `main` after ConstProp
3+
4+
fn main() -> () {
5+
let mut _0: (); // return place in scope 0 at $DIR/boxes.rs:11:11: 11:11
6+
let _1: i32; // in scope 0 at $DIR/boxes.rs:12:9: 12:10
7+
let mut _2: i32; // in scope 0 at $DIR/boxes.rs:12:13: 12:22
8+
let mut _3: std::boxed::Box<i32>; // in scope 0 at $DIR/boxes.rs:12:14: 12:22
9+
let mut _4: std::boxed::Box<i32>; // in scope 0 at $DIR/boxes.rs:12:14: 12:22
10+
scope 1 {
11+
debug x => _1; // in scope 1 at $DIR/boxes.rs:12:9: 12:10
12+
}
13+
14+
bb0: {
15+
StorageLive(_1); // bb0[0]: scope 0 at $DIR/boxes.rs:12:9: 12:10
16+
StorageLive(_2); // bb0[1]: scope 0 at $DIR/boxes.rs:12:13: 12:22
17+
StorageLive(_3); // bb0[2]: scope 0 at $DIR/boxes.rs:12:14: 12:22
18+
StorageLive(_4); // bb0[3]: scope 0 at $DIR/boxes.rs:12:14: 12:22
19+
_4 = Box(i32); // bb0[4]: scope 0 at $DIR/boxes.rs:12:14: 12:22
20+
(*_4) = const 42i32; // bb0[5]: scope 0 at $DIR/boxes.rs:12:19: 12:21
21+
// ty::Const
22+
// + ty: i32
23+
// + val: Value(Scalar(0x0000002a))
24+
// mir::Constant
25+
// + span: $DIR/boxes.rs:12:19: 12:21
26+
// + literal: Const { ty: i32, val: Value(Scalar(0x0000002a)) }
27+
_3 = move _4; // bb0[6]: scope 0 at $DIR/boxes.rs:12:14: 12:22
28+
StorageDead(_4); // bb0[7]: scope 0 at $DIR/boxes.rs:12:21: 12:22
29+
_2 = (*_3); // bb0[8]: scope 0 at $DIR/boxes.rs:12:13: 12:22
30+
_1 = Add(move _2, const 0i32); // bb0[9]: scope 0 at $DIR/boxes.rs:12:13: 12:26
31+
// ty::Const
32+
// + ty: i32
33+
// + val: Value(Scalar(0x00000000))
34+
// mir::Constant
35+
// + span: $DIR/boxes.rs:12:25: 12:26
36+
// + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
37+
StorageDead(_2); // bb0[10]: scope 0 at $DIR/boxes.rs:12:25: 12:26
38+
drop(_3) -> [return: bb2, unwind: bb1]; // bb0[11]: scope 0 at $DIR/boxes.rs:12:26: 12:27
39+
}
40+
41+
bb1 (cleanup): {
42+
resume; // bb1[0]: scope 0 at $DIR/boxes.rs:11:1: 13:2
43+
}
44+
45+
bb2: {
46+
StorageDead(_3); // bb2[0]: scope 0 at $DIR/boxes.rs:12:26: 12:27
47+
_0 = (); // bb2[1]: scope 0 at $DIR/boxes.rs:11:11: 13:2
48+
StorageDead(_1); // bb2[2]: scope 0 at $DIR/boxes.rs:13:1: 13:2
49+
return; // bb2[3]: scope 0 at $DIR/boxes.rs:13:2: 13:2
50+
}
51+
}
52+
Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,6 @@
11
// compile-flags: -C overflow-checks=on
22

3+
// EMIT_MIR rustc.main.ConstProp.diff
34
fn main() {
45
let x: u32 = 1 + 1;
56
}
6-
7-
// END RUST SOURCE
8-
// START rustc.main.ConstProp.before.mir
9-
// bb0: {
10-
// ...
11-
// _2 = CheckedAdd(const 1u32, const 1u32);
12-
// assert(!move (_2.1: bool), "attempt to add with overflow") -> bb1;
13-
// }
14-
// END rustc.main.ConstProp.before.mir
15-
// START rustc.main.ConstProp.after.mir
16-
// bb0: {
17-
// ...
18-
// _2 = (const 2u32, const false);
19-
// assert(!const false, "attempt to add with overflow") -> bb1;
20-
// }
21-
// END rustc.main.ConstProp.after.mir

0 commit comments

Comments
 (0)