Skip to content

Commit 377a361

Browse files
committed
Clean up MIR opt tests around simplify_try.
This commit makes a couple of changes: 1. Rename `simplify-arm` to `simplify_arm` so that it appears with the output files. 2. Deduplicate tests across `simplify_arm` and `simplify_try`. This moves all the tests to `simplify_arm`, where output for both opts is emitted where appropriate. Output for `SimplifyLocals` and `DestProp` is removed, because `DestProp` is unsound and not interesting for this case anyway, while `simplify_arm` calls `simplify_locals` internally anyway 3. Blesses the `simplify_arm` tests with the new optimization. squash 1
1 parent 3b06220 commit 377a361

12 files changed

+183
-504
lines changed

src/test/mir-opt/simplify_arm.id.SimplifyArmIdentity.diff

+21-29
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,37 @@
22
+ // MIR for `id` after SimplifyArmIdentity
33

44
fn id(_1: Option<u8>) -> Option<u8> {
5-
debug o => _1; // in scope 0 at $DIR/simplify-arm.rs:9:7: 9:8
6-
let mut _0: std::option::Option<u8>; // return place in scope 0 at $DIR/simplify-arm.rs:9:25: 9:35
7-
let mut _2: isize; // in scope 0 at $DIR/simplify-arm.rs:11:9: 11:16
8-
let _3: u8; // in scope 0 at $DIR/simplify-arm.rs:11:14: 11:15
9-
let mut _4: u8; // in scope 0 at $DIR/simplify-arm.rs:11:25: 11:26
5+
debug o => _1; // in scope 0 at $DIR/simplify_arm.rs:5:7: 5:8
6+
let mut _0: std::option::Option<u8>; // return place in scope 0 at $DIR/simplify_arm.rs:5:25: 5:35
7+
let mut _2: isize; // in scope 0 at $DIR/simplify_arm.rs:7:9: 7:16
8+
- let _3: u8; // in scope 0 at $DIR/simplify_arm.rs:7:14: 7:15
9+
- let mut _4: u8; // in scope 0 at $DIR/simplify_arm.rs:7:25: 7:26
1010
scope 1 {
11-
- debug v => _3; // in scope 1 at $DIR/simplify-arm.rs:11:14: 11:15
12-
+ debug v => ((_0 as Some).0: u8); // in scope 1 at $DIR/simplify-arm.rs:11:14: 11:15
11+
- debug v => _3; // in scope 1 at $DIR/simplify_arm.rs:7:14: 7:15
12+
+ debug v => ((_0 as Some).0: u8); // in scope 1 at $DIR/simplify_arm.rs:7:14: 7:15
1313
}
1414

1515
bb0: {
16-
_2 = discriminant(_1); // scope 0 at $DIR/simplify-arm.rs:10:11: 10:12
17-
switchInt(move _2) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify-arm.rs:10:5: 10:12
16+
_2 = discriminant(_1); // scope 0 at $DIR/simplify_arm.rs:6:11: 6:12
17+
switchInt(move _2) -> [0_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify_arm.rs:6:5: 6:12
1818
}
1919

2020
bb1: {
21-
discriminant(_0) = 0; // scope 0 at $DIR/simplify-arm.rs:12:17: 12:21
22-
goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:12:17: 12:21
21+
discriminant(_0) = 0; // scope 0 at $DIR/simplify_arm.rs:8:17: 8:21
22+
return; // scope 0 at $DIR/simplify_arm.rs:8:17: 8:21
2323
}
2424

2525
bb2: {
26-
unreachable; // scope 0 at $DIR/simplify-arm.rs:10:11: 10:12
27-
}
28-
29-
bb3: {
30-
- StorageLive(_3); // scope 0 at $DIR/simplify-arm.rs:11:14: 11:15
31-
- _3 = ((_1 as Some).0: u8); // scope 0 at $DIR/simplify-arm.rs:11:14: 11:15
32-
- StorageLive(_4); // scope 1 at $DIR/simplify-arm.rs:11:25: 11:26
33-
- _4 = _3; // scope 1 at $DIR/simplify-arm.rs:11:25: 11:26
34-
- ((_0 as Some).0: u8) = move _4; // scope 1 at $DIR/simplify-arm.rs:11:20: 11:27
35-
- discriminant(_0) = 1; // scope 1 at $DIR/simplify-arm.rs:11:20: 11:27
36-
- StorageDead(_4); // scope 1 at $DIR/simplify-arm.rs:11:26: 11:27
37-
- StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:11:26: 11:27
38-
+ _0 = move _1; // scope 1 at $DIR/simplify-arm.rs:11:20: 11:27
39-
goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:11:26: 11:27
40-
}
41-
42-
bb4: {
43-
return; // scope 0 at $DIR/simplify-arm.rs:14:2: 14:2
26+
- StorageLive(_3); // scope 0 at $DIR/simplify_arm.rs:7:14: 7:15
27+
- _3 = ((_1 as Some).0: u8); // scope 0 at $DIR/simplify_arm.rs:7:14: 7:15
28+
- StorageLive(_4); // scope 1 at $DIR/simplify_arm.rs:7:25: 7:26
29+
- _4 = _3; // scope 1 at $DIR/simplify_arm.rs:7:25: 7:26
30+
- ((_0 as Some).0: u8) = move _4; // scope 1 at $DIR/simplify_arm.rs:7:20: 7:27
31+
- discriminant(_0) = 1; // scope 1 at $DIR/simplify_arm.rs:7:20: 7:27
32+
- StorageDead(_4); // scope 1 at $DIR/simplify_arm.rs:7:26: 7:27
33+
- StorageDead(_3); // scope 0 at $DIR/simplify_arm.rs:7:26: 7:27
34+
+ _0 = _1; // scope 1 at $DIR/simplify_arm.rs:7:20: 7:27
35+
return; // scope 0 at $DIR/simplify_arm.rs:7:26: 7:27
4436
}
4537
}
4638

src/test/mir-opt/simplify_arm.id.SimplifyBranchSame.diff

+11-23
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,27 @@
22
+ // MIR for `id` after SimplifyBranchSame
33

44
fn id(_1: Option<u8>) -> Option<u8> {
5-
debug o => _1; // in scope 0 at $DIR/simplify-arm.rs:9:7: 9:8
6-
let mut _0: std::option::Option<u8>; // return place in scope 0 at $DIR/simplify-arm.rs:9:25: 9:35
7-
let mut _2: isize; // in scope 0 at $DIR/simplify-arm.rs:11:9: 11:16
8-
let _3: u8; // in scope 0 at $DIR/simplify-arm.rs:11:14: 11:15
9-
let mut _4: u8; // in scope 0 at $DIR/simplify-arm.rs:11:25: 11:26
5+
debug o => _1; // in scope 0 at $DIR/simplify_arm.rs:5:7: 5:8
6+
let mut _0: std::option::Option<u8>; // return place in scope 0 at $DIR/simplify_arm.rs:5:25: 5:35
7+
let mut _2: isize; // in scope 0 at $DIR/simplify_arm.rs:7:9: 7:16
108
scope 1 {
11-
debug v => ((_0 as Some).0: u8); // in scope 1 at $DIR/simplify-arm.rs:11:14: 11:15
9+
debug v => ((_0 as Some).0: u8); // in scope 1 at $DIR/simplify_arm.rs:7:14: 7:15
1210
}
1311

1412
bb0: {
15-
_2 = discriminant(_1); // scope 0 at $DIR/simplify-arm.rs:10:11: 10:12
16-
- switchInt(move _2) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify-arm.rs:10:5: 10:12
17-
+ goto -> bb1; // scope 0 at $DIR/simplify-arm.rs:10:5: 10:12
13+
_2 = discriminant(_1); // scope 0 at $DIR/simplify_arm.rs:6:11: 6:12
14+
- switchInt(move _2) -> [0_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify_arm.rs:6:5: 6:12
15+
+ goto -> bb1; // scope 0 at $DIR/simplify_arm.rs:6:5: 6:12
1816
}
1917

2018
bb1: {
21-
- discriminant(_0) = 0; // scope 0 at $DIR/simplify-arm.rs:12:17: 12:21
22-
- goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:12:17: 12:21
19+
- discriminant(_0) = 0; // scope 0 at $DIR/simplify_arm.rs:8:17: 8:21
20+
- return; // scope 0 at $DIR/simplify_arm.rs:8:17: 8:21
2321
- }
2422
-
2523
- bb2: {
26-
- unreachable; // scope 0 at $DIR/simplify-arm.rs:10:11: 10:12
27-
- }
28-
-
29-
- bb3: {
30-
_0 = move _1; // scope 1 at $DIR/simplify-arm.rs:11:20: 11:27
31-
- goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:11:26: 11:27
32-
+ goto -> bb2; // scope 0 at $DIR/simplify-arm.rs:11:26: 11:27
33-
}
34-
35-
- bb4: {
36-
+ bb2: {
37-
return; // scope 0 at $DIR/simplify-arm.rs:14:2: 14:2
24+
_0 = _1; // scope 1 at $DIR/simplify_arm.rs:7:20: 7:27
25+
return; // scope 0 at $DIR/simplify_arm.rs:7:26: 7:27
3826
}
3927
}
4028

src/test/mir-opt/simplify_arm.id_result.SimplifyArmIdentity.diff

+33-41
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,51 @@
22
+ // MIR for `id_result` after SimplifyArmIdentity
33

44
fn id_result(_1: Result<u8, i32>) -> Result<u8, i32> {
5-
debug r => _1; // in scope 0 at $DIR/simplify-arm.rs:16:14: 16:15
6-
let mut _0: std::result::Result<u8, i32>; // return place in scope 0 at $DIR/simplify-arm.rs:16:37: 16:52
7-
let mut _2: isize; // in scope 0 at $DIR/simplify-arm.rs:18:9: 18:14
8-
let _3: u8; // in scope 0 at $DIR/simplify-arm.rs:18:12: 18:13
9-
let mut _4: u8; // in scope 0 at $DIR/simplify-arm.rs:18:21: 18:22
10-
let _5: i32; // in scope 0 at $DIR/simplify-arm.rs:19:13: 19:14
11-
let mut _6: i32; // in scope 0 at $DIR/simplify-arm.rs:19:23: 19:24
5+
debug r => _1; // in scope 0 at $DIR/simplify_arm.rs:14:14: 14:15
6+
let mut _0: std::result::Result<u8, i32>; // return place in scope 0 at $DIR/simplify_arm.rs:14:37: 14:52
7+
let mut _2: isize; // in scope 0 at $DIR/simplify_arm.rs:16:9: 16:14
8+
- let _3: u8; // in scope 0 at $DIR/simplify_arm.rs:16:12: 16:13
9+
- let mut _4: u8; // in scope 0 at $DIR/simplify_arm.rs:16:21: 16:22
10+
- let _5: i32; // in scope 0 at $DIR/simplify_arm.rs:17:13: 17:14
11+
- let mut _6: i32; // in scope 0 at $DIR/simplify_arm.rs:17:23: 17:24
1212
scope 1 {
13-
- debug x => _3; // in scope 1 at $DIR/simplify-arm.rs:18:12: 18:13
14-
+ debug x => ((_0 as Ok).0: u8); // in scope 1 at $DIR/simplify-arm.rs:18:12: 18:13
13+
- debug x => _3; // in scope 1 at $DIR/simplify_arm.rs:16:12: 16:13
14+
+ debug x => ((_0 as Ok).0: u8); // in scope 1 at $DIR/simplify_arm.rs:16:12: 16:13
1515
}
1616
scope 2 {
17-
- debug y => _5; // in scope 2 at $DIR/simplify-arm.rs:19:13: 19:14
18-
+ debug y => ((_0 as Err).0: i32); // in scope 2 at $DIR/simplify-arm.rs:19:13: 19:14
17+
- debug y => _5; // in scope 2 at $DIR/simplify_arm.rs:17:13: 17:14
18+
+ debug y => ((_0 as Err).0: i32); // in scope 2 at $DIR/simplify_arm.rs:17:13: 17:14
1919
}
2020

2121
bb0: {
22-
_2 = discriminant(_1); // scope 0 at $DIR/simplify-arm.rs:17:11: 17:12
23-
switchInt(move _2) -> [0_isize: bb3, 1_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify-arm.rs:17:5: 17:12
22+
_2 = discriminant(_1); // scope 0 at $DIR/simplify_arm.rs:15:11: 15:12
23+
switchInt(move _2) -> [0_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/simplify_arm.rs:15:5: 15:12
2424
}
2525

2626
bb1: {
27-
- StorageLive(_5); // scope 0 at $DIR/simplify-arm.rs:19:13: 19:14
28-
- _5 = ((_1 as Err).0: i32); // scope 0 at $DIR/simplify-arm.rs:19:13: 19:14
29-
- StorageLive(_6); // scope 2 at $DIR/simplify-arm.rs:19:23: 19:24
30-
- _6 = _5; // scope 2 at $DIR/simplify-arm.rs:19:23: 19:24
31-
- ((_0 as Err).0: i32) = move _6; // scope 2 at $DIR/simplify-arm.rs:19:19: 19:25
32-
- discriminant(_0) = 1; // scope 2 at $DIR/simplify-arm.rs:19:19: 19:25
33-
- StorageDead(_6); // scope 2 at $DIR/simplify-arm.rs:19:24: 19:25
34-
- StorageDead(_5); // scope 0 at $DIR/simplify-arm.rs:19:24: 19:25
35-
+ _0 = move _1; // scope 2 at $DIR/simplify-arm.rs:19:19: 19:25
36-
goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:19:24: 19:25
27+
- StorageLive(_5); // scope 0 at $DIR/simplify_arm.rs:17:13: 17:14
28+
- _5 = ((_1 as Err).0: i32); // scope 0 at $DIR/simplify_arm.rs:17:13: 17:14
29+
- StorageLive(_6); // scope 2 at $DIR/simplify_arm.rs:17:23: 17:24
30+
- _6 = _5; // scope 2 at $DIR/simplify_arm.rs:17:23: 17:24
31+
- ((_0 as Err).0: i32) = move _6; // scope 2 at $DIR/simplify_arm.rs:17:19: 17:25
32+
- discriminant(_0) = 1; // scope 2 at $DIR/simplify_arm.rs:17:19: 17:25
33+
- StorageDead(_6); // scope 2 at $DIR/simplify_arm.rs:17:24: 17:25
34+
- StorageDead(_5); // scope 0 at $DIR/simplify_arm.rs:17:24: 17:25
35+
+ _0 = _1; // scope 2 at $DIR/simplify_arm.rs:17:19: 17:25
36+
return; // scope 0 at $DIR/simplify_arm.rs:17:24: 17:25
3737
}
3838

3939
bb2: {
40-
unreachable; // scope 0 at $DIR/simplify-arm.rs:17:11: 17:12
41-
}
42-
43-
bb3: {
44-
- StorageLive(_3); // scope 0 at $DIR/simplify-arm.rs:18:12: 18:13
45-
- _3 = ((_1 as Ok).0: u8); // scope 0 at $DIR/simplify-arm.rs:18:12: 18:13
46-
- StorageLive(_4); // scope 1 at $DIR/simplify-arm.rs:18:21: 18:22
47-
- _4 = _3; // scope 1 at $DIR/simplify-arm.rs:18:21: 18:22
48-
- ((_0 as Ok).0: u8) = move _4; // scope 1 at $DIR/simplify-arm.rs:18:18: 18:23
49-
- discriminant(_0) = 0; // scope 1 at $DIR/simplify-arm.rs:18:18: 18:23
50-
- StorageDead(_4); // scope 1 at $DIR/simplify-arm.rs:18:22: 18:23
51-
- StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:18:22: 18:23
52-
+ _0 = move _1; // scope 1 at $DIR/simplify-arm.rs:18:18: 18:23
53-
goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:18:22: 18:23
54-
}
55-
56-
bb4: {
57-
return; // scope 0 at $DIR/simplify-arm.rs:21:2: 21:2
40+
- StorageLive(_3); // scope 0 at $DIR/simplify_arm.rs:16:12: 16:13
41+
- _3 = ((_1 as Ok).0: u8); // scope 0 at $DIR/simplify_arm.rs:16:12: 16:13
42+
- StorageLive(_4); // scope 1 at $DIR/simplify_arm.rs:16:21: 16:22
43+
- _4 = _3; // scope 1 at $DIR/simplify_arm.rs:16:21: 16:22
44+
- ((_0 as Ok).0: u8) = move _4; // scope 1 at $DIR/simplify_arm.rs:16:18: 16:23
45+
- discriminant(_0) = 0; // scope 1 at $DIR/simplify_arm.rs:16:18: 16:23
46+
- StorageDead(_4); // scope 1 at $DIR/simplify_arm.rs:16:22: 16:23
47+
- StorageDead(_3); // scope 0 at $DIR/simplify_arm.rs:16:22: 16:23
48+
+ _0 = _1; // scope 1 at $DIR/simplify_arm.rs:16:18: 16:23
49+
return; // scope 0 at $DIR/simplify_arm.rs:16:22: 16:23
5850
}
5951
}
6052

src/test/mir-opt/simplify_arm.id_result.SimplifyBranchSame.diff

+12-26
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,30 @@
22
+ // MIR for `id_result` after SimplifyBranchSame
33

44
fn id_result(_1: Result<u8, i32>) -> Result<u8, i32> {
5-
debug r => _1; // in scope 0 at $DIR/simplify-arm.rs:16:14: 16:15
6-
let mut _0: std::result::Result<u8, i32>; // return place in scope 0 at $DIR/simplify-arm.rs:16:37: 16:52
7-
let mut _2: isize; // in scope 0 at $DIR/simplify-arm.rs:18:9: 18:14
8-
let _3: u8; // in scope 0 at $DIR/simplify-arm.rs:18:12: 18:13
9-
let mut _4: u8; // in scope 0 at $DIR/simplify-arm.rs:18:21: 18:22
10-
let _5: i32; // in scope 0 at $DIR/simplify-arm.rs:19:13: 19:14
11-
let mut _6: i32; // in scope 0 at $DIR/simplify-arm.rs:19:23: 19:24
5+
debug r => _1; // in scope 0 at $DIR/simplify_arm.rs:14:14: 14:15
6+
let mut _0: std::result::Result<u8, i32>; // return place in scope 0 at $DIR/simplify_arm.rs:14:37: 14:52
7+
let mut _2: isize; // in scope 0 at $DIR/simplify_arm.rs:16:9: 16:14
128
scope 1 {
13-
debug x => ((_0 as Ok).0: u8); // in scope 1 at $DIR/simplify-arm.rs:18:12: 18:13
9+
debug x => ((_0 as Ok).0: u8); // in scope 1 at $DIR/simplify_arm.rs:16:12: 16:13
1410
}
1511
scope 2 {
16-
debug y => ((_0 as Err).0: i32); // in scope 2 at $DIR/simplify-arm.rs:19:13: 19:14
12+
debug y => ((_0 as Err).0: i32); // in scope 2 at $DIR/simplify_arm.rs:17:13: 17:14
1713
}
1814

1915
bb0: {
20-
_2 = discriminant(_1); // scope 0 at $DIR/simplify-arm.rs:17:11: 17:12
21-
- switchInt(move _2) -> [0_isize: bb3, 1_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify-arm.rs:17:5: 17:12
22-
+ goto -> bb1; // scope 0 at $DIR/simplify-arm.rs:17:5: 17:12
16+
_2 = discriminant(_1); // scope 0 at $DIR/simplify_arm.rs:15:11: 15:12
17+
- switchInt(move _2) -> [0_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/simplify_arm.rs:15:5: 15:12
18+
+ goto -> bb1; // scope 0 at $DIR/simplify_arm.rs:15:5: 15:12
2319
}
2420

2521
bb1: {
26-
- _0 = move _1; // scope 2 at $DIR/simplify-arm.rs:19:19: 19:25
27-
- goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:19:24: 19:25
22+
- _0 = _1; // scope 2 at $DIR/simplify_arm.rs:17:19: 17:25
23+
- return; // scope 0 at $DIR/simplify_arm.rs:17:24: 17:25
2824
- }
2925
-
3026
- bb2: {
31-
- unreachable; // scope 0 at $DIR/simplify-arm.rs:17:11: 17:12
32-
- }
33-
-
34-
- bb3: {
35-
_0 = move _1; // scope 1 at $DIR/simplify-arm.rs:18:18: 18:23
36-
- goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:18:22: 18:23
37-
+ goto -> bb2; // scope 0 at $DIR/simplify-arm.rs:18:22: 18:23
38-
}
39-
40-
- bb4: {
41-
+ bb2: {
42-
return; // scope 0 at $DIR/simplify-arm.rs:21:2: 21:2
27+
_0 = _1; // scope 1 at $DIR/simplify_arm.rs:16:18: 16:23
28+
return; // scope 0 at $DIR/simplify_arm.rs:16:22: 16:23
4329
}
4430
}
4531

0 commit comments

Comments
 (0)