Skip to content

Commit d69725d

Browse files
committed
Normalize block and local orders in mir-opt tests
Since this only affects `PreCodegen MIR, and it would be nice for that to be resilient to permutations of things that don't affect the actual semantic behaviours.
1 parent 05bf42b commit d69725d

25 files changed

+754
-751
lines changed

src/tools/compiletest/src/runtest.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -2045,7 +2045,10 @@ impl<'test> TestCx<'test> {
20452045
if let Some(pass) = &self.props.mir_unit_test {
20462046
rustc.args(&["-Zmir-opt-level=0", &format!("-Zmir-enable-passes=+{}", pass)]);
20472047
} else {
2048-
rustc.arg("-Zmir-opt-level=4");
2048+
rustc.args(&[
2049+
"-Zmir-opt-level=4",
2050+
"-Zmir-enable-passes=+ReorderBasicBlocks,+ReorderLocals",
2051+
]);
20492052
}
20502053

20512054
let mir_dump_dir = self.get_mir_dump_dir();

tests/mir-opt/deref-patterns/string.foo.PreCodegen.after.mir

+31-31
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,33 @@
33
fn foo(_1: Option<String>) -> i32 {
44
debug s => _1; // in scope 0 at $DIR/string.rs:+0:12: +0:13
55
let mut _0: i32; // return place in scope 0 at $DIR/string.rs:+0:34: +0:37
6-
let mut _2: &std::string::String; // in scope 0 at $DIR/string.rs:+2:14: +2:17
7-
let mut _3: &str; // in scope 0 at $DIR/string.rs:+2:14: +2:17
8-
let mut _4: bool; // in scope 0 at $DIR/string.rs:+2:14: +2:17
9-
let mut _5: isize; // in scope 0 at $DIR/string.rs:+2:9: +2:18
10-
let _6: std::option::Option<std::string::String>; // in scope 0 at $DIR/string.rs:+3:9: +3:10
11-
let mut _7: bool; // in scope 0 at $DIR/string.rs:+5:1: +5:2
6+
let mut _2: bool; // in scope 0 at $DIR/string.rs:+5:1: +5:2
7+
let mut _3: isize; // in scope 0 at $DIR/string.rs:+2:9: +2:18
8+
let mut _4: &std::string::String; // in scope 0 at $DIR/string.rs:+2:14: +2:17
9+
let mut _5: &str; // in scope 0 at $DIR/string.rs:+2:14: +2:17
10+
let mut _6: bool; // in scope 0 at $DIR/string.rs:+2:14: +2:17
11+
let _7: std::option::Option<std::string::String>; // in scope 0 at $DIR/string.rs:+3:9: +3:10
1212
scope 1 {
13-
debug s => _6; // in scope 1 at $DIR/string.rs:+3:9: +3:10
13+
debug s => _7; // in scope 1 at $DIR/string.rs:+3:9: +3:10
1414
}
1515

1616
bb0: {
17-
_7 = const false; // scope 0 at $DIR/string.rs:+1:11: +1:12
18-
_7 = const true; // scope 0 at $DIR/string.rs:+1:11: +1:12
19-
_5 = discriminant(_1); // scope 0 at $DIR/string.rs:+1:11: +1:12
20-
switchInt(move _5) -> [1: bb2, otherwise: bb1]; // scope 0 at $DIR/string.rs:+1:5: +1:12
17+
_2 = const false; // scope 0 at $DIR/string.rs:+1:11: +1:12
18+
_2 = const true; // scope 0 at $DIR/string.rs:+1:11: +1:12
19+
_3 = discriminant(_1); // scope 0 at $DIR/string.rs:+1:11: +1:12
20+
switchInt(move _3) -> [1: bb1, otherwise: bb5]; // scope 0 at $DIR/string.rs:+1:5: +1:12
2121
}
2222

2323
bb1: {
24-
StorageLive(_6); // scope 0 at $DIR/string.rs:+3:9: +3:10
25-
_7 = const false; // scope 0 at $DIR/string.rs:+3:9: +3:10
26-
_6 = move _1; // scope 0 at $DIR/string.rs:+3:9: +3:10
27-
_0 = const 4321_i32; // scope 1 at $DIR/string.rs:+3:14: +3:18
28-
drop(_6) -> [return: bb6, unwind unreachable]; // scope 0 at $DIR/string.rs:+3:17: +3:18
29-
}
30-
31-
bb2: {
32-
_2 = &((_1 as Some).0: std::string::String); // scope 0 at $DIR/string.rs:+2:14: +2:17
33-
_3 = <String as Deref>::deref(move _2) -> [return: bb3, unwind unreachable]; // scope 0 at $DIR/string.rs:+2:14: +2:17
24+
_4 = &((_1 as Some).0: std::string::String); // scope 0 at $DIR/string.rs:+2:14: +2:17
25+
_5 = <String as Deref>::deref(move _4) -> [return: bb2, unwind unreachable]; // scope 0 at $DIR/string.rs:+2:14: +2:17
3426
// mir::Constant
3527
// + span: $DIR/string.rs:9:14: 9:17
3628
// + literal: Const { ty: for<'a> fn(&'a String) -> &'a <String as Deref>::Target {<String as Deref>::deref}, val: Value(<ZST>) }
3729
}
3830

39-
bb3: {
40-
_4 = <str as PartialEq>::eq(_3, const "a") -> [return: bb4, unwind unreachable]; // scope 0 at $DIR/string.rs:+2:14: +2:17
31+
bb2: {
32+
_6 = <str as PartialEq>::eq(_5, const "a") -> [return: bb3, unwind unreachable]; // scope 0 at $DIR/string.rs:+2:14: +2:17
4133
// mir::Constant
4234
// + span: $DIR/string.rs:9:14: 9:17
4335
// + literal: Const { ty: for<'a, 'b> fn(&'a str, &'b str) -> bool {<str as PartialEq>::eq}, val: Value(<ZST>) }
@@ -46,29 +38,37 @@ fn foo(_1: Option<String>) -> i32 {
4638
// + literal: Const { ty: &str, val: Value(Slice(..)) }
4739
}
4840

41+
bb3: {
42+
switchInt(move _6) -> [0: bb5, otherwise: bb4]; // scope 0 at $DIR/string.rs:+2:14: +2:17
43+
}
44+
4945
bb4: {
50-
switchInt(move _4) -> [0: bb1, otherwise: bb5]; // scope 0 at $DIR/string.rs:+2:14: +2:17
46+
_0 = const 1234_i32; // scope 0 at $DIR/string.rs:+2:22: +2:26
47+
goto -> bb7; // scope 0 at $DIR/string.rs:+2:22: +2:26
5148
}
5249

5350
bb5: {
54-
_0 = const 1234_i32; // scope 0 at $DIR/string.rs:+2:22: +2:26
55-
goto -> bb9; // scope 0 at $DIR/string.rs:+2:22: +2:26
51+
StorageLive(_7); // scope 0 at $DIR/string.rs:+3:9: +3:10
52+
_2 = const false; // scope 0 at $DIR/string.rs:+3:9: +3:10
53+
_7 = move _1; // scope 0 at $DIR/string.rs:+3:9: +3:10
54+
_0 = const 4321_i32; // scope 1 at $DIR/string.rs:+3:14: +3:18
55+
drop(_7) -> [return: bb6, unwind unreachable]; // scope 0 at $DIR/string.rs:+3:17: +3:18
5656
}
5757

5858
bb6: {
59-
StorageDead(_6); // scope 0 at $DIR/string.rs:+3:17: +3:18
60-
goto -> bb9; // scope 0 at $DIR/string.rs:+3:17: +3:18
59+
StorageDead(_7); // scope 0 at $DIR/string.rs:+3:17: +3:18
60+
goto -> bb7; // scope 0 at $DIR/string.rs:+3:17: +3:18
6161
}
6262

6363
bb7: {
64-
return; // scope 0 at $DIR/string.rs:+5:2: +5:2
64+
switchInt(_2) -> [0: bb9, otherwise: bb8]; // scope 0 at $DIR/string.rs:+5:1: +5:2
6565
}
6666

6767
bb8: {
68-
drop(_1) -> [return: bb7, unwind unreachable]; // scope 0 at $DIR/string.rs:+5:1: +5:2
68+
drop(_1) -> [return: bb9, unwind unreachable]; // scope 0 at $DIR/string.rs:+5:1: +5:2
6969
}
7070

7171
bb9: {
72-
switchInt(_7) -> [0: bb7, otherwise: bb8]; // scope 0 at $DIR/string.rs:+5:1: +5:2
72+
return; // scope 0 at $DIR/string.rs:+5:2: +5:2
7373
}
7474
}

tests/mir-opt/inline/cycle.g.Inline.diff

+8-8
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
+ let mut _5: (); // in scope 0 at $DIR/cycle.rs:6:5: 6:8
99
+ scope 1 (inlined f::<fn() {main}>) { // at $DIR/cycle.rs:12:5: 12:12
1010
+ debug g => _2; // in scope 1 at $DIR/cycle.rs:5:6: 5:7
11-
+ let _3: (); // in scope 1 at $DIR/cycle.rs:6:5: 6:8
12-
+ let mut _4: &fn() {main}; // in scope 1 at $DIR/cycle.rs:6:5: 6:6
11+
+ let mut _3: &fn() {main}; // in scope 1 at $DIR/cycle.rs:6:5: 6:6
12+
+ let _4: (); // in scope 1 at $DIR/cycle.rs:6:5: 6:8
1313
+ scope 2 (inlined <fn() {main} as Fn<()>>::call - shim(fn() {main})) { // at $DIR/cycle.rs:6:5: 6:8
1414
+ }
1515
+ }
@@ -25,16 +25,16 @@
2525
- // mir::Constant
2626
// + span: $DIR/cycle.rs:12:7: 12:11
2727
// + literal: Const { ty: fn() {main}, val: Value(<ZST>) }
28-
+ StorageLive(_3); // scope 0 at $DIR/cycle.rs:+1:5: +1:12
29-
+ StorageLive(_4); // scope 1 at $DIR/cycle.rs:6:5: 6:6
30-
+ _4 = &_2; // scope 1 at $DIR/cycle.rs:6:5: 6:6
28+
+ StorageLive(_4); // scope 0 at $DIR/cycle.rs:+1:5: +1:12
29+
+ StorageLive(_3); // scope 1 at $DIR/cycle.rs:6:5: 6:6
30+
+ _3 = &_2; // scope 1 at $DIR/cycle.rs:6:5: 6:6
3131
+ StorageLive(_5); // scope 1 at $DIR/cycle.rs:6:5: 6:8
3232
+ _5 = const (); // scope 1 at $DIR/cycle.rs:6:5: 6:8
33-
+ _3 = move (*_4)() -> [return: bb4, unwind: bb2]; // scope 2 at $SRC_DIR/core/src/ops/function.rs:LL:COL
33+
+ _4 = move (*_3)() -> [return: bb4, unwind: bb2]; // scope 2 at $SRC_DIR/core/src/ops/function.rs:LL:COL
3434
}
3535

3636
bb1: {
37-
+ StorageDead(_3); // scope 0 at $DIR/cycle.rs:+1:5: +1:12
37+
+ StorageDead(_4); // scope 0 at $DIR/cycle.rs:+1:5: +1:12
3838
+ StorageDead(_2); // scope 0 at $DIR/cycle.rs:+1:5: +1:12
3939
StorageDead(_1); // scope 0 at $DIR/cycle.rs:+1:12: +1:13
4040
_0 = const (); // scope 0 at $DIR/cycle.rs:+0:8: +2:2
@@ -51,7 +51,7 @@
5151
+
5252
+ bb4: {
5353
+ StorageDead(_5); // scope 1 at $DIR/cycle.rs:6:5: 6:8
54-
+ StorageDead(_4); // scope 1 at $DIR/cycle.rs:6:7: 6:8
54+
+ StorageDead(_3); // scope 1 at $DIR/cycle.rs:6:7: 6:8
5555
+ drop(_2) -> bb1; // scope 1 at $DIR/cycle.rs:7:1: 7:2
5656
}
5757
}

tests/mir-opt/inline/cycle.main.Inline.diff

+8-8
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
+ let mut _5: (); // in scope 0 at $DIR/cycle.rs:6:5: 6:8
99
+ scope 1 (inlined f::<fn() {g}>) { // at $DIR/cycle.rs:17:5: 17:9
1010
+ debug g => _2; // in scope 1 at $DIR/cycle.rs:5:6: 5:7
11-
+ let _3: (); // in scope 1 at $DIR/cycle.rs:6:5: 6:8
12-
+ let mut _4: &fn() {g}; // in scope 1 at $DIR/cycle.rs:6:5: 6:6
11+
+ let mut _3: &fn() {g}; // in scope 1 at $DIR/cycle.rs:6:5: 6:6
12+
+ let _4: (); // in scope 1 at $DIR/cycle.rs:6:5: 6:8
1313
+ scope 2 (inlined <fn() {g} as Fn<()>>::call - shim(fn() {g})) { // at $DIR/cycle.rs:6:5: 6:8
1414
+ }
1515
+ }
@@ -25,16 +25,16 @@
2525
- // mir::Constant
2626
// + span: $DIR/cycle.rs:17:7: 17:8
2727
// + literal: Const { ty: fn() {g}, val: Value(<ZST>) }
28-
+ StorageLive(_3); // scope 0 at $DIR/cycle.rs:+1:5: +1:9
29-
+ StorageLive(_4); // scope 1 at $DIR/cycle.rs:6:5: 6:6
30-
+ _4 = &_2; // scope 1 at $DIR/cycle.rs:6:5: 6:6
28+
+ StorageLive(_4); // scope 0 at $DIR/cycle.rs:+1:5: +1:9
29+
+ StorageLive(_3); // scope 1 at $DIR/cycle.rs:6:5: 6:6
30+
+ _3 = &_2; // scope 1 at $DIR/cycle.rs:6:5: 6:6
3131
+ StorageLive(_5); // scope 1 at $DIR/cycle.rs:6:5: 6:8
3232
+ _5 = const (); // scope 1 at $DIR/cycle.rs:6:5: 6:8
33-
+ _3 = move (*_4)() -> [return: bb4, unwind: bb2]; // scope 2 at $SRC_DIR/core/src/ops/function.rs:LL:COL
33+
+ _4 = move (*_3)() -> [return: bb4, unwind: bb2]; // scope 2 at $SRC_DIR/core/src/ops/function.rs:LL:COL
3434
}
3535

3636
bb1: {
37-
+ StorageDead(_3); // scope 0 at $DIR/cycle.rs:+1:5: +1:9
37+
+ StorageDead(_4); // scope 0 at $DIR/cycle.rs:+1:5: +1:9
3838
+ StorageDead(_2); // scope 0 at $DIR/cycle.rs:+1:5: +1:9
3939
StorageDead(_1); // scope 0 at $DIR/cycle.rs:+1:9: +1:10
4040
_0 = const (); // scope 0 at $DIR/cycle.rs:+0:11: +2:2
@@ -51,7 +51,7 @@
5151
+
5252
+ bb4: {
5353
+ StorageDead(_5); // scope 1 at $DIR/cycle.rs:6:5: 6:8
54-
+ StorageDead(_4); // scope 1 at $DIR/cycle.rs:6:7: 6:8
54+
+ StorageDead(_3); // scope 1 at $DIR/cycle.rs:6:7: 6:8
5555
+ drop(_2) -> bb1; // scope 1 at $DIR/cycle.rs:7:1: 7:2
5656
}
5757
}

tests/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir

+12-12
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ fn foo(_1: T, _2: i32) -> (i32, T) {
1717
debug _q => _9; // in scope 2 at $DIR/inline_closure_captures.rs:+1:14: +1:16
1818
debug q => (*((*_6).0: &i32)); // in scope 2 at $DIR/inline_closure_captures.rs:+0:23: +0:24
1919
debug t => (*((*_6).1: &T)); // in scope 2 at $DIR/inline_closure_captures.rs:+0:17: +0:18
20-
let mut _10: i32; // in scope 2 at $DIR/inline_closure_captures.rs:+1:19: +1:20
21-
let mut _11: T; // in scope 2 at $DIR/inline_closure_captures.rs:+1:22: +1:23
22-
let mut _12: &i32; // in scope 2 at $DIR/inline_closure_captures.rs:+1:13: +1:24
23-
let mut _13: &T; // in scope 2 at $DIR/inline_closure_captures.rs:+1:13: +1:24
20+
let mut _10: &i32; // in scope 2 at $DIR/inline_closure_captures.rs:+1:13: +1:24
21+
let mut _11: i32; // in scope 2 at $DIR/inline_closure_captures.rs:+1:19: +1:20
22+
let mut _12: &T; // in scope 2 at $DIR/inline_closure_captures.rs:+1:13: +1:24
23+
let mut _13: T; // in scope 2 at $DIR/inline_closure_captures.rs:+1:22: +1:23
2424
}
2525
}
2626

@@ -49,15 +49,15 @@ fn foo(_1: T, _2: i32) -> (i32, T) {
4949
_7 = (move _8,); // scope 1 at $DIR/inline_closure_captures.rs:+2:5: +2:9
5050
StorageLive(_9); // scope 1 at $DIR/inline_closure_captures.rs:+2:5: +2:9
5151
_9 = move (_7.0: i32); // scope 1 at $DIR/inline_closure_captures.rs:+2:5: +2:9
52-
StorageLive(_10); // scope 2 at $DIR/inline_closure_captures.rs:+1:19: +1:20
53-
_12 = deref_copy ((*_6).0: &i32); // scope 2 at $DIR/inline_closure_captures.rs:+1:19: +1:20
54-
_10 = (*_12); // scope 2 at $DIR/inline_closure_captures.rs:+1:19: +1:20
55-
StorageLive(_11); // scope 2 at $DIR/inline_closure_captures.rs:+1:22: +1:23
56-
_13 = deref_copy ((*_6).1: &T); // scope 2 at $DIR/inline_closure_captures.rs:+1:22: +1:23
57-
_11 = (*_13); // scope 2 at $DIR/inline_closure_captures.rs:+1:22: +1:23
58-
_0 = (move _10, move _11); // scope 2 at $DIR/inline_closure_captures.rs:+1:18: +1:24
52+
StorageLive(_11); // scope 2 at $DIR/inline_closure_captures.rs:+1:19: +1:20
53+
_10 = deref_copy ((*_6).0: &i32); // scope 2 at $DIR/inline_closure_captures.rs:+1:19: +1:20
54+
_11 = (*_10); // scope 2 at $DIR/inline_closure_captures.rs:+1:19: +1:20
55+
StorageLive(_13); // scope 2 at $DIR/inline_closure_captures.rs:+1:22: +1:23
56+
_12 = deref_copy ((*_6).1: &T); // scope 2 at $DIR/inline_closure_captures.rs:+1:22: +1:23
57+
_13 = (*_12); // scope 2 at $DIR/inline_closure_captures.rs:+1:22: +1:23
58+
_0 = (move _11, move _13); // scope 2 at $DIR/inline_closure_captures.rs:+1:18: +1:24
59+
StorageDead(_13); // scope 2 at $DIR/inline_closure_captures.rs:+1:23: +1:24
5960
StorageDead(_11); // scope 2 at $DIR/inline_closure_captures.rs:+1:23: +1:24
60-
StorageDead(_10); // scope 2 at $DIR/inline_closure_captures.rs:+1:23: +1:24
6161
StorageDead(_9); // scope 1 at $DIR/inline_closure_captures.rs:+2:5: +2:9
6262
StorageDead(_8); // scope 1 at $DIR/inline_closure_captures.rs:+2:8: +2:9
6363
StorageDead(_7); // scope 1 at $DIR/inline_closure_captures.rs:+2:8: +2:9

0 commit comments

Comments
 (0)