Skip to content

Commit b56ea88

Browse files
committedJul 24, 2020
Add a system for creating diffs across multiple mir optimizations.
1 parent 7138410 commit b56ea88

5 files changed

+357
-493
lines changed
 

‎src/test/mir-opt/match-arm-scopes.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
// all of the bindings for that scope.
1010
// * No drop flags are used.
1111

12-
// EMIT_MIR rustc.complicated_match.SimplifyCfg-initial.after.mir
13-
// EMIT_MIR rustc.complicated_match.ElaborateDrops.after.mir
12+
// EMIT_MIR rustc.complicated_match SimplifyCfg-initial.after ElaborateDrops.after
1413
fn complicated_match(cond: bool, items: (bool, bool, String)) -> i32 {
1514
match items {
1615
(false, a, s) | (a, false, s) if if cond { return 3 } else { a } => 1,

‎src/test/mir-opt/match-arm-scopes/rustc.complicated_match.ElaborateDrops.after.mir

Lines changed: 0 additions & 235 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,313 @@
1+
- // MIR for `complicated_match` after SimplifyCfg-initial
2+
+ // MIR for `complicated_match` after ElaborateDrops
3+
4+
fn complicated_match(_1: bool, _2: (bool, bool, std::string::String)) -> i32 {
5+
debug cond => _1; // in scope 0 at $DIR/match-arm-scopes.rs:13:22: 13:26
6+
debug items => _2; // in scope 0 at $DIR/match-arm-scopes.rs:13:34: 13:39
7+
let mut _0: i32; // return place in scope 0 at $DIR/match-arm-scopes.rs:13:66: 13:69
8+
let mut _3: &bool; // in scope 0 at $DIR/match-arm-scopes.rs:14:11: 14:16
9+
let mut _4: &bool; // in scope 0 at $DIR/match-arm-scopes.rs:14:11: 14:16
10+
let _5: bool; // in scope 0 at $DIR/match-arm-scopes.rs:15:17: 15:18
11+
let _6: &bool; // in scope 0 at $DIR/match-arm-scopes.rs:15:17: 15:18
12+
let _7: std::string::String; // in scope 0 at $DIR/match-arm-scopes.rs:15:20: 15:21
13+
let _8: &std::string::String; // in scope 0 at $DIR/match-arm-scopes.rs:15:20: 15:21
14+
let mut _9: bool; // in scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73
15+
let mut _10: bool; // in scope 0 at $DIR/match-arm-scopes.rs:15:45: 15:49
16+
let mut _11: !; // in scope 0 at $DIR/match-arm-scopes.rs:15:52: 15:60
17+
let mut _12: bool; // in scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73
18+
let mut _13: bool; // in scope 0 at $DIR/match-arm-scopes.rs:15:45: 15:49
19+
let mut _14: !; // in scope 0 at $DIR/match-arm-scopes.rs:15:52: 15:60
20+
let _15: bool; // in scope 0 at $DIR/match-arm-scopes.rs:16:16: 16:17
21+
let _16: std::string::String; // in scope 0 at $DIR/match-arm-scopes.rs:16:19: 16:20
22+
scope 1 {
23+
debug a => _5; // in scope 1 at $DIR/match-arm-scopes.rs:15:17: 15:18
24+
debug a => _6; // in scope 1 at $DIR/match-arm-scopes.rs:15:17: 15:18
25+
debug s => _7; // in scope 1 at $DIR/match-arm-scopes.rs:15:20: 15:21
26+
debug s => _8; // in scope 1 at $DIR/match-arm-scopes.rs:15:20: 15:21
27+
}
28+
scope 2 {
29+
debug b => _15; // in scope 2 at $DIR/match-arm-scopes.rs:16:16: 16:17
30+
debug t => _16; // in scope 2 at $DIR/match-arm-scopes.rs:16:19: 16:20
31+
}
32+
33+
bb0: {
34+
- FakeRead(ForMatchedPlace, _2); // scope 0 at $DIR/match-arm-scopes.rs:14:11: 14:16
35+
- switchInt((_2.0: bool)) -> [false: bb2, otherwise: bb3]; // scope 0 at $DIR/match-arm-scopes.rs:15:10: 15:15
36+
+ switchInt((_2.0: bool)) -> [false: bb6, otherwise: bb2]; // scope 0 at $DIR/match-arm-scopes.rs:15:10: 15:15
37+
}
38+
39+
bb1 (cleanup): {
40+
resume; // scope 0 at $DIR/match-arm-scopes.rs:13:1: 18:2
41+
}
42+
43+
bb2: {
44+
- falseEdge -> [real: bb9, imaginary: bb4]; // scope 0 at $DIR/match-arm-scopes.rs:15:9: 15:22
45+
+ switchInt((_2.1: bool)) -> [false: bb14, otherwise: bb3]; // scope 0 at $DIR/match-arm-scopes.rs:15:29: 15:34
46+
}
47+
48+
bb3: {
49+
- switchInt((_2.1: bool)) -> [false: bb4, otherwise: bb5]; // scope 0 at $DIR/match-arm-scopes.rs:15:29: 15:34
50+
+ switchInt((_2.0: bool)) -> [false: bb4, otherwise: bb21]; // scope 0 at $DIR/match-arm-scopes.rs:16:10: 16:14
51+
}
52+
53+
bb4: {
54+
- falseEdge -> [real: bb18, imaginary: bb6]; // scope 0 at $DIR/match-arm-scopes.rs:15:25: 15:38
55+
- }
56+
-
57+
- bb5: {
58+
- switchInt((_2.0: bool)) -> [false: bb7, otherwise: bb6]; // scope 0 at $DIR/match-arm-scopes.rs:16:10: 16:14
59+
- }
60+
-
61+
- bb6: {
62+
- falseEdge -> [real: bb26, imaginary: bb7]; // scope 0 at $DIR/match-arm-scopes.rs:16:9: 16:21
63+
- }
64+
-
65+
- bb7: {
66+
StorageLive(_15); // scope 0 at $DIR/match-arm-scopes.rs:16:32: 16:33
67+
_15 = (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:16:32: 16:33
68+
StorageLive(_16); // scope 0 at $DIR/match-arm-scopes.rs:16:35: 16:36
69+
_16 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:16:35: 16:36
70+
- goto -> bb25; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6
71+
+ goto -> bb20; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6
72+
}
73+
74+
- bb8: {
75+
+ bb5: {
76+
_0 = const 1_i32; // scope 1 at $DIR/match-arm-scopes.rs:15:77: 15:78
77+
// ty::Const
78+
// + ty: i32
79+
// + val: Value(Scalar(0x00000001))
80+
// mir::Constant
81+
// + span: $DIR/match-arm-scopes.rs:15:77: 15:78
82+
// + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
83+
- drop(_7) -> [return: bb24, unwind: bb14]; // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
84+
+ drop(_7) -> [return: bb19, unwind: bb10]; // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
85+
}
86+
87+
- bb9: {
88+
+ bb6: {
89+
StorageLive(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:17: 15:18
90+
_6 = &(_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:15:17: 15:18
91+
StorageLive(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:20: 15:21
92+
_8 = &(_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:15:20: 15:21
93+
- _3 = &shallow (_2.0: bool); // scope 0 at $DIR/match-arm-scopes.rs:14:11: 14:16
94+
- _4 = &shallow (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:14:11: 14:16
95+
StorageLive(_9); // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73
96+
StorageLive(_10); // scope 0 at $DIR/match-arm-scopes.rs:15:45: 15:49
97+
_10 = _1; // scope 0 at $DIR/match-arm-scopes.rs:15:45: 15:49
98+
- FakeRead(ForMatchedPlace, _10); // scope 0 at $DIR/match-arm-scopes.rs:15:45: 15:49
99+
- switchInt(_10) -> [false: bb11, otherwise: bb10]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73
100+
+ switchInt(_10) -> [false: bb7, otherwise: bb8]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73
101+
}
102+
103+
- bb10: {
104+
- falseEdge -> [real: bb12, imaginary: bb11]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73
105+
- }
106+
-
107+
- bb11: {
108+
+ bb7: {
109+
_9 = (*_6); // scope 0 at $DIR/match-arm-scopes.rs:15:70: 15:71
110+
StorageDead(_10); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73
111+
- switchInt(move _9) -> [false: bb17, otherwise: bb16]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73
112+
+ switchInt(move _9) -> [false: bb13, otherwise: bb12]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73
113+
}
114+
115+
- bb12: {
116+
+ bb8: {
117+
_0 = const 3_i32; // scope 0 at $DIR/match-arm-scopes.rs:15:59: 15:60
118+
// ty::Const
119+
// + ty: i32
120+
// + val: Value(Scalar(0x00000003))
121+
// mir::Constant
122+
// + span: $DIR/match-arm-scopes.rs:15:59: 15:60
123+
// + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) }
124+
StorageDead(_10); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73
125+
StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
126+
StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
127+
StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
128+
- goto -> bb15; // scope 0 at $DIR/match-arm-scopes.rs:15:52: 15:60
129+
+ goto -> bb11; // scope 0 at $DIR/match-arm-scopes.rs:15:52: 15:60
130+
}
131+
132+
- bb13: {
133+
+ bb9: {
134+
return; // scope 0 at $DIR/match-arm-scopes.rs:18:2: 18:2
135+
}
136+
137+
- bb14 (cleanup): {
138+
- drop(_2) -> bb1; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2
139+
+ bb10 (cleanup): {
140+
+ goto -> bb25; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2
141+
}
142+
143+
- bb15: {
144+
- drop(_2) -> [return: bb13, unwind: bb1]; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2
145+
+ bb11: {
146+
+ drop(_2) -> [return: bb9, unwind: bb1]; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2
147+
}
148+
149+
- bb16: {
150+
+ bb12: {
151+
StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
152+
- FakeRead(ForMatchGuard, _3); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73
153+
- FakeRead(ForMatchGuard, _4); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73
154+
- FakeRead(ForGuardBinding, _6); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73
155+
- FakeRead(ForGuardBinding, _8); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73
156+
StorageLive(_5); // scope 0 at $DIR/match-arm-scopes.rs:15:17: 15:18
157+
_5 = (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:15:17: 15:18
158+
StorageLive(_7); // scope 0 at $DIR/match-arm-scopes.rs:15:20: 15:21
159+
_7 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:15:20: 15:21
160+
- goto -> bb8; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6
161+
+ goto -> bb5; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6
162+
}
163+
164+
- bb17: {
165+
+ bb13: {
166+
StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
167+
StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
168+
StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
169+
- falseEdge -> [real: bb3, imaginary: bb4]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73
170+
+ goto -> bb2; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73
171+
}
172+
173+
- bb18: {
174+
+ bb14: {
175+
StorageLive(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:26: 15:27
176+
_6 = &(_2.0: bool); // scope 0 at $DIR/match-arm-scopes.rs:15:26: 15:27
177+
StorageLive(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:36: 15:37
178+
_8 = &(_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:15:36: 15:37
179+
- _3 = &shallow (_2.0: bool); // scope 0 at $DIR/match-arm-scopes.rs:14:11: 14:16
180+
- _4 = &shallow (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:14:11: 14:16
181+
StorageLive(_12); // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73
182+
StorageLive(_13); // scope 0 at $DIR/match-arm-scopes.rs:15:45: 15:49
183+
_13 = _1; // scope 0 at $DIR/match-arm-scopes.rs:15:45: 15:49
184+
- FakeRead(ForMatchedPlace, _13); // scope 0 at $DIR/match-arm-scopes.rs:15:45: 15:49
185+
- switchInt(_13) -> [false: bb20, otherwise: bb19]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73
186+
+ switchInt(_13) -> [false: bb15, otherwise: bb16]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73
187+
}
188+
189+
- bb19: {
190+
- falseEdge -> [real: bb21, imaginary: bb20]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73
191+
- }
192+
-
193+
- bb20: {
194+
+ bb15: {
195+
_12 = (*_6); // scope 0 at $DIR/match-arm-scopes.rs:15:70: 15:71
196+
StorageDead(_13); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73
197+
- switchInt(move _12) -> [false: bb23, otherwise: bb22]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73
198+
+ switchInt(move _12) -> [false: bb18, otherwise: bb17]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73
199+
}
200+
201+
- bb21: {
202+
+ bb16: {
203+
_0 = const 3_i32; // scope 0 at $DIR/match-arm-scopes.rs:15:59: 15:60
204+
// ty::Const
205+
// + ty: i32
206+
// + val: Value(Scalar(0x00000003))
207+
// mir::Constant
208+
// + span: $DIR/match-arm-scopes.rs:15:59: 15:60
209+
// + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) }
210+
StorageDead(_13); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73
211+
StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
212+
StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
213+
StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
214+
- goto -> bb15; // scope 0 at $DIR/match-arm-scopes.rs:15:52: 15:60
215+
+ goto -> bb11; // scope 0 at $DIR/match-arm-scopes.rs:15:52: 15:60
216+
}
217+
218+
- bb22: {
219+
+ bb17: {
220+
StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
221+
- FakeRead(ForMatchGuard, _3); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73
222+
- FakeRead(ForMatchGuard, _4); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73
223+
- FakeRead(ForGuardBinding, _6); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73
224+
- FakeRead(ForGuardBinding, _8); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73
225+
StorageLive(_5); // scope 0 at $DIR/match-arm-scopes.rs:15:26: 15:27
226+
_5 = (_2.0: bool); // scope 0 at $DIR/match-arm-scopes.rs:15:26: 15:27
227+
StorageLive(_7); // scope 0 at $DIR/match-arm-scopes.rs:15:36: 15:37
228+
_7 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:15:36: 15:37
229+
- goto -> bb8; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6
230+
+ goto -> bb5; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6
231+
}
232+
233+
- bb23: {
234+
+ bb18: {
235+
StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
236+
StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
237+
StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
238+
- falseEdge -> [real: bb5, imaginary: bb6]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73
239+
+ goto -> bb3; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73
240+
}
241+
242+
- bb24: {
243+
+ bb19: {
244+
StorageDead(_7); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
245+
StorageDead(_5); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
246+
StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
247+
StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
248+
- goto -> bb28; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6
249+
+ goto -> bb23; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6
250+
}
251+
252+
- bb25: {
253+
+ bb20: {
254+
_0 = const 2_i32; // scope 2 at $DIR/match-arm-scopes.rs:16:41: 16:42
255+
// ty::Const
256+
// + ty: i32
257+
// + val: Value(Scalar(0x00000002))
258+
// mir::Constant
259+
// + span: $DIR/match-arm-scopes.rs:16:41: 16:42
260+
// + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) }
261+
- drop(_16) -> [return: bb27, unwind: bb14]; // scope 0 at $DIR/match-arm-scopes.rs:16:41: 16:42
262+
+ drop(_16) -> [return: bb22, unwind: bb10]; // scope 0 at $DIR/match-arm-scopes.rs:16:41: 16:42
263+
}
264+
265+
- bb26: {
266+
+ bb21: {
267+
StorageLive(_15); // scope 0 at $DIR/match-arm-scopes.rs:16:16: 16:17
268+
_15 = (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:16:16: 16:17
269+
StorageLive(_16); // scope 0 at $DIR/match-arm-scopes.rs:16:19: 16:20
270+
_16 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:16:19: 16:20
271+
- goto -> bb25; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6
272+
+ goto -> bb20; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6
273+
}
274+
275+
- bb27: {
276+
+ bb22: {
277+
StorageDead(_16); // scope 0 at $DIR/match-arm-scopes.rs:16:41: 16:42
278+
StorageDead(_15); // scope 0 at $DIR/match-arm-scopes.rs:16:41: 16:42
279+
- goto -> bb28; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6
280+
+ goto -> bb23; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6
281+
}
282+
283+
- bb28: {
284+
- drop(_2) -> [return: bb13, unwind: bb1]; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2
285+
+ bb23: {
286+
+ goto -> bb29; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2
287+
+ }
288+
+
289+
+ bb24 (cleanup): {
290+
+ goto -> bb1; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2
291+
+ }
292+
+
293+
+ bb25 (cleanup): {
294+
+ goto -> bb24; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2
295+
+ }
296+
+
297+
+ bb26: {
298+
+ goto -> bb9; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2
299+
+ }
300+
+
301+
+ bb27 (cleanup): {
302+
+ goto -> bb1; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2
303+
+ }
304+
+
305+
+ bb28 (cleanup): {
306+
+ goto -> bb27; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2
307+
+ }
308+
+
309+
+ bb29: {
310+
+ goto -> bb26; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2
311+
}
312+
}
313+

‎src/test/mir-opt/match-arm-scopes/rustc.complicated_match.SimplifyCfg-initial.after.mir

Lines changed: 0 additions & 246 deletions
This file was deleted.

‎src/tools/compiletest/src/runtest.rs

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3135,14 +3135,47 @@ impl<'test> TestCx<'test> {
31353135
}
31363136
for l in test_file_contents.lines() {
31373137
if l.starts_with("// EMIT_MIR ") {
3138-
let test_name = l.trim_start_matches("// EMIT_MIR ");
3139-
let expected_file = test_dir.join(test_name);
3140-
3141-
let dumped_string = if test_name.ends_with(".diff") {
3142-
let test_name = test_name.trim_end_matches(".diff");
3143-
let before = format!("{}.before.mir", test_name);
3144-
let after = format!("{}.after.mir", test_name);
3145-
let before = self.get_mir_dump_dir().join(before);
3138+
let test_name = l.trim_start_matches("// EMIT_MIR ").trim();
3139+
let mut test_names = test_name.split(' ');
3140+
// sometimes we specify two files so that we get a diff between the two files
3141+
let test_name = test_names.next().unwrap();
3142+
let expected_file;
3143+
let from_file;
3144+
let to_file;
3145+
3146+
if test_name.ends_with(".diff") {
3147+
let trimmed = test_name.trim_end_matches(".diff");
3148+
let test_against = format!("{}.after.mir", trimmed);
3149+
from_file = format!("{}.before.mir", trimmed);
3150+
expected_file = test_name.to_string();
3151+
assert!(
3152+
test_names.next().is_none(),
3153+
"two mir pass names specified for MIR diff"
3154+
);
3155+
to_file = Some(test_against);
3156+
} else if let Some(first_pass) = test_names.next() {
3157+
let second_pass = test_names.next().unwrap();
3158+
assert!(
3159+
test_names.next().is_none(),
3160+
"three mir pass names specified for MIR diff"
3161+
);
3162+
expected_file = format!("{}.{}-{}.diff", test_name, first_pass, second_pass);
3163+
let second_file = format!("{}.{}.mir", test_name, second_pass);
3164+
from_file = format!("{}.{}.mir", test_name, first_pass);
3165+
to_file = Some(second_file);
3166+
} else {
3167+
expected_file = test_name.to_string();
3168+
from_file = test_name.to_string();
3169+
assert!(
3170+
test_names.next().is_none(),
3171+
"two mir pass names specified for MIR dump"
3172+
);
3173+
to_file = None;
3174+
};
3175+
let expected_file = test_dir.join(expected_file);
3176+
3177+
let dumped_string = if let Some(after) = to_file {
3178+
let before = self.get_mir_dump_dir().join(from_file);
31463179
let after = self.get_mir_dump_dir().join(after);
31473180
debug!(
31483181
"comparing the contents of: {} with {}",
@@ -3166,7 +3199,7 @@ impl<'test> TestCx<'test> {
31663199
} else {
31673200
let mut output_file = PathBuf::new();
31683201
output_file.push(self.get_mir_dump_dir());
3169-
output_file.push(test_name);
3202+
output_file.push(&from_file);
31703203
debug!(
31713204
"comparing the contents of: {} with {}",
31723205
output_file.display(),
@@ -3179,7 +3212,7 @@ impl<'test> TestCx<'test> {
31793212
output_file.parent().unwrap().display()
31803213
);
31813214
}
3182-
self.check_mir_test_timestamp(test_name, &output_file);
3215+
self.check_mir_test_timestamp(&from_file, &output_file);
31833216
let dumped_string = fs::read_to_string(&output_file).unwrap();
31843217
self.normalize_output(&dumped_string, &[])
31853218
};

0 commit comments

Comments
 (0)
Please sign in to comment.