Skip to content

Commit 248a530

Browse files
committedMar 5, 2023
Move SROA tests.
·
1.88.01.70.0
1 parent 0fbfc3e commit 248a530

19 files changed

+469
-469
lines changed
 

‎tests/mir-opt/sroa.constant.ScalarReplacementOfAggregates.diff

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

‎tests/mir-opt/sroa.copies.ScalarReplacementOfAggregates.diff

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

‎tests/mir-opt/sroa.dropping.ScalarReplacementOfAggregates.diff

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

‎tests/mir-opt/sroa.enums.ScalarReplacementOfAggregates.diff

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

‎tests/mir-opt/sroa.escaping.ScalarReplacementOfAggregates.diff

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

‎tests/mir-opt/sroa.flat.ScalarReplacementOfAggregates.diff

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

‎tests/mir-opt/sroa.ref_copies.ScalarReplacementOfAggregates.diff

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

‎tests/mir-opt/sroa.structs.ScalarReplacementOfAggregates.diff

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

‎tests/mir-opt/sroa.unions.ScalarReplacementOfAggregates.diff

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
- // MIR for `constant` before ScalarReplacementOfAggregates
2+
+ // MIR for `constant` after ScalarReplacementOfAggregates
3+
4+
fn constant() -> () {
5+
let mut _0: (); // return place in scope 0 at $DIR/structs.rs:+0:15: +0:15
6+
let _1: (usize, u8); // in scope 0 at $DIR/structs.rs:+2:9: +2:10
7+
+ let _4: usize; // in scope 0 at $DIR/structs.rs:+2:9: +2:10
8+
+ let _5: u8; // in scope 0 at $DIR/structs.rs:+2:9: +2:10
9+
scope 1 {
10+
- debug y => _1; // in scope 1 at $DIR/structs.rs:+2:9: +2:10
11+
+ debug y => (usize, u8){ .0 => _4, .1 => _5, }; // in scope 1 at $DIR/structs.rs:+2:9: +2:10
12+
let _2: usize; // in scope 1 at $DIR/structs.rs:+3:9: +3:10
13+
scope 2 {
14+
debug t => _2; // in scope 2 at $DIR/structs.rs:+3:9: +3:10
15+
let _3: u8; // in scope 2 at $DIR/structs.rs:+4:9: +4:10
16+
scope 3 {
17+
debug u => _3; // in scope 3 at $DIR/structs.rs:+4:9: +4:10
18+
}
19+
}
20+
}
21+
22+
bb0: {
23+
- StorageLive(_1); // scope 0 at $DIR/structs.rs:+2:9: +2:10
24+
+ StorageLive(_4); // scope 0 at $DIR/structs.rs:+2:9: +2:10
25+
+ StorageLive(_5); // scope 0 at $DIR/structs.rs:+2:9: +2:10
26+
+ nop; // scope 0 at $DIR/structs.rs:+2:9: +2:10
27+
_1 = const _; // scope 0 at $DIR/structs.rs:+2:13: +2:14
28+
+ _4 = move (_1.0: usize); // scope 1 at $DIR/structs.rs:+3:9: +3:10
29+
+ _5 = move (_1.1: u8); // scope 1 at $DIR/structs.rs:+3:9: +3:10
30+
StorageLive(_2); // scope 1 at $DIR/structs.rs:+3:9: +3:10
31+
- _2 = (_1.0: usize); // scope 1 at $DIR/structs.rs:+3:13: +3:16
32+
+ _2 = _4; // scope 1 at $DIR/structs.rs:+3:13: +3:16
33+
StorageLive(_3); // scope 2 at $DIR/structs.rs:+4:9: +4:10
34+
- _3 = (_1.1: u8); // scope 2 at $DIR/structs.rs:+4:13: +4:16
35+
+ _3 = _5; // scope 2 at $DIR/structs.rs:+4:13: +4:16
36+
_0 = const (); // scope 0 at $DIR/structs.rs:+0:15: +5:2
37+
StorageDead(_3); // scope 2 at $DIR/structs.rs:+5:1: +5:2
38+
StorageDead(_2); // scope 1 at $DIR/structs.rs:+5:1: +5:2
39+
- StorageDead(_1); // scope 0 at $DIR/structs.rs:+5:1: +5:2
40+
+ StorageDead(_4); // scope 0 at $DIR/structs.rs:+5:1: +5:2
41+
+ StorageDead(_5); // scope 0 at $DIR/structs.rs:+5:1: +5:2
42+
+ nop; // scope 0 at $DIR/structs.rs:+5:1: +5:2
43+
return; // scope 0 at $DIR/structs.rs:+5:2: +5:2
44+
}
45+
}
46+
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
- // MIR for `copies` before ScalarReplacementOfAggregates
2+
+ // MIR for `copies` after ScalarReplacementOfAggregates
3+
4+
fn copies(_1: Foo) -> () {
5+
debug x => _1; // in scope 0 at $DIR/structs.rs:+0:11: +0:12
6+
let mut _0: (); // return place in scope 0 at $DIR/structs.rs:+0:19: +0:19
7+
let _2: Foo; // in scope 0 at $DIR/structs.rs:+1:9: +1:10
8+
+ let _11: u8; // in scope 0 at $DIR/structs.rs:+1:9: +1:10
9+
+ let _12: (); // in scope 0 at $DIR/structs.rs:+1:9: +1:10
10+
+ let _13: &str; // in scope 0 at $DIR/structs.rs:+1:9: +1:10
11+
+ let _14: std::option::Option<isize>; // in scope 0 at $DIR/structs.rs:+1:9: +1:10
12+
scope 1 {
13+
- debug y => _2; // in scope 1 at $DIR/structs.rs:+1:9: +1:10
14+
+ debug y => Foo{ .0 => _11, .1 => _12, .2 => _13, .3 => _14, }; // in scope 1 at $DIR/structs.rs:+1:9: +1:10
15+
let _3: u8; // in scope 1 at $DIR/structs.rs:+2:9: +2:10
16+
scope 2 {
17+
debug t => _3; // in scope 2 at $DIR/structs.rs:+2:9: +2:10
18+
let _4: &str; // in scope 2 at $DIR/structs.rs:+3:9: +3:10
19+
scope 3 {
20+
debug u => _4; // in scope 3 at $DIR/structs.rs:+3:9: +3:10
21+
let _5: Foo; // in scope 3 at $DIR/structs.rs:+4:9: +4:10
22+
+ let _7: u8; // in scope 3 at $DIR/structs.rs:+4:9: +4:10
23+
+ let _8: (); // in scope 3 at $DIR/structs.rs:+4:9: +4:10
24+
+ let _9: &str; // in scope 3 at $DIR/structs.rs:+4:9: +4:10
25+
+ let _10: std::option::Option<isize>; // in scope 3 at $DIR/structs.rs:+4:9: +4:10
26+
scope 4 {
27+
- debug z => _5; // in scope 4 at $DIR/structs.rs:+4:9: +4:10
28+
+ debug z => Foo{ .0 => _7, .1 => _8, .2 => _9, .3 => _10, }; // in scope 4 at $DIR/structs.rs:+4:9: +4:10
29+
let _6: (); // in scope 4 at $DIR/structs.rs:+5:9: +5:10
30+
scope 5 {
31+
debug a => _6; // in scope 5 at $DIR/structs.rs:+5:9: +5:10
32+
}
33+
}
34+
}
35+
}
36+
}
37+
38+
bb0: {
39+
- StorageLive(_2); // scope 0 at $DIR/structs.rs:+1:9: +1:10
40+
- _2 = _1; // scope 0 at $DIR/structs.rs:+1:13: +1:14
41+
+ StorageLive(_11); // scope 0 at $DIR/structs.rs:+1:9: +1:10
42+
+ StorageLive(_12); // scope 0 at $DIR/structs.rs:+1:9: +1:10
43+
+ StorageLive(_13); // scope 0 at $DIR/structs.rs:+1:9: +1:10
44+
+ StorageLive(_14); // scope 0 at $DIR/structs.rs:+1:9: +1:10
45+
+ nop; // scope 0 at $DIR/structs.rs:+1:9: +1:10
46+
+ _11 = (_1.0: u8); // scope 0 at $DIR/structs.rs:+1:13: +1:14
47+
+ _12 = (_1.1: ()); // scope 0 at $DIR/structs.rs:+1:13: +1:14
48+
+ _13 = (_1.2: &str); // scope 0 at $DIR/structs.rs:+1:13: +1:14
49+
+ _14 = (_1.3: std::option::Option<isize>); // scope 0 at $DIR/structs.rs:+1:13: +1:14
50+
+ nop; // scope 0 at $DIR/structs.rs:+1:13: +1:14
51+
StorageLive(_3); // scope 1 at $DIR/structs.rs:+2:9: +2:10
52+
- _3 = (_2.0: u8); // scope 1 at $DIR/structs.rs:+2:13: +2:16
53+
+ _3 = _11; // scope 1 at $DIR/structs.rs:+2:13: +2:16
54+
StorageLive(_4); // scope 2 at $DIR/structs.rs:+3:9: +3:10
55+
- _4 = (_2.2: &str); // scope 2 at $DIR/structs.rs:+3:13: +3:16
56+
- StorageLive(_5); // scope 3 at $DIR/structs.rs:+4:9: +4:10
57+
- _5 = _2; // scope 3 at $DIR/structs.rs:+4:13: +4:14
58+
+ _4 = _13; // scope 2 at $DIR/structs.rs:+3:13: +3:16
59+
+ StorageLive(_7); // scope 3 at $DIR/structs.rs:+4:9: +4:10
60+
+ StorageLive(_8); // scope 3 at $DIR/structs.rs:+4:9: +4:10
61+
+ StorageLive(_9); // scope 3 at $DIR/structs.rs:+4:9: +4:10
62+
+ StorageLive(_10); // scope 3 at $DIR/structs.rs:+4:9: +4:10
63+
+ nop; // scope 3 at $DIR/structs.rs:+4:9: +4:10
64+
+ _7 = _11; // scope 3 at $DIR/structs.rs:+4:13: +4:14
65+
+ _8 = _12; // scope 3 at $DIR/structs.rs:+4:13: +4:14
66+
+ _9 = _13; // scope 3 at $DIR/structs.rs:+4:13: +4:14
67+
+ _10 = _14; // scope 3 at $DIR/structs.rs:+4:13: +4:14
68+
+ nop; // scope 3 at $DIR/structs.rs:+4:13: +4:14
69+
StorageLive(_6); // scope 4 at $DIR/structs.rs:+5:9: +5:10
70+
- _6 = (_5.1: ()); // scope 4 at $DIR/structs.rs:+5:13: +5:16
71+
+ _6 = _8; // scope 4 at $DIR/structs.rs:+5:13: +5:16
72+
_0 = const (); // scope 0 at $DIR/structs.rs:+0:19: +6:2
73+
StorageDead(_6); // scope 4 at $DIR/structs.rs:+6:1: +6:2
74+
- StorageDead(_5); // scope 3 at $DIR/structs.rs:+6:1: +6:2
75+
+ StorageDead(_7); // scope 3 at $DIR/structs.rs:+6:1: +6:2
76+
+ StorageDead(_8); // scope 3 at $DIR/structs.rs:+6:1: +6:2
77+
+ StorageDead(_9); // scope 3 at $DIR/structs.rs:+6:1: +6:2
78+
+ StorageDead(_10); // scope 3 at $DIR/structs.rs:+6:1: +6:2
79+
+ nop; // scope 3 at $DIR/structs.rs:+6:1: +6:2
80+
StorageDead(_4); // scope 2 at $DIR/structs.rs:+6:1: +6:2
81+
StorageDead(_3); // scope 1 at $DIR/structs.rs:+6:1: +6:2
82+
- StorageDead(_2); // scope 0 at $DIR/structs.rs:+6:1: +6:2
83+
+ StorageDead(_11); // scope 0 at $DIR/structs.rs:+6:1: +6:2
84+
+ StorageDead(_12); // scope 0 at $DIR/structs.rs:+6:1: +6:2
85+
+ StorageDead(_13); // scope 0 at $DIR/structs.rs:+6:1: +6:2
86+
+ StorageDead(_14); // scope 0 at $DIR/structs.rs:+6:1: +6:2
87+
+ nop; // scope 0 at $DIR/structs.rs:+6:1: +6:2
88+
return; // scope 0 at $DIR/structs.rs:+6:2: +6:2
89+
}
90+
}
91+
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
- // MIR for `dropping` before ScalarReplacementOfAggregates
2+
+ // MIR for `dropping` after ScalarReplacementOfAggregates
3+
4+
fn dropping() -> () {
5+
let mut _0: (); // return place in scope 0 at $DIR/structs.rs:+0:19: +0:19
6+
let _1: Tag; // in scope 0 at $DIR/structs.rs:+1:5: +1:32
7+
let mut _2: S; // in scope 0 at $DIR/structs.rs:+1:5: +1:30
8+
let mut _3: Tag; // in scope 0 at $DIR/structs.rs:+1:7: +1:13
9+
let mut _4: Tag; // in scope 0 at $DIR/structs.rs:+1:15: +1:21
10+
let mut _5: Tag; // in scope 0 at $DIR/structs.rs:+1:23: +1:29
11+
12+
bb0: {
13+
StorageLive(_1); // scope 0 at $DIR/structs.rs:+1:5: +1:32
14+
StorageLive(_2); // scope 0 at $DIR/structs.rs:+1:5: +1:30
15+
StorageLive(_3); // scope 0 at $DIR/structs.rs:+1:7: +1:13
16+
_3 = Tag(const 0_usize); // scope 0 at $DIR/structs.rs:+1:7: +1:13
17+
StorageLive(_4); // scope 0 at $DIR/structs.rs:+1:15: +1:21
18+
_4 = Tag(const 1_usize); // scope 0 at $DIR/structs.rs:+1:15: +1:21
19+
StorageLive(_5); // scope 0 at $DIR/structs.rs:+1:23: +1:29
20+
_5 = Tag(const 2_usize); // scope 0 at $DIR/structs.rs:+1:23: +1:29
21+
_2 = S(move _3, move _4, move _5); // scope 0 at $DIR/structs.rs:+1:5: +1:30
22+
StorageDead(_5); // scope 0 at $DIR/structs.rs:+1:29: +1:30
23+
StorageDead(_4); // scope 0 at $DIR/structs.rs:+1:29: +1:30
24+
StorageDead(_3); // scope 0 at $DIR/structs.rs:+1:29: +1:30
25+
_1 = move (_2.1: Tag); // scope 0 at $DIR/structs.rs:+1:5: +1:32
26+
drop(_1) -> bb1; // scope 0 at $DIR/structs.rs:+1:32: +1:33
27+
}
28+
29+
bb1: {
30+
drop((_2.0: Tag)) -> bb3; // scope 0 at $DIR/structs.rs:+1:32: +1:33
31+
}
32+
33+
bb2: {
34+
StorageDead(_2); // scope 0 at $DIR/structs.rs:+1:32: +1:33
35+
StorageDead(_1); // scope 0 at $DIR/structs.rs:+1:32: +1:33
36+
_0 = const (); // scope 0 at $DIR/structs.rs:+0:19: +2:2
37+
return; // scope 0 at $DIR/structs.rs:+2:2: +2:2
38+
}
39+
40+
bb3: {
41+
drop((_2.2: Tag)) -> bb2; // scope 0 at $DIR/structs.rs:+1:32: +1:33
42+
}
43+
}
44+
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
- // MIR for `enums` before ScalarReplacementOfAggregates
2+
+ // MIR for `enums` after ScalarReplacementOfAggregates
3+
4+
fn enums(_1: usize) -> usize {
5+
debug a => _1; // in scope 0 at $DIR/structs.rs:+0:14: +0:15
6+
let mut _0: usize; // return place in scope 0 at $DIR/structs.rs:+0:27: +0:32
7+
let mut _2: std::option::Option<usize>; // in scope 0 at $DIR/structs.rs:+1:22: +1:29
8+
let mut _3: usize; // in scope 0 at $DIR/structs.rs:+1:27: +1:28
9+
let mut _4: isize; // in scope 0 at $DIR/structs.rs:+1:12: +1:19
10+
scope 1 {
11+
debug a => _5; // in scope 1 at $DIR/structs.rs:+1:17: +1:18
12+
let _5: usize; // in scope 1 at $DIR/structs.rs:+1:17: +1:18
13+
}
14+
15+
bb0: {
16+
StorageLive(_2); // scope 1 at $DIR/structs.rs:+1:22: +1:29
17+
StorageLive(_3); // scope 1 at $DIR/structs.rs:+1:27: +1:28
18+
_3 = _1; // scope 1 at $DIR/structs.rs:+1:27: +1:28
19+
_2 = Option::<usize>::Some(move _3); // scope 1 at $DIR/structs.rs:+1:22: +1:29
20+
StorageDead(_3); // scope 1 at $DIR/structs.rs:+1:28: +1:29
21+
_4 = discriminant(_2); // scope 1 at $DIR/structs.rs:+1:12: +1:19
22+
switchInt(move _4) -> [1: bb1, otherwise: bb2]; // scope 1 at $DIR/structs.rs:+1:12: +1:19
23+
}
24+
25+
bb1: {
26+
StorageLive(_5); // scope 1 at $DIR/structs.rs:+1:17: +1:18
27+
_5 = ((_2 as Some).0: usize); // scope 1 at $DIR/structs.rs:+1:17: +1:18
28+
_0 = _5; // scope 1 at $DIR/structs.rs:+1:32: +1:33
29+
StorageDead(_5); // scope 0 at $DIR/structs.rs:+1:34: +1:35
30+
goto -> bb3; // scope 0 at $DIR/structs.rs:+1:5: +1:46
31+
}
32+
33+
bb2: {
34+
_0 = const 0_usize; // scope 0 at $DIR/structs.rs:+1:43: +1:44
35+
goto -> bb3; // scope 0 at $DIR/structs.rs:+1:5: +1:46
36+
}
37+
38+
bb3: {
39+
StorageDead(_2); // scope 0 at $DIR/structs.rs:+2:1: +2:2
40+
return; // scope 0 at $DIR/structs.rs:+2:2: +2:2
41+
}
42+
}
43+
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
- // MIR for `escaping` before ScalarReplacementOfAggregates
2+
+ // MIR for `escaping` after ScalarReplacementOfAggregates
3+
4+
fn escaping() -> () {
5+
let mut _0: (); // return place in scope 0 at $DIR/structs.rs:+0:19: +0:19
6+
let _1: (); // in scope 0 at $DIR/structs.rs:+1:5: +1:42
7+
let mut _2: *const u32; // in scope 0 at $DIR/structs.rs:+1:7: +1:41
8+
let _3: &u32; // in scope 0 at $DIR/structs.rs:+1:7: +1:41
9+
let _4: Escaping; // in scope 0 at $DIR/structs.rs:+1:8: +1:39
10+
let mut _5: u32; // in scope 0 at $DIR/structs.rs:+1:34: +1:37
11+
12+
bb0: {
13+
StorageLive(_1); // scope 0 at $DIR/structs.rs:+1:5: +1:42
14+
StorageLive(_2); // scope 0 at $DIR/structs.rs:+1:7: +1:41
15+
StorageLive(_3); // scope 0 at $DIR/structs.rs:+1:7: +1:41
16+
StorageLive(_4); // scope 0 at $DIR/structs.rs:+1:8: +1:39
17+
StorageLive(_5); // scope 0 at $DIR/structs.rs:+1:34: +1:37
18+
_5 = g() -> bb1; // scope 0 at $DIR/structs.rs:+1:34: +1:37
19+
// mir::Constant
20+
// + span: $DIR/structs.rs:78:34: 78:35
21+
// + literal: Const { ty: fn() -> u32 {g}, val: Value(<ZST>) }
22+
}
23+
24+
bb1: {
25+
_4 = Escaping { a: const 1_u32, b: const 2_u32, c: move _5 }; // scope 0 at $DIR/structs.rs:+1:8: +1:39
26+
StorageDead(_5); // scope 0 at $DIR/structs.rs:+1:38: +1:39
27+
_3 = &(_4.0: u32); // scope 0 at $DIR/structs.rs:+1:7: +1:41
28+
_2 = &raw const (*_3); // scope 0 at $DIR/structs.rs:+1:7: +1:41
29+
_1 = f(move _2) -> bb2; // scope 0 at $DIR/structs.rs:+1:5: +1:42
30+
// mir::Constant
31+
// + span: $DIR/structs.rs:78:5: 78:6
32+
// + literal: Const { ty: fn(*const u32) {f}, val: Value(<ZST>) }
33+
}
34+
35+
bb2: {
36+
StorageDead(_2); // scope 0 at $DIR/structs.rs:+1:41: +1:42
37+
StorageDead(_4); // scope 0 at $DIR/structs.rs:+1:42: +1:43
38+
StorageDead(_3); // scope 0 at $DIR/structs.rs:+1:42: +1:43
39+
StorageDead(_1); // scope 0 at $DIR/structs.rs:+1:42: +1:43
40+
_0 = const (); // scope 0 at $DIR/structs.rs:+0:19: +2:2
41+
return; // scope 0 at $DIR/structs.rs:+2:2: +2:2
42+
}
43+
}
44+
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
- // MIR for `flat` before ScalarReplacementOfAggregates
2+
+ // MIR for `flat` after ScalarReplacementOfAggregates
3+
4+
fn flat() -> () {
5+
let mut _0: (); // return place in scope 0 at $DIR/structs.rs:+0:15: +0:15
6+
let _1: u8; // in scope 0 at $DIR/structs.rs:+1:15: +1:16
7+
let _2: (); // in scope 0 at $DIR/structs.rs:+1:18: +1:19
8+
let _3: &str; // in scope 0 at $DIR/structs.rs:+1:21: +1:22
9+
let _4: std::option::Option<isize>; // in scope 0 at $DIR/structs.rs:+1:24: +1:25
10+
let mut _5: Foo; // in scope 0 at $DIR/structs.rs:+1:30: +1:70
11+
let mut _6: (); // in scope 0 at $DIR/structs.rs:+1:45: +1:47
12+
let mut _7: std::option::Option<isize>; // in scope 0 at $DIR/structs.rs:+1:60: +1:68
13+
+ let mut _8: u8; // in scope 0 at $DIR/structs.rs:+1:30: +1:70
14+
+ let mut _9: (); // in scope 0 at $DIR/structs.rs:+1:30: +1:70
15+
+ let mut _10: &str; // in scope 0 at $DIR/structs.rs:+1:30: +1:70
16+
+ let mut _11: std::option::Option<isize>; // in scope 0 at $DIR/structs.rs:+1:30: +1:70
17+
scope 1 {
18+
debug a => _1; // in scope 1 at $DIR/structs.rs:+1:15: +1:16
19+
debug b => _2; // in scope 1 at $DIR/structs.rs:+1:18: +1:19
20+
debug c => _3; // in scope 1 at $DIR/structs.rs:+1:21: +1:22
21+
debug d => _4; // in scope 1 at $DIR/structs.rs:+1:24: +1:25
22+
scope 2 {
23+
scope 3 {
24+
scope 4 {
25+
scope 5 {
26+
}
27+
}
28+
}
29+
}
30+
}
31+
32+
bb0: {
33+
- StorageLive(_5); // scope 0 at $DIR/structs.rs:+1:30: +1:70
34+
+ StorageLive(_8); // scope 0 at $DIR/structs.rs:+1:30: +1:70
35+
+ StorageLive(_9); // scope 0 at $DIR/structs.rs:+1:30: +1:70
36+
+ StorageLive(_10); // scope 0 at $DIR/structs.rs:+1:30: +1:70
37+
+ StorageLive(_11); // scope 0 at $DIR/structs.rs:+1:30: +1:70
38+
+ nop; // scope 0 at $DIR/structs.rs:+1:30: +1:70
39+
StorageLive(_6); // scope 0 at $DIR/structs.rs:+1:45: +1:47
40+
_6 = (); // scope 0 at $DIR/structs.rs:+1:45: +1:47
41+
StorageLive(_7); // scope 0 at $DIR/structs.rs:+1:60: +1:68
42+
_7 = Option::<isize>::Some(const -4_isize); // scope 0 at $DIR/structs.rs:+1:60: +1:68
43+
- _5 = Foo { a: const 5_u8, b: move _6, c: const "a", d: move _7 }; // scope 0 at $DIR/structs.rs:+1:30: +1:70
44+
+ _8 = const 5_u8; // scope 0 at $DIR/structs.rs:+1:30: +1:70
45+
+ _9 = move _6; // scope 0 at $DIR/structs.rs:+1:30: +1:70
46+
+ _10 = const "a"; // scope 0 at $DIR/structs.rs:+1:30: +1:70
47+
// mir::Constant
48+
// + span: $DIR/structs.rs:53:52: 53:55
49+
// + literal: Const { ty: &str, val: Value(Slice(..)) }
50+
+ _11 = move _7; // scope 0 at $DIR/structs.rs:+1:30: +1:70
51+
+ nop; // scope 0 at $DIR/structs.rs:+1:30: +1:70
52+
StorageDead(_7); // scope 0 at $DIR/structs.rs:+1:69: +1:70
53+
StorageDead(_6); // scope 0 at $DIR/structs.rs:+1:69: +1:70
54+
StorageLive(_1); // scope 0 at $DIR/structs.rs:+1:15: +1:16
55+
- _1 = (_5.0: u8); // scope 0 at $DIR/structs.rs:+1:15: +1:16
56+
+ _1 = _8; // scope 0 at $DIR/structs.rs:+1:15: +1:16
57+
StorageLive(_2); // scope 0 at $DIR/structs.rs:+1:18: +1:19
58+
- _2 = (_5.1: ()); // scope 0 at $DIR/structs.rs:+1:18: +1:19
59+
+ _2 = _9; // scope 0 at $DIR/structs.rs:+1:18: +1:19
60+
StorageLive(_3); // scope 0 at $DIR/structs.rs:+1:21: +1:22
61+
- _3 = (_5.2: &str); // scope 0 at $DIR/structs.rs:+1:21: +1:22
62+
+ _3 = _10; // scope 0 at $DIR/structs.rs:+1:21: +1:22
63+
StorageLive(_4); // scope 0 at $DIR/structs.rs:+1:24: +1:25
64+
- _4 = (_5.3: std::option::Option<isize>); // scope 0 at $DIR/structs.rs:+1:24: +1:25
65+
- StorageDead(_5); // scope 0 at $DIR/structs.rs:+1:70: +1:71
66+
+ _4 = _11; // scope 0 at $DIR/structs.rs:+1:24: +1:25
67+
+ StorageDead(_8); // scope 0 at $DIR/structs.rs:+1:70: +1:71
68+
+ StorageDead(_9); // scope 0 at $DIR/structs.rs:+1:70: +1:71
69+
+ StorageDead(_10); // scope 0 at $DIR/structs.rs:+1:70: +1:71
70+
+ StorageDead(_11); // scope 0 at $DIR/structs.rs:+1:70: +1:71
71+
+ nop; // scope 0 at $DIR/structs.rs:+1:70: +1:71
72+
_0 = const (); // scope 0 at $DIR/structs.rs:+0:15: +6:2
73+
StorageDead(_4); // scope 0 at $DIR/structs.rs:+6:1: +6:2
74+
StorageDead(_3); // scope 0 at $DIR/structs.rs:+6:1: +6:2
75+
StorageDead(_2); // scope 0 at $DIR/structs.rs:+6:1: +6:2
76+
StorageDead(_1); // scope 0 at $DIR/structs.rs:+6:1: +6:2
77+
return; // scope 0 at $DIR/structs.rs:+6:2: +6:2
78+
}
79+
}
80+
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
- // MIR for `ref_copies` before ScalarReplacementOfAggregates
2+
+ // MIR for `ref_copies` after ScalarReplacementOfAggregates
3+
4+
fn ref_copies(_1: &Foo) -> () {
5+
debug x => _1; // in scope 0 at $DIR/structs.rs:+0:15: +0:16
6+
let mut _0: (); // return place in scope 0 at $DIR/structs.rs:+0:24: +0:24
7+
let _2: Foo; // in scope 0 at $DIR/structs.rs:+1:9: +1:10
8+
+ let _5: u8; // in scope 0 at $DIR/structs.rs:+1:9: +1:10
9+
+ let _6: (); // in scope 0 at $DIR/structs.rs:+1:9: +1:10
10+
+ let _7: &str; // in scope 0 at $DIR/structs.rs:+1:9: +1:10
11+
+ let _8: std::option::Option<isize>; // in scope 0 at $DIR/structs.rs:+1:9: +1:10
12+
scope 1 {
13+
- debug y => _2; // in scope 1 at $DIR/structs.rs:+1:9: +1:10
14+
+ debug y => Foo{ .0 => _5, .1 => _6, .2 => _7, .3 => _8, }; // in scope 1 at $DIR/structs.rs:+1:9: +1:10
15+
let _3: u8; // in scope 1 at $DIR/structs.rs:+2:9: +2:10
16+
scope 2 {
17+
debug t => _3; // in scope 2 at $DIR/structs.rs:+2:9: +2:10
18+
let _4: &str; // in scope 2 at $DIR/structs.rs:+3:9: +3:10
19+
scope 3 {
20+
debug u => _4; // in scope 3 at $DIR/structs.rs:+3:9: +3:10
21+
}
22+
}
23+
}
24+
25+
bb0: {
26+
- StorageLive(_2); // scope 0 at $DIR/structs.rs:+1:9: +1:10
27+
- _2 = (*_1); // scope 0 at $DIR/structs.rs:+1:13: +1:15
28+
+ StorageLive(_5); // scope 0 at $DIR/structs.rs:+1:9: +1:10
29+
+ StorageLive(_6); // scope 0 at $DIR/structs.rs:+1:9: +1:10
30+
+ StorageLive(_7); // scope 0 at $DIR/structs.rs:+1:9: +1:10
31+
+ StorageLive(_8); // scope 0 at $DIR/structs.rs:+1:9: +1:10
32+
+ nop; // scope 0 at $DIR/structs.rs:+1:9: +1:10
33+
+ _5 = ((*_1).0: u8); // scope 0 at $DIR/structs.rs:+1:13: +1:15
34+
+ _6 = ((*_1).1: ()); // scope 0 at $DIR/structs.rs:+1:13: +1:15
35+
+ _7 = ((*_1).2: &str); // scope 0 at $DIR/structs.rs:+1:13: +1:15
36+
+ _8 = ((*_1).3: std::option::Option<isize>); // scope 0 at $DIR/structs.rs:+1:13: +1:15
37+
+ nop; // scope 0 at $DIR/structs.rs:+1:13: +1:15
38+
StorageLive(_3); // scope 1 at $DIR/structs.rs:+2:9: +2:10
39+
- _3 = (_2.0: u8); // scope 1 at $DIR/structs.rs:+2:13: +2:16
40+
+ _3 = _5; // scope 1 at $DIR/structs.rs:+2:13: +2:16
41+
StorageLive(_4); // scope 2 at $DIR/structs.rs:+3:9: +3:10
42+
- _4 = (_2.2: &str); // scope 2 at $DIR/structs.rs:+3:13: +3:16
43+
+ _4 = _7; // scope 2 at $DIR/structs.rs:+3:13: +3:16
44+
_0 = const (); // scope 0 at $DIR/structs.rs:+0:24: +4:2
45+
StorageDead(_4); // scope 2 at $DIR/structs.rs:+4:1: +4:2
46+
StorageDead(_3); // scope 1 at $DIR/structs.rs:+4:1: +4:2
47+
- StorageDead(_2); // scope 0 at $DIR/structs.rs:+4:1: +4:2
48+
+ StorageDead(_5); // scope 0 at $DIR/structs.rs:+4:1: +4:2
49+
+ StorageDead(_6); // scope 0 at $DIR/structs.rs:+4:1: +4:2
50+
+ StorageDead(_7); // scope 0 at $DIR/structs.rs:+4:1: +4:2
51+
+ StorageDead(_8); // scope 0 at $DIR/structs.rs:+4:1: +4:2
52+
+ nop; // scope 0 at $DIR/structs.rs:+4:1: +4:2
53+
return; // scope 0 at $DIR/structs.rs:+4:2: +4:2
54+
}
55+
}
56+

‎tests/mir-opt/sroa.rs renamed to ‎tests/mir-opt/sroa/structs.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,12 @@ fn main() {
111111
constant();
112112
}
113113

114-
// EMIT_MIR sroa.dropping.ScalarReplacementOfAggregates.diff
115-
// EMIT_MIR sroa.enums.ScalarReplacementOfAggregates.diff
116-
// EMIT_MIR sroa.structs.ScalarReplacementOfAggregates.diff
117-
// EMIT_MIR sroa.unions.ScalarReplacementOfAggregates.diff
118-
// EMIT_MIR sroa.flat.ScalarReplacementOfAggregates.diff
119-
// EMIT_MIR sroa.escaping.ScalarReplacementOfAggregates.diff
120-
// EMIT_MIR sroa.copies.ScalarReplacementOfAggregates.diff
121-
// EMIT_MIR sroa.ref_copies.ScalarReplacementOfAggregates.diff
122-
// EMIT_MIR sroa.constant.ScalarReplacementOfAggregates.diff
114+
// EMIT_MIR structs.dropping.ScalarReplacementOfAggregates.diff
115+
// EMIT_MIR structs.enums.ScalarReplacementOfAggregates.diff
116+
// EMIT_MIR structs.structs.ScalarReplacementOfAggregates.diff
117+
// EMIT_MIR structs.unions.ScalarReplacementOfAggregates.diff
118+
// EMIT_MIR structs.flat.ScalarReplacementOfAggregates.diff
119+
// EMIT_MIR structs.escaping.ScalarReplacementOfAggregates.diff
120+
// EMIT_MIR structs.copies.ScalarReplacementOfAggregates.diff
121+
// EMIT_MIR structs.ref_copies.ScalarReplacementOfAggregates.diff
122+
// EMIT_MIR structs.constant.ScalarReplacementOfAggregates.diff
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
- // MIR for `structs` before ScalarReplacementOfAggregates
2+
+ // MIR for `structs` after ScalarReplacementOfAggregates
3+
4+
fn structs(_1: f32) -> f32 {
5+
debug a => _1; // in scope 0 at $DIR/structs.rs:+0:16: +0:17
6+
let mut _0: f32; // return place in scope 0 at $DIR/structs.rs:+0:27: +0:30
7+
let mut _2: structs::U; // in scope 0 at $DIR/structs.rs:+6:5: +6:21
8+
let mut _3: f32; // in scope 0 at $DIR/structs.rs:+6:18: +6:19
9+
+ let mut _4: usize; // in scope 0 at $DIR/structs.rs:+6:5: +6:21
10+
+ let mut _5: f32; // in scope 0 at $DIR/structs.rs:+6:5: +6:21
11+
12+
bb0: {
13+
- StorageLive(_2); // scope 0 at $DIR/structs.rs:+6:5: +6:21
14+
+ StorageLive(_4); // scope 0 at $DIR/structs.rs:+6:5: +6:21
15+
+ StorageLive(_5); // scope 0 at $DIR/structs.rs:+6:5: +6:21
16+
+ nop; // scope 0 at $DIR/structs.rs:+6:5: +6:21
17+
StorageLive(_3); // scope 0 at $DIR/structs.rs:+6:18: +6:19
18+
_3 = _1; // scope 0 at $DIR/structs.rs:+6:18: +6:19
19+
- _2 = U { _foo: const 0_usize, a: move _3 }; // scope 0 at $DIR/structs.rs:+6:5: +6:21
20+
+ _4 = const 0_usize; // scope 0 at $DIR/structs.rs:+6:5: +6:21
21+
+ _5 = move _3; // scope 0 at $DIR/structs.rs:+6:5: +6:21
22+
+ nop; // scope 0 at $DIR/structs.rs:+6:5: +6:21
23+
StorageDead(_3); // scope 0 at $DIR/structs.rs:+6:20: +6:21
24+
- _0 = (_2.1: f32); // scope 0 at $DIR/structs.rs:+6:5: +6:23
25+
- StorageDead(_2); // scope 0 at $DIR/structs.rs:+7:1: +7:2
26+
+ _0 = _5; // scope 0 at $DIR/structs.rs:+6:5: +6:23
27+
+ StorageDead(_4); // scope 0 at $DIR/structs.rs:+7:1: +7:2
28+
+ StorageDead(_5); // scope 0 at $DIR/structs.rs:+7:1: +7:2
29+
+ nop; // scope 0 at $DIR/structs.rs:+7:1: +7:2
30+
return; // scope 0 at $DIR/structs.rs:+7:2: +7:2
31+
}
32+
}
33+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
- // MIR for `unions` before ScalarReplacementOfAggregates
2+
+ // MIR for `unions` after ScalarReplacementOfAggregates
3+
4+
fn unions(_1: f32) -> u32 {
5+
debug a => _1; // in scope 0 at $DIR/structs.rs:+0:15: +0:16
6+
let mut _0: u32; // return place in scope 0 at $DIR/structs.rs:+0:26: +0:29
7+
let mut _2: unions::Repr; // in scope 0 at $DIR/structs.rs:+5:14: +5:27
8+
let mut _3: f32; // in scope 0 at $DIR/structs.rs:+5:24: +5:25
9+
scope 1 {
10+
}
11+
12+
bb0: {
13+
StorageLive(_2); // scope 1 at $DIR/structs.rs:+5:14: +5:27
14+
StorageLive(_3); // scope 1 at $DIR/structs.rs:+5:24: +5:25
15+
_3 = _1; // scope 1 at $DIR/structs.rs:+5:24: +5:25
16+
_2 = Repr { f: move _3 }; // scope 1 at $DIR/structs.rs:+5:14: +5:27
17+
StorageDead(_3); // scope 1 at $DIR/structs.rs:+5:26: +5:27
18+
_0 = (_2.1: u32); // scope 1 at $DIR/structs.rs:+5:14: +5:29
19+
StorageDead(_2); // scope 0 at $DIR/structs.rs:+6:1: +6:2
20+
return; // scope 0 at $DIR/structs.rs:+6:2: +6:2
21+
}
22+
}
23+

0 commit comments

Comments
 (0)
Please sign in to comment.