Skip to content

Commit 7493ad0

Browse files
committed
Duplicate output for test.
1 parent bcfe1a4 commit 7493ad0

14 files changed

+491
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
- // MIR for `constant` before DataflowConstProp
2+
+ // MIR for `constant` after DataflowConstProp
3+
4+
fn constant() -> () {
5+
let mut _0: ();
6+
let _1: E;
7+
let mut _3: isize;
8+
scope 1 {
9+
debug e => _1;
10+
let _2: i32;
11+
let _4: i32;
12+
let _5: i32;
13+
scope 2 {
14+
debug x => _2;
15+
}
16+
scope 3 {
17+
debug x => _4;
18+
}
19+
scope 4 {
20+
debug x => _5;
21+
}
22+
}
23+
24+
bb0: {
25+
StorageLive(_1);
26+
_1 = const _;
27+
StorageLive(_2);
28+
- _3 = discriminant(_1);
29+
- switchInt(move _3) -> [0: bb3, 1: bb1, otherwise: bb2];
30+
+ _3 = const 0_isize;
31+
+ switchInt(const 0_isize) -> [0: bb3, 1: bb1, otherwise: bb2];
32+
}
33+
34+
bb1: {
35+
StorageLive(_5);
36+
_5 = ((_1 as V2).0: i32);
37+
_2 = _5;
38+
StorageDead(_5);
39+
goto -> bb4;
40+
}
41+
42+
bb2: {
43+
unreachable;
44+
}
45+
46+
bb3: {
47+
StorageLive(_4);
48+
- _4 = ((_1 as V1).0: i32);
49+
- _2 = _4;
50+
+ _4 = const 0_i32;
51+
+ _2 = const 0_i32;
52+
StorageDead(_4);
53+
goto -> bb4;
54+
}
55+
56+
bb4: {
57+
_0 = const ();
58+
StorageDead(_2);
59+
StorageDead(_1);
60+
return;
61+
}
62+
}
63+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
- // MIR for `multiple` before DataflowConstProp
2+
+ // MIR for `multiple` after DataflowConstProp
3+
4+
fn multiple(_1: bool, _2: u8) -> () {
5+
debug x => _1;
6+
debug i => _2;
7+
let mut _0: ();
8+
let _3: std::option::Option<u8>;
9+
let mut _4: bool;
10+
let mut _5: u8;
11+
let mut _7: isize;
12+
scope 1 {
13+
debug e => _3;
14+
let _6: u8;
15+
let _8: u8;
16+
scope 2 {
17+
debug x => _6;
18+
let _9: u8;
19+
scope 4 {
20+
debug y => _9;
21+
}
22+
}
23+
scope 3 {
24+
debug i => _8;
25+
}
26+
}
27+
28+
bb0: {
29+
StorageLive(_3);
30+
StorageLive(_4);
31+
_4 = _1;
32+
switchInt(move _4) -> [0: bb2, otherwise: bb1];
33+
}
34+
35+
bb1: {
36+
StorageLive(_5);
37+
_5 = _2;
38+
_3 = Option::<u8>::Some(move _5);
39+
StorageDead(_5);
40+
goto -> bb3;
41+
}
42+
43+
bb2: {
44+
_3 = Option::<u8>::None;
45+
goto -> bb3;
46+
}
47+
48+
bb3: {
49+
StorageDead(_4);
50+
StorageLive(_6);
51+
_7 = discriminant(_3);
52+
switchInt(move _7) -> [0: bb4, 1: bb6, otherwise: bb5];
53+
}
54+
55+
bb4: {
56+
_6 = const 0_u8;
57+
goto -> bb7;
58+
}
59+
60+
bb5: {
61+
unreachable;
62+
}
63+
64+
bb6: {
65+
StorageLive(_8);
66+
_8 = ((_3 as Some).0: u8);
67+
_6 = _8;
68+
StorageDead(_8);
69+
goto -> bb7;
70+
}
71+
72+
bb7: {
73+
StorageLive(_9);
74+
_9 = _6;
75+
_0 = const ();
76+
StorageDead(_9);
77+
StorageDead(_6);
78+
StorageDead(_3);
79+
return;
80+
}
81+
}
82+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
- // MIR for `mutate_discriminant` before DataflowConstProp
2+
+ // MIR for `mutate_discriminant` after DataflowConstProp
3+
4+
fn mutate_discriminant() -> u8 {
5+
let mut _0: u8;
6+
let mut _1: std::option::Option<NonZeroUsize>;
7+
let mut _2: isize;
8+
9+
bb0: {
10+
discriminant(_1) = 1;
11+
(((_1 as variant#1).0: NonZeroUsize).0: usize) = const 0_usize;
12+
_2 = discriminant(_1);
13+
switchInt(_2) -> [0: bb1, otherwise: bb2];
14+
}
15+
16+
bb1: {
17+
_0 = const 1_u8;
18+
return;
19+
}
20+
21+
bb2: {
22+
_0 = const 2_u8;
23+
unreachable;
24+
}
25+
}
26+

tests/mir-opt/dataflow-const-prop/enum.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// unit-test: DataflowConstProp
2+
// EMIT_MIR_FOR_EACH_BIT_WIDTH
23

34
#![feature(custom_mir, core_intrinsics, rustc_attrs)]
45

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
- // MIR for `simple` before DataflowConstProp
2+
+ // MIR for `simple` after DataflowConstProp
3+
4+
fn simple() -> () {
5+
let mut _0: ();
6+
let _1: E;
7+
let mut _3: isize;
8+
scope 1 {
9+
debug e => _1;
10+
let _2: i32;
11+
let _4: i32;
12+
let _5: i32;
13+
scope 2 {
14+
debug x => _2;
15+
}
16+
scope 3 {
17+
debug x => _4;
18+
}
19+
scope 4 {
20+
debug x => _5;
21+
}
22+
}
23+
24+
bb0: {
25+
StorageLive(_1);
26+
_1 = E::V1(const 0_i32);
27+
StorageLive(_2);
28+
- _3 = discriminant(_1);
29+
- switchInt(move _3) -> [0: bb3, 1: bb1, otherwise: bb2];
30+
+ _3 = const 0_isize;
31+
+ switchInt(const 0_isize) -> [0: bb3, 1: bb1, otherwise: bb2];
32+
}
33+
34+
bb1: {
35+
StorageLive(_5);
36+
_5 = ((_1 as V2).0: i32);
37+
_2 = _5;
38+
StorageDead(_5);
39+
goto -> bb4;
40+
}
41+
42+
bb2: {
43+
unreachable;
44+
}
45+
46+
bb3: {
47+
StorageLive(_4);
48+
- _4 = ((_1 as V1).0: i32);
49+
- _2 = _4;
50+
+ _4 = const 0_i32;
51+
+ _2 = const 0_i32;
52+
StorageDead(_4);
53+
goto -> bb4;
54+
}
55+
56+
bb4: {
57+
_0 = const ();
58+
StorageDead(_2);
59+
StorageDead(_1);
60+
return;
61+
}
62+
}
63+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
- // MIR for `statics` before DataflowConstProp
2+
+ // MIR for `statics` after DataflowConstProp
3+
4+
fn statics() -> () {
5+
let mut _0: ();
6+
let _1: E;
7+
let mut _2: &E;
8+
let mut _4: isize;
9+
let mut _8: &&E;
10+
let mut _10: isize;
11+
scope 1 {
12+
debug e => _1;
13+
let _3: i32;
14+
let _5: i32;
15+
let _6: i32;
16+
scope 2 {
17+
debug x => _3;
18+
let _7: &E;
19+
scope 5 {
20+
debug e => _7;
21+
let _9: &i32;
22+
let _11: &i32;
23+
let _12: &i32;
24+
scope 6 {
25+
debug x => _9;
26+
}
27+
scope 7 {
28+
debug x => _11;
29+
}
30+
scope 8 {
31+
debug x => _12;
32+
}
33+
}
34+
}
35+
scope 3 {
36+
debug x => _5;
37+
}
38+
scope 4 {
39+
debug x => _6;
40+
}
41+
}
42+
43+
bb0: {
44+
StorageLive(_1);
45+
StorageLive(_2);
46+
_2 = const {alloc1: &E};
47+
_1 = (*_2);
48+
StorageDead(_2);
49+
StorageLive(_3);
50+
- _4 = discriminant(_1);
51+
- switchInt(move _4) -> [0: bb3, 1: bb1, otherwise: bb2];
52+
+ _4 = const 0_isize;
53+
+ switchInt(const 0_isize) -> [0: bb3, 1: bb1, otherwise: bb2];
54+
}
55+
56+
bb1: {
57+
StorageLive(_6);
58+
_6 = ((_1 as V2).0: i32);
59+
_3 = _6;
60+
StorageDead(_6);
61+
goto -> bb4;
62+
}
63+
64+
bb2: {
65+
unreachable;
66+
}
67+
68+
bb3: {
69+
StorageLive(_5);
70+
- _5 = ((_1 as V1).0: i32);
71+
- _3 = _5;
72+
+ _5 = const 0_i32;
73+
+ _3 = const 0_i32;
74+
StorageDead(_5);
75+
goto -> bb4;
76+
}
77+
78+
bb4: {
79+
StorageLive(_7);
80+
StorageLive(_8);
81+
_8 = const {alloc2: &&E};
82+
_7 = (*_8);
83+
StorageDead(_8);
84+
StorageLive(_9);
85+
_10 = discriminant((*_7));
86+
switchInt(move _10) -> [0: bb6, 1: bb5, otherwise: bb2];
87+
}
88+
89+
bb5: {
90+
StorageLive(_12);
91+
_12 = &(((*_7) as V2).0: i32);
92+
_9 = &(*_12);
93+
StorageDead(_12);
94+
goto -> bb7;
95+
}
96+
97+
bb6: {
98+
StorageLive(_11);
99+
_11 = &(((*_7) as V1).0: i32);
100+
_9 = _11;
101+
StorageDead(_11);
102+
goto -> bb7;
103+
}
104+
105+
bb7: {
106+
_0 = const ();
107+
StorageDead(_9);
108+
StorageDead(_7);
109+
StorageDead(_3);
110+
StorageDead(_1);
111+
return;
112+
}
113+
}
114+
115+
alloc2 (static: RC, size: 4, align: 4) {
116+
╾─alloc14─╼ │ ╾──╼
117+
}
118+
119+
alloc14 (size: 8, align: 4) {
120+
01 00 00 00 04 00 00 00 │ ........
121+
}
122+
123+
alloc1 (static: statics::C, size: 8, align: 4) {
124+
00 00 00 00 00 00 00 00 │ ........
125+
}
126+

0 commit comments

Comments
 (0)