Skip to content

Commit fb939ed

Browse files
committed
Make simplify_cfg test more consistent
Force it to always use panic=abort which means that all targets should produce the same MIR now.
1 parent 0168dfe commit fb939ed

File tree

3 files changed

+50
-47
lines changed

3 files changed

+50
-47
lines changed

src/test/mir-opt/simplify_cfg.main.SimplifyCfg-early-opt.diff

+21-20
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,47 @@
22
+ // MIR for `main` after SimplifyCfg-early-opt
33

44
fn main() -> () {
5-
let mut _0: (); // return place in scope 0 at $DIR/simplify_cfg.rs:5:11: 5:11
6-
let mut _1: (); // in scope 0 at $DIR/simplify_cfg.rs:5:1: 11:2
7-
let mut _2: bool; // in scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17
8-
let mut _3: !; // in scope 0 at $DIR/simplify_cfg.rs:7:18: 9:10
5+
let mut _0: (); // return place in scope 0 at $DIR/simplify_cfg.rs:7:11: 7:11
6+
let mut _1: (); // in scope 0 at $DIR/simplify_cfg.rs:7:1: 13:2
7+
let mut _2: bool; // in scope 0 at $DIR/simplify_cfg.rs:9:12: 9:17
8+
let mut _3: !; // in scope 0 at $DIR/simplify_cfg.rs:9:18: 11:10
99

1010
bb0: {
11-
- goto -> bb1; // scope 0 at $DIR/simplify_cfg.rs:6:5: 10:6
11+
- goto -> bb1; // scope 0 at $DIR/simplify_cfg.rs:8:5: 12:6
1212
- }
1313
-
1414
- bb1: {
15-
StorageLive(_2); // scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17
16-
- _2 = bar() -> bb2; // scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17
17-
+ _2 = bar() -> bb1; // scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17
15+
StorageLive(_2); // scope 0 at $DIR/simplify_cfg.rs:9:12: 9:17
16+
- _2 = bar() -> [return: bb2, unwind: bb5]; // scope 0 at $DIR/simplify_cfg.rs:9:12: 9:17
17+
+ _2 = bar() -> [return: bb1, unwind: bb4]; // scope 0 at $DIR/simplify_cfg.rs:9:12: 9:17
1818
// mir::Constant
19-
// + span: $DIR/simplify_cfg.rs:7:12: 7:15
19+
// + span: $DIR/simplify_cfg.rs:9:12: 9:15
2020
// + literal: Const { ty: fn() -> bool {bar}, val: Value(Scalar(<ZST>)) }
2121
}
2222

2323
- bb2: {
24-
- switchInt(move _2) -> [false: bb4, otherwise: bb3]; // scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10
24+
- switchInt(move _2) -> [false: bb4, otherwise: bb3]; // scope 0 at $DIR/simplify_cfg.rs:9:9: 11:10
2525
+ bb1: {
26-
+ switchInt(move _2) -> [false: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10
26+
+ switchInt(move _2) -> [false: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify_cfg.rs:9:9: 11:10
2727
}
2828

2929
- bb3: {
3030
+ bb2: {
31-
_0 = const (); // scope 0 at $DIR/simplify_cfg.rs:8:13: 8:18
32-
StorageDead(_2); // scope 0 at $DIR/simplify_cfg.rs:9:9: 9:10
33-
return; // scope 0 at $DIR/simplify_cfg.rs:11:2: 11:2
31+
_0 = const (); // scope 0 at $DIR/simplify_cfg.rs:10:13: 10:18
32+
StorageDead(_2); // scope 0 at $DIR/simplify_cfg.rs:11:9: 11:10
33+
return; // scope 0 at $DIR/simplify_cfg.rs:13:2: 13:2
3434
}
3535

3636
- bb4: {
3737
+ bb3: {
38-
_1 = const (); // scope 0 at $DIR/simplify_cfg.rs:9:10: 9:10
39-
StorageDead(_2); // scope 0 at $DIR/simplify_cfg.rs:9:9: 9:10
40-
goto -> bb0; // scope 0 at $DIR/simplify_cfg.rs:6:5: 10:6
41-
- }
42-
-
38+
_1 = const (); // scope 0 at $DIR/simplify_cfg.rs:11:10: 11:10
39+
StorageDead(_2); // scope 0 at $DIR/simplify_cfg.rs:11:9: 11:10
40+
goto -> bb0; // scope 0 at $DIR/simplify_cfg.rs:8:5: 12:6
41+
}
42+
4343
- bb5 (cleanup): {
44-
- resume; // scope 0 at $DIR/simplify_cfg.rs:5:1: 11:2
44+
+ bb4 (cleanup): {
45+
resume; // scope 0 at $DIR/simplify_cfg.rs:7:1: 13:2
4546
}
4647
}
4748

src/test/mir-opt/simplify_cfg.main.SimplifyCfg-initial.diff

+27-27
Original file line numberDiff line numberDiff line change
@@ -2,71 +2,71 @@
22
+ // MIR for `main` after SimplifyCfg-initial
33

44
fn main() -> () {
5-
let mut _0: (); // return place in scope 0 at $DIR/simplify_cfg.rs:5:11: 5:11
6-
let mut _1: (); // in scope 0 at $DIR/simplify_cfg.rs:5:1: 11:2
7-
let mut _2: bool; // in scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17
8-
let mut _3: !; // in scope 0 at $DIR/simplify_cfg.rs:7:18: 9:10
5+
let mut _0: (); // return place in scope 0 at $DIR/simplify_cfg.rs:7:11: 7:11
6+
let mut _1: (); // in scope 0 at $DIR/simplify_cfg.rs:7:1: 13:2
7+
let mut _2: bool; // in scope 0 at $DIR/simplify_cfg.rs:9:12: 9:17
8+
let mut _3: !; // in scope 0 at $DIR/simplify_cfg.rs:9:18: 11:10
99

1010
bb0: {
11-
- goto -> bb1; // scope 0 at $DIR/simplify_cfg.rs:6:5: 10:6
12-
+ falseUnwind -> [real: bb1, cleanup: bb5]; // scope 0 at $DIR/simplify_cfg.rs:6:5: 10:6
11+
- goto -> bb1; // scope 0 at $DIR/simplify_cfg.rs:8:5: 12:6
12+
+ falseUnwind -> [real: bb1, cleanup: bb5]; // scope 0 at $DIR/simplify_cfg.rs:8:5: 12:6
1313
}
1414

1515
bb1: {
16-
- falseUnwind -> [real: bb2, cleanup: bb10]; // scope 0 at $DIR/simplify_cfg.rs:6:5: 10:6
16+
- falseUnwind -> [real: bb2, cleanup: bb10]; // scope 0 at $DIR/simplify_cfg.rs:8:5: 12:6
1717
- }
1818
-
1919
- bb2: {
20-
StorageLive(_2); // scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17
21-
- _2 = bar() -> [return: bb3, unwind: bb10]; // scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17
22-
+ _2 = bar() -> [return: bb2, unwind: bb5]; // scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17
20+
StorageLive(_2); // scope 0 at $DIR/simplify_cfg.rs:9:12: 9:17
21+
- _2 = bar() -> [return: bb3, unwind: bb10]; // scope 0 at $DIR/simplify_cfg.rs:9:12: 9:17
22+
+ _2 = bar() -> [return: bb2, unwind: bb5]; // scope 0 at $DIR/simplify_cfg.rs:9:12: 9:17
2323
// mir::Constant
24-
// + span: $DIR/simplify_cfg.rs:7:12: 7:15
24+
// + span: $DIR/simplify_cfg.rs:9:12: 9:15
2525
// + literal: Const { ty: fn() -> bool {bar}, val: Value(Scalar(<ZST>)) }
2626
}
2727

2828
- bb3: {
29-
- switchInt(move _2) -> [false: bb5, otherwise: bb4]; // scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10
29+
- switchInt(move _2) -> [false: bb5, otherwise: bb4]; // scope 0 at $DIR/simplify_cfg.rs:9:9: 11:10
3030
+ bb2: {
31-
+ switchInt(move _2) -> [false: bb4, otherwise: bb3]; // scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10
31+
+ switchInt(move _2) -> [false: bb4, otherwise: bb3]; // scope 0 at $DIR/simplify_cfg.rs:9:9: 11:10
3232
}
3333

3434
- bb4: {
3535
+ bb3: {
36-
_0 = const (); // scope 0 at $DIR/simplify_cfg.rs:8:13: 8:18
37-
- goto -> bb9; // scope 0 at $DIR/simplify_cfg.rs:8:13: 8:18
38-
+ StorageDead(_2); // scope 0 at $DIR/simplify_cfg.rs:9:9: 9:10
39-
+ return; // scope 0 at $DIR/simplify_cfg.rs:11:2: 11:2
36+
_0 = const (); // scope 0 at $DIR/simplify_cfg.rs:10:13: 10:18
37+
- goto -> bb9; // scope 0 at $DIR/simplify_cfg.rs:10:13: 10:18
38+
+ StorageDead(_2); // scope 0 at $DIR/simplify_cfg.rs:11:9: 11:10
39+
+ return; // scope 0 at $DIR/simplify_cfg.rs:13:2: 13:2
4040
}
4141

4242
- bb5: {
4343
+ bb4: {
44-
_1 = const (); // scope 0 at $DIR/simplify_cfg.rs:9:10: 9:10
45-
- goto -> bb8; // scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10
44+
_1 = const (); // scope 0 at $DIR/simplify_cfg.rs:11:10: 11:10
45+
- goto -> bb8; // scope 0 at $DIR/simplify_cfg.rs:9:9: 11:10
4646
- }
4747
-
4848
- bb6: {
49-
- unreachable; // scope 0 at $DIR/simplify_cfg.rs:7:18: 9:10
49+
- unreachable; // scope 0 at $DIR/simplify_cfg.rs:9:18: 11:10
5050
- }
5151
-
5252
- bb7: {
53-
- goto -> bb8; // scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10
53+
- goto -> bb8; // scope 0 at $DIR/simplify_cfg.rs:9:9: 11:10
5454
- }
5555
-
5656
- bb8: {
57-
StorageDead(_2); // scope 0 at $DIR/simplify_cfg.rs:9:9: 9:10
58-
- goto -> bb1; // scope 0 at $DIR/simplify_cfg.rs:6:5: 10:6
59-
+ goto -> bb0; // scope 0 at $DIR/simplify_cfg.rs:6:5: 10:6
57+
StorageDead(_2); // scope 0 at $DIR/simplify_cfg.rs:11:9: 11:10
58+
- goto -> bb1; // scope 0 at $DIR/simplify_cfg.rs:8:5: 12:6
59+
+ goto -> bb0; // scope 0 at $DIR/simplify_cfg.rs:8:5: 12:6
6060
}
6161

6262
- bb9: {
63-
- StorageDead(_2); // scope 0 at $DIR/simplify_cfg.rs:9:9: 9:10
64-
- return; // scope 0 at $DIR/simplify_cfg.rs:11:2: 11:2
63+
- StorageDead(_2); // scope 0 at $DIR/simplify_cfg.rs:11:9: 11:10
64+
- return; // scope 0 at $DIR/simplify_cfg.rs:13:2: 13:2
6565
- }
6666
-
6767
- bb10 (cleanup): {
6868
+ bb5 (cleanup): {
69-
resume; // scope 0 at $DIR/simplify_cfg.rs:5:1: 11:2
69+
resume; // scope 0 at $DIR/simplify_cfg.rs:7:1: 13:2
7070
}
7171
}
7272

src/test/mir-opt/simplify_cfg.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// Test that the goto chain starting from bb0 is collapsed.
2+
// compile-flags: -Cpanic=abort
3+
// no-prefer-dynamic
24

35
// EMIT_MIR simplify_cfg.main.SimplifyCfg-initial.diff
46
// EMIT_MIR simplify_cfg.main.SimplifyCfg-early-opt.diff

0 commit comments

Comments
 (0)