Skip to content

Commit bddb8e4

Browse files
committed
Added gvn test for removed local storage annotations
1 parent 002bc18 commit bddb8e4

File tree

3 files changed

+291
-0
lines changed

3 files changed

+291
-0
lines changed
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
- // MIR for `main` before GVN
2+
+ // MIR for `main` after GVN
3+
4+
fn main() -> () {
5+
let mut _0: ();
6+
let _1: ();
7+
let _2: main::S;
8+
let _3: ();
9+
let mut _4: main::S;
10+
let _5: ();
11+
let _6: main::S;
12+
let _7: ();
13+
let mut _8: main::S;
14+
let _9: ();
15+
let _10: main::C;
16+
let _11: ();
17+
let mut _12: main::C;
18+
let _13: main::C;
19+
let _14: ();
20+
let mut _15: main::C;
21+
scope 1 {
22+
debug s1 => _2;
23+
}
24+
scope 2 {
25+
debug s2 => _6;
26+
}
27+
scope 3 {
28+
debug c1 => _10;
29+
}
30+
scope 4 {
31+
debug c2 => _13;
32+
}
33+
34+
bb0: {
35+
StorageLive(_1);
36+
- StorageLive(_2);
37+
- _2 = S(const 1_u32, const 2_u32);
38+
+ nop;
39+
+ _2 = const S(1_u32, 2_u32);
40+
StorageLive(_3);
41+
StorageLive(_4);
42+
- _4 = move _2;
43+
- _3 = std::mem::drop::<S>(move _4) -> [return: bb1, unwind unreachable];
44+
+ _4 = const S(1_u32, 2_u32);
45+
+ _3 = std::mem::drop::<S>(const S(1_u32, 2_u32)) -> [return: bb1, unwind unreachable];
46+
}
47+
48+
bb1: {
49+
StorageDead(_4);
50+
StorageDead(_3);
51+
_1 = const ();
52+
- StorageDead(_2);
53+
+ nop;
54+
StorageDead(_1);
55+
StorageLive(_5);
56+
- StorageLive(_6);
57+
- _6 = S(const 3_u32, const 4_u32);
58+
+ nop;
59+
+ _6 = const S(3_u32, 4_u32);
60+
StorageLive(_7);
61+
StorageLive(_8);
62+
- _8 = move _6;
63+
- _7 = std::mem::drop::<S>(move _8) -> [return: bb2, unwind unreachable];
64+
+ _8 = const S(3_u32, 4_u32);
65+
+ _7 = std::mem::drop::<S>(const S(3_u32, 4_u32)) -> [return: bb2, unwind unreachable];
66+
}
67+
68+
bb2: {
69+
StorageDead(_8);
70+
StorageDead(_7);
71+
_5 = const ();
72+
- StorageDead(_6);
73+
+ nop;
74+
StorageDead(_5);
75+
StorageLive(_9);
76+
- StorageLive(_10);
77+
- _10 = C(const 1_u32, const 2_u32);
78+
+ nop;
79+
+ _10 = const C(1_u32, 2_u32);
80+
StorageLive(_11);
81+
StorageLive(_12);
82+
- _12 = copy _10;
83+
- _11 = std::mem::drop::<C>(move _12) -> [return: bb3, unwind unreachable];
84+
+ _12 = const C(1_u32, 2_u32);
85+
+ _11 = std::mem::drop::<C>(const C(1_u32, 2_u32)) -> [return: bb3, unwind unreachable];
86+
}
87+
88+
bb3: {
89+
StorageDead(_12);
90+
StorageDead(_11);
91+
_9 = const ();
92+
- StorageDead(_10);
93+
+ nop;
94+
StorageDead(_9);
95+
- StorageLive(_13);
96+
- _13 = C(const 3_u32, const 4_u32);
97+
+ nop;
98+
+ _13 = const C(3_u32, 4_u32);
99+
StorageLive(_14);
100+
StorageLive(_15);
101+
- _15 = copy _13;
102+
- _14 = std::mem::drop::<C>(move _15) -> [return: bb4, unwind unreachable];
103+
+ _15 = const C(3_u32, 4_u32);
104+
+ _14 = std::mem::drop::<C>(const C(3_u32, 4_u32)) -> [return: bb4, unwind unreachable];
105+
}
106+
107+
bb4: {
108+
StorageDead(_15);
109+
StorageDead(_14);
110+
_0 = const ();
111+
- StorageDead(_13);
112+
+ nop;
113+
return;
114+
}
115+
+ }
116+
+
117+
+ ALLOC0 (size: 8, align: 4) {
118+
+ 03 00 00 00 04 00 00 00 │ ........
119+
+ }
120+
+
121+
+ ALLOC1 (size: 8, align: 4) {
122+
+ 01 00 00 00 02 00 00 00 │ ........
123+
+ }
124+
+
125+
+ ALLOC2 (size: 8, align: 4) {
126+
+ 03 00 00 00 04 00 00 00 │ ........
127+
+ }
128+
+
129+
+ ALLOC3 (size: 8, align: 4) {
130+
+ 01 00 00 00 02 00 00 00 │ ........
131+
}
132+
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
- // MIR for `main` before GVN
2+
+ // MIR for `main` after GVN
3+
4+
fn main() -> () {
5+
let mut _0: ();
6+
let _1: ();
7+
let _2: main::S;
8+
let _3: ();
9+
let mut _4: main::S;
10+
let _5: ();
11+
let _6: main::S;
12+
let _7: ();
13+
let mut _8: main::S;
14+
let _9: ();
15+
let _10: main::C;
16+
let _11: ();
17+
let mut _12: main::C;
18+
let _13: main::C;
19+
let _14: ();
20+
let mut _15: main::C;
21+
scope 1 {
22+
debug s1 => _2;
23+
}
24+
scope 2 {
25+
debug s2 => _6;
26+
}
27+
scope 3 {
28+
debug c1 => _10;
29+
}
30+
scope 4 {
31+
debug c2 => _13;
32+
}
33+
34+
bb0: {
35+
StorageLive(_1);
36+
- StorageLive(_2);
37+
- _2 = S(const 1_u32, const 2_u32);
38+
+ nop;
39+
+ _2 = const S(1_u32, 2_u32);
40+
StorageLive(_3);
41+
StorageLive(_4);
42+
- _4 = move _2;
43+
- _3 = std::mem::drop::<S>(move _4) -> [return: bb1, unwind continue];
44+
+ _4 = const S(1_u32, 2_u32);
45+
+ _3 = std::mem::drop::<S>(const S(1_u32, 2_u32)) -> [return: bb1, unwind continue];
46+
}
47+
48+
bb1: {
49+
StorageDead(_4);
50+
StorageDead(_3);
51+
_1 = const ();
52+
- StorageDead(_2);
53+
+ nop;
54+
StorageDead(_1);
55+
StorageLive(_5);
56+
- StorageLive(_6);
57+
- _6 = S(const 3_u32, const 4_u32);
58+
+ nop;
59+
+ _6 = const S(3_u32, 4_u32);
60+
StorageLive(_7);
61+
StorageLive(_8);
62+
- _8 = move _6;
63+
- _7 = std::mem::drop::<S>(move _8) -> [return: bb2, unwind continue];
64+
+ _8 = const S(3_u32, 4_u32);
65+
+ _7 = std::mem::drop::<S>(const S(3_u32, 4_u32)) -> [return: bb2, unwind continue];
66+
}
67+
68+
bb2: {
69+
StorageDead(_8);
70+
StorageDead(_7);
71+
_5 = const ();
72+
- StorageDead(_6);
73+
+ nop;
74+
StorageDead(_5);
75+
StorageLive(_9);
76+
- StorageLive(_10);
77+
- _10 = C(const 1_u32, const 2_u32);
78+
+ nop;
79+
+ _10 = const C(1_u32, 2_u32);
80+
StorageLive(_11);
81+
StorageLive(_12);
82+
- _12 = copy _10;
83+
- _11 = std::mem::drop::<C>(move _12) -> [return: bb3, unwind continue];
84+
+ _12 = const C(1_u32, 2_u32);
85+
+ _11 = std::mem::drop::<C>(const C(1_u32, 2_u32)) -> [return: bb3, unwind continue];
86+
}
87+
88+
bb3: {
89+
StorageDead(_12);
90+
StorageDead(_11);
91+
_9 = const ();
92+
- StorageDead(_10);
93+
+ nop;
94+
StorageDead(_9);
95+
- StorageLive(_13);
96+
- _13 = C(const 3_u32, const 4_u32);
97+
+ nop;
98+
+ _13 = const C(3_u32, 4_u32);
99+
StorageLive(_14);
100+
StorageLive(_15);
101+
- _15 = copy _13;
102+
- _14 = std::mem::drop::<C>(move _15) -> [return: bb4, unwind continue];
103+
+ _15 = const C(3_u32, 4_u32);
104+
+ _14 = std::mem::drop::<C>(const C(3_u32, 4_u32)) -> [return: bb4, unwind continue];
105+
}
106+
107+
bb4: {
108+
StorageDead(_15);
109+
StorageDead(_14);
110+
_0 = const ();
111+
- StorageDead(_13);
112+
+ nop;
113+
return;
114+
}
115+
+ }
116+
+
117+
+ ALLOC0 (size: 8, align: 4) {
118+
+ 03 00 00 00 04 00 00 00 │ ........
119+
+ }
120+
+
121+
+ ALLOC1 (size: 8, align: 4) {
122+
+ 01 00 00 00 02 00 00 00 │ ........
123+
+ }
124+
+
125+
+ ALLOC2 (size: 8, align: 4) {
126+
+ 03 00 00 00 04 00 00 00 │ ........
127+
+ }
128+
+
129+
+ ALLOC3 (size: 8, align: 4) {
130+
+ 01 00 00 00 02 00 00 00 │ ........
131+
}
132+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// skip-filecheck
2+
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
3+
//@ test-mir-pass: GVN
4+
5+
// EMIT_MIR issue_141649_gvn_storage_remove.main.GVN.diff
6+
fn main() {
7+
struct S(u32, u32);
8+
{
9+
let s1 = S(1, 2);
10+
drop(s1);
11+
}
12+
{
13+
let s2 = S(3, 4);
14+
drop(s2);
15+
}
16+
17+
#[derive(Clone, Copy)]
18+
struct C(u32, u32);
19+
{
20+
let c1 = C(1, 2);
21+
drop(c1);
22+
}
23+
{
24+
let c2 = C(3, 4);
25+
drop(c2);
26+
}
27+
}

0 commit comments

Comments
 (0)