Skip to content

Commit 9596dd3

Browse files
committed
Maintain a graph of fulfilled conditions.
1 parent be6b5e2 commit 9596dd3

25 files changed

+1546
-604
lines changed

compiler/rustc_mir_transform/src/jump_threading.rs

Lines changed: 496 additions & 436 deletions
Large diffs are not rendered by default.
Lines changed: 335 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,335 @@
1+
- // MIR for `chained_conditions` before JumpThreading
2+
+ // MIR for `chained_conditions` after JumpThreading
3+
4+
fn chained_conditions() -> u8 {
5+
let mut _0: u8;
6+
let _1: chained_conditions::BacktraceStyle;
7+
let mut _2: std::option::Option<std::string::String>;
8+
let mut _3: &std::option::Option<std::string::String>;
9+
let mut _4: isize;
10+
let _5: std::string::String;
11+
let _6: &std::string::String;
12+
let mut _7: bool;
13+
let mut _8: &&std::string::String;
14+
let _9: &std::string::String;
15+
let mut _10: &&str;
16+
let _11: &str;
17+
let _12: std::string::String;
18+
let _13: &std::string::String;
19+
let mut _14: bool;
20+
let mut _15: &&std::string::String;
21+
let _16: &std::string::String;
22+
let mut _17: &&str;
23+
let _18: &str;
24+
let mut _19: isize;
25+
let mut _20: &&str;
26+
let mut _21: &&str;
27+
let mut _22: bool;
28+
let mut _23: bool;
29+
let mut _24: isize;
30+
let mut _25: isize;
31+
let mut _26: isize;
32+
scope 1 {
33+
debug format => _1;
34+
}
35+
scope 2 {
36+
debug x => _5;
37+
debug x => _6;
38+
}
39+
scope 3 {
40+
debug x => _12;
41+
debug x => _13;
42+
}
43+
scope 4 (inlined std::cmp::impls::<impl PartialEq<&str> for &String>::eq) {
44+
let mut _27: &std::string::String;
45+
let mut _28: &str;
46+
}
47+
scope 5 (inlined std::cmp::impls::<impl PartialEq<&str> for &String>::eq) {
48+
let mut _29: &std::string::String;
49+
let mut _30: &str;
50+
}
51+
52+
bb0: {
53+
_22 = const false;
54+
_23 = const false;
55+
StorageLive(_1);
56+
StorageLive(_2);
57+
_2 = env_var() -> [return: bb1, unwind unreachable];
58+
}
59+
60+
bb1: {
61+
_22 = const true;
62+
_23 = const true;
63+
_4 = discriminant(_2);
64+
- switchInt(move _4) -> [0: bb3, 1: bb4, otherwise: bb2];
65+
+ switchInt(move _4) -> [0: bb21, 1: bb4, otherwise: bb2];
66+
}
67+
68+
bb2: {
69+
unreachable;
70+
}
71+
72+
bb3: {
73+
_1 = chained_conditions::BacktraceStyle::Off;
74+
goto -> bb18;
75+
}
76+
77+
bb4: {
78+
StorageLive(_6);
79+
_6 = &((_2 as Some).0: std::string::String);
80+
StorageLive(_7);
81+
StorageLive(_8);
82+
StorageLive(_9);
83+
_9 = &(*_6);
84+
_8 = &_9;
85+
StorageLive(_10);
86+
_21 = const chained_conditions::promoted[1];
87+
_10 = &(*_21);
88+
StorageLive(_27);
89+
StorageLive(_28);
90+
_27 = copy (*_8);
91+
_28 = copy (*_10);
92+
_7 = <String as PartialEq<str>>::eq(move _27, move _28) -> [return: bb19, unwind unreachable];
93+
}
94+
95+
bb5: {
96+
StorageDead(_10);
97+
StorageDead(_9);
98+
StorageDead(_8);
99+
StorageDead(_7);
100+
StorageLive(_5);
101+
_23 = const false;
102+
_5 = move ((_2 as Some).0: std::string::String);
103+
_1 = chained_conditions::BacktraceStyle::Full;
104+
- drop(_5) -> [return: bb7, unwind unreachable];
105+
+ drop(_5) -> [return: bb23, unwind unreachable];
106+
}
107+
108+
bb6: {
109+
StorageDead(_10);
110+
StorageDead(_9);
111+
StorageDead(_8);
112+
StorageDead(_7);
113+
StorageDead(_6);
114+
StorageLive(_13);
115+
_13 = &((_2 as Some).0: std::string::String);
116+
StorageLive(_14);
117+
StorageLive(_15);
118+
StorageLive(_16);
119+
_16 = &(*_13);
120+
_15 = &_16;
121+
StorageLive(_17);
122+
_20 = const chained_conditions::promoted[0];
123+
_17 = &(*_20);
124+
StorageLive(_29);
125+
StorageLive(_30);
126+
_29 = copy (*_15);
127+
_30 = copy (*_17);
128+
_14 = <String as PartialEq<str>>::eq(move _29, move _30) -> [return: bb20, unwind unreachable];
129+
}
130+
131+
bb7: {
132+
StorageDead(_5);
133+
StorageDead(_6);
134+
goto -> bb18;
135+
}
136+
137+
bb8: {
138+
StorageDead(_17);
139+
StorageDead(_16);
140+
StorageDead(_15);
141+
StorageDead(_14);
142+
StorageLive(_12);
143+
_23 = const false;
144+
_12 = move ((_2 as Some).0: std::string::String);
145+
_1 = chained_conditions::BacktraceStyle::Off;
146+
- drop(_12) -> [return: bb10, unwind unreachable];
147+
+ drop(_12) -> [return: bb30, unwind unreachable];
148+
}
149+
150+
bb9: {
151+
StorageDead(_17);
152+
StorageDead(_16);
153+
StorageDead(_15);
154+
StorageDead(_14);
155+
StorageDead(_13);
156+
_1 = chained_conditions::BacktraceStyle::Short;
157+
- goto -> bb18;
158+
+ goto -> bb36;
159+
}
160+
161+
bb10: {
162+
StorageDead(_12);
163+
StorageDead(_13);
164+
goto -> bb18;
165+
}
166+
167+
bb11: {
168+
_0 = const 3_u8;
169+
goto -> bb14;
170+
}
171+
172+
bb12: {
173+
_0 = const 2_u8;
174+
goto -> bb14;
175+
}
176+
177+
bb13: {
178+
_0 = const 1_u8;
179+
goto -> bb14;
180+
}
181+
182+
bb14: {
183+
StorageDead(_1);
184+
return;
185+
}
186+
187+
bb15: {
188+
_22 = const false;
189+
_23 = const false;
190+
StorageDead(_2);
191+
_19 = discriminant(_1);
192+
switchInt(move _19) -> [0: bb13, 1: bb12, 2: bb11, otherwise: bb2];
193+
}
194+
195+
bb16: {
196+
switchInt(copy _23) -> [0: bb15, otherwise: bb17];
197+
}
198+
199+
bb17: {
200+
drop(((_2 as Some).0: std::string::String)) -> [return: bb15, unwind unreachable];
201+
}
202+
203+
bb18: {
204+
_24 = discriminant(_2);
205+
switchInt(move _24) -> [1: bb16, otherwise: bb15];
206+
}
207+
208+
bb19: {
209+
StorageDead(_28);
210+
StorageDead(_27);
211+
switchInt(move _7) -> [0: bb6, otherwise: bb5];
212+
}
213+
214+
bb20: {
215+
StorageDead(_30);
216+
StorageDead(_29);
217+
switchInt(move _14) -> [0: bb9, otherwise: bb8];
218+
+ }
219+
+
220+
+ bb21: {
221+
+ _1 = chained_conditions::BacktraceStyle::Off;
222+
+ goto -> bb40;
223+
+ }
224+
+
225+
+ bb22: {
226+
+ StorageDead(_5);
227+
+ StorageDead(_6);
228+
+ goto -> bb18;
229+
+ }
230+
+
231+
+ bb23: {
232+
+ StorageDead(_5);
233+
+ StorageDead(_6);
234+
+ goto -> bb25;
235+
+ }
236+
+
237+
+ bb24: {
238+
+ _24 = discriminant(_2);
239+
+ switchInt(move _24) -> [1: bb16, otherwise: bb15];
240+
+ }
241+
+
242+
+ bb25: {
243+
+ _24 = discriminant(_2);
244+
+ switchInt(move _24) -> [1: bb28, otherwise: bb26];
245+
+ }
246+
+
247+
+ bb26: {
248+
+ _22 = const false;
249+
+ _23 = const false;
250+
+ StorageDead(_2);
251+
+ _19 = discriminant(_1);
252+
+ goto -> bb11;
253+
+ }
254+
+
255+
+ bb27: {
256+
+ switchInt(copy _23) -> [0: bb15, otherwise: bb17];
257+
+ }
258+
+
259+
+ bb28: {
260+
+ goto -> bb26;
261+
+ }
262+
+
263+
+ bb29: {
264+
+ StorageDead(_12);
265+
+ StorageDead(_13);
266+
+ goto -> bb18;
267+
+ }
268+
+
269+
+ bb30: {
270+
+ StorageDead(_12);
271+
+ StorageDead(_13);
272+
+ goto -> bb32;
273+
+ }
274+
+
275+
+ bb31: {
276+
+ _24 = discriminant(_2);
277+
+ switchInt(move _24) -> [1: bb16, otherwise: bb15];
278+
+ }
279+
+
280+
+ bb32: {
281+
+ _24 = discriminant(_2);
282+
+ switchInt(move _24) -> [1: bb35, otherwise: bb33];
283+
+ }
284+
+
285+
+ bb33: {
286+
+ _22 = const false;
287+
+ _23 = const false;
288+
+ StorageDead(_2);
289+
+ _19 = discriminant(_1);
290+
+ goto -> bb13;
291+
+ }
292+
+
293+
+ bb34: {
294+
+ switchInt(copy _23) -> [0: bb15, otherwise: bb17];
295+
+ }
296+
+
297+
+ bb35: {
298+
+ goto -> bb33;
299+
+ }
300+
+
301+
+ bb36: {
302+
+ _24 = discriminant(_2);
303+
+ switchInt(move _24) -> [1: bb38, otherwise: bb37];
304+
+ }
305+
+
306+
+ bb37: {
307+
+ _22 = const false;
308+
+ _23 = const false;
309+
+ StorageDead(_2);
310+
+ _19 = discriminant(_1);
311+
+ goto -> bb12;
312+
+ }
313+
+
314+
+ bb38: {
315+
+ switchInt(copy _23) -> [0: bb37, otherwise: bb39];
316+
+ }
317+
+
318+
+ bb39: {
319+
+ drop(((_2 as Some).0: std::string::String)) -> [return: bb37, unwind unreachable];
320+
+ }
321+
+
322+
+ bb40: {
323+
+ _24 = discriminant(_2);
324+
+ switchInt(move _24) -> [1: bb41, otherwise: bb33];
325+
+ }
326+
+
327+
+ bb41: {
328+
+ goto -> bb42;
329+
+ }
330+
+
331+
+ bb42: {
332+
+ drop(((_2 as Some).0: std::string::String)) -> [return: bb33, unwind unreachable];
333+
}
334+
}
335+

0 commit comments

Comments
 (0)