Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e385ca2

Browse files
authoredFeb 6, 2023
Rollup merge of rust-lang#107687 - cjgillot:sroa-2, r=oli-obk
Adapt SROA MIR opt for aggregated MIR The pass was broken by rust-lang#107267. This PR extends it to replace: ``` x = Struct { 0: a, 1: b } y = move? x ``` by assignment between locals ``` x_0 = a x_1 = b y_0 = move? x_0 y_1 = move? x_1 ``` The improved pass runs to fixpoint, so we can flatten nested field accesses.
2 parents 675976e + 51ef82d commit e385ca2

21 files changed

+589
-313
lines changed
 

‎compiler/rustc_mir_dataflow/src/value_analysis.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ impl<V, T> TryFrom<ProjectionElem<V, T>> for TrackElem {
790790
}
791791

792792
/// Invokes `f` on all direct fields of `ty`.
793-
fn iter_fields<'tcx>(
793+
pub fn iter_fields<'tcx>(
794794
ty: Ty<'tcx>,
795795
tcx: TyCtxt<'tcx>,
796796
mut f: impl FnMut(Option<VariantIdx>, Field, Ty<'tcx>),
@@ -824,7 +824,7 @@ fn iter_fields<'tcx>(
824824
}
825825

826826
/// Returns all locals with projections that have their reference or address taken.
827-
fn excluded_locals(body: &Body<'_>) -> IndexVec<Local, bool> {
827+
pub fn excluded_locals(body: &Body<'_>) -> IndexVec<Local, bool> {
828828
struct Collector {
829829
result: IndexVec<Local, bool>,
830830
}

‎compiler/rustc_mir_transform/src/sroa.rs

Lines changed: 253 additions & 178 deletions
Large diffs are not rendered by default.

‎tests/mir-opt/const_debuginfo.main.ConstDebugInfo.diff

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
let mut _6: u8; // in scope 0 at $DIR/const_debuginfo.rs:+4:15: +4:16
99
let mut _7: u8; // in scope 0 at $DIR/const_debuginfo.rs:+4:19: +4:20
1010
let mut _8: u8; // in scope 0 at $DIR/const_debuginfo.rs:+4:23: +4:24
11-
let mut _14: u32; // in scope 0 at $DIR/const_debuginfo.rs:+13:13: +13:16
12-
let mut _15: u32; // in scope 0 at $DIR/const_debuginfo.rs:+13:19: +13:22
11+
let mut _12: u32; // in scope 0 at $DIR/const_debuginfo.rs:+13:13: +13:16
12+
let mut _13: u32; // in scope 0 at $DIR/const_debuginfo.rs:+13:19: +13:22
1313
scope 1 {
1414
- debug x => _1; // in scope 1 at $DIR/const_debuginfo.rs:+1:9: +1:10
1515
+ debug x => const 1_u8; // in scope 1 at $DIR/const_debuginfo.rs:+1:9: +1:10
@@ -29,18 +29,21 @@
2929
scope 5 {
3030
- debug s => _9; // in scope 5 at $DIR/const_debuginfo.rs:+6:9: +6:10
3131
+ debug s => const "hello, world!"; // in scope 5 at $DIR/const_debuginfo.rs:+6:9: +6:10
32-
let _10: (bool, bool, u32); // in scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10
32+
let _14: bool; // in scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10
33+
let _15: bool; // in scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10
34+
let _16: u32; // in scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10
3335
scope 6 {
34-
debug f => _10; // in scope 6 at $DIR/const_debuginfo.rs:+8:9: +8:10
35-
let _11: std::option::Option<u16>; // in scope 6 at $DIR/const_debuginfo.rs:+10:9: +10:10
36+
debug f => (bool, bool, u32){ .0 => _14, .1 => _15, .2 => _16, }; // in scope 6 at $DIR/const_debuginfo.rs:+8:9: +8:10
37+
let _10: std::option::Option<u16>; // in scope 6 at $DIR/const_debuginfo.rs:+10:9: +10:10
3638
scope 7 {
37-
debug o => _11; // in scope 7 at $DIR/const_debuginfo.rs:+10:9: +10:10
38-
let _12: Point; // in scope 7 at $DIR/const_debuginfo.rs:+12:9: +12:10
39+
debug o => _10; // in scope 7 at $DIR/const_debuginfo.rs:+10:9: +10:10
40+
let _17: u32; // in scope 7 at $DIR/const_debuginfo.rs:+12:9: +12:10
41+
let _18: u32; // in scope 7 at $DIR/const_debuginfo.rs:+12:9: +12:10
3942
scope 8 {
40-
debug p => _12; // in scope 8 at $DIR/const_debuginfo.rs:+12:9: +12:10
41-
let _13: u32; // in scope 8 at $DIR/const_debuginfo.rs:+13:9: +13:10
43+
debug p => Point{ .0 => _17, .1 => _18, }; // in scope 8 at $DIR/const_debuginfo.rs:+12:9: +12:10
44+
let _11: u32; // in scope 8 at $DIR/const_debuginfo.rs:+13:9: +13:10
4245
scope 9 {
43-
- debug a => _13; // in scope 9 at $DIR/const_debuginfo.rs:+13:9: +13:10
46+
- debug a => _11; // in scope 9 at $DIR/const_debuginfo.rs:+13:9: +13:10
4447
+ debug a => const 64_u32; // in scope 9 at $DIR/const_debuginfo.rs:+13:9: +13:10
4548
}
4649
}
@@ -66,24 +69,23 @@
6669
// mir::Constant
6770
// + span: $DIR/const_debuginfo.rs:14:13: 14:28
6871
// + literal: Const { ty: &str, val: Value(Slice(..)) }
69-
StorageLive(_10); // scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10
70-
_10 = (const true, const false, const 123_u32); // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34
71-
StorageLive(_11); // scope 6 at $DIR/const_debuginfo.rs:+10:9: +10:10
72-
_11 = Option::<u16>::Some(const 99_u16); // scope 6 at $DIR/const_debuginfo.rs:+10:13: +10:24
73-
StorageLive(_12); // scope 7 at $DIR/const_debuginfo.rs:+12:9: +12:10
74-
_12 = Point { x: const 32_u32, y: const 32_u32 }; // scope 7 at $DIR/const_debuginfo.rs:+12:13: +12:35
75-
StorageLive(_13); // scope 8 at $DIR/const_debuginfo.rs:+13:9: +13:10
76-
StorageLive(_14); // scope 8 at $DIR/const_debuginfo.rs:+13:13: +13:16
77-
_14 = const 32_u32; // scope 8 at $DIR/const_debuginfo.rs:+13:13: +13:16
78-
StorageLive(_15); // scope 8 at $DIR/const_debuginfo.rs:+13:19: +13:22
79-
_15 = const 32_u32; // scope 8 at $DIR/const_debuginfo.rs:+13:19: +13:22
80-
_13 = const 64_u32; // scope 8 at $DIR/const_debuginfo.rs:+13:13: +13:22
81-
StorageDead(_15); // scope 8 at $DIR/const_debuginfo.rs:+13:21: +13:22
82-
StorageDead(_14); // scope 8 at $DIR/const_debuginfo.rs:+13:21: +13:22
83-
StorageDead(_13); // scope 8 at $DIR/const_debuginfo.rs:+14:1: +14:2
84-
StorageDead(_12); // scope 7 at $DIR/const_debuginfo.rs:+14:1: +14:2
85-
StorageDead(_11); // scope 6 at $DIR/const_debuginfo.rs:+14:1: +14:2
86-
StorageDead(_10); // scope 5 at $DIR/const_debuginfo.rs:+14:1: +14:2
72+
StorageLive(_14); // scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10
73+
StorageLive(_15); // scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10
74+
StorageLive(_16); // scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10
75+
_14 = const true; // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34
76+
_15 = const false; // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34
77+
_16 = const 123_u32; // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34
78+
StorageLive(_10); // scope 6 at $DIR/const_debuginfo.rs:+10:9: +10:10
79+
_10 = Option::<u16>::Some(const 99_u16); // scope 6 at $DIR/const_debuginfo.rs:+10:13: +10:24
80+
_17 = const 32_u32; // scope 7 at $DIR/const_debuginfo.rs:+12:13: +12:35
81+
_18 = const 32_u32; // scope 7 at $DIR/const_debuginfo.rs:+12:13: +12:35
82+
StorageLive(_11); // scope 8 at $DIR/const_debuginfo.rs:+13:9: +13:10
83+
_11 = const 64_u32; // scope 8 at $DIR/const_debuginfo.rs:+13:13: +13:22
84+
StorageDead(_11); // scope 8 at $DIR/const_debuginfo.rs:+14:1: +14:2
85+
StorageDead(_10); // scope 6 at $DIR/const_debuginfo.rs:+14:1: +14:2
86+
StorageDead(_14); // scope 5 at $DIR/const_debuginfo.rs:+14:1: +14:2
87+
StorageDead(_15); // scope 5 at $DIR/const_debuginfo.rs:+14:1: +14:2
88+
StorageDead(_16); // scope 5 at $DIR/const_debuginfo.rs:+14:1: +14:2
8789
StorageDead(_9); // scope 4 at $DIR/const_debuginfo.rs:+14:1: +14:2
8890
StorageDead(_4); // scope 3 at $DIR/const_debuginfo.rs:+14:1: +14:2
8991
return; // scope 0 at $DIR/const_debuginfo.rs:+14:2: +14:2

‎tests/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,27 @@
33

44
fn main() -> () {
55
let mut _0: (); // return place in scope 0 at $DIR/mutable_variable_aggregate.rs:+0:11: +0:11
6-
let mut _1: (i32, i32); // in scope 0 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14
6+
let mut _3: i32; // in scope 0 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14
7+
let mut _4: i32; // in scope 0 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14
78
scope 1 {
8-
debug x => _1; // in scope 1 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14
9-
let _2: (i32, i32); // in scope 1 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10
9+
debug x => (i32, i32){ .0 => _3, .1 => _4, }; // in scope 1 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14
10+
let _1: i32; // in scope 1 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10
11+
let _2: i32; // in scope 1 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10
1012
scope 2 {
11-
debug y => _2; // in scope 2 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10
13+
debug y => (i32, i32){ .0 => _3, .1 => _2, }; // in scope 2 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10
1214
}
1315
}
1416

1517
bb0: {
16-
StorageLive(_1); // scope 0 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14
17-
- _1 = (const 42_i32, const 43_i32); // scope 0 at $DIR/mutable_variable_aggregate.rs:+1:17: +1:25
18-
+ _1 = const (42_i32, 43_i32); // scope 0 at $DIR/mutable_variable_aggregate.rs:+1:17: +1:25
19-
(_1.1: i32) = const 99_i32; // scope 1 at $DIR/mutable_variable_aggregate.rs:+2:5: +2:13
18+
StorageLive(_4); // scope 0 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14
19+
_3 = const 42_i32; // scope 0 at $DIR/mutable_variable_aggregate.rs:+1:17: +1:25
20+
_4 = const 43_i32; // scope 0 at $DIR/mutable_variable_aggregate.rs:+1:17: +1:25
21+
_4 = const 99_i32; // scope 1 at $DIR/mutable_variable_aggregate.rs:+2:5: +2:13
2022
StorageLive(_2); // scope 1 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10
21-
- _2 = _1; // scope 1 at $DIR/mutable_variable_aggregate.rs:+3:13: +3:14
22-
+ _2 = const (42_i32, 99_i32); // scope 1 at $DIR/mutable_variable_aggregate.rs:+3:13: +3:14
23+
- _2 = _4; // scope 1 at $DIR/mutable_variable_aggregate.rs:+3:13: +3:14
24+
+ _2 = const 99_i32; // scope 1 at $DIR/mutable_variable_aggregate.rs:+3:13: +3:14
2325
StorageDead(_2); // scope 1 at $DIR/mutable_variable_aggregate.rs:+4:1: +4:2
24-
StorageDead(_1); // scope 0 at $DIR/mutable_variable_aggregate.rs:+4:1: +4:2
26+
StorageDead(_4); // scope 0 at $DIR/mutable_variable_aggregate.rs:+4:1: +4:2
2527
return; // scope 0 at $DIR/mutable_variable_aggregate.rs:+4:2: +4:2
2628
}
2729
}

‎tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.ConstProp.diff

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
let _2: &mut (i32, i32); // in scope 1 at $DIR/mutable_variable_aggregate_mut_ref.rs:+2:9: +2:10
1010
scope 2 {
1111
debug z => _2; // in scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+2:9: +2:10
12-
let _3: (i32, i32); // in scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10
12+
let _3: i32; // in scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10
13+
let _4: i32; // in scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10
1314
scope 3 {
14-
debug y => _3; // in scope 3 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10
15+
debug y => (i32, i32){ .0 => _3, .1 => _4, }; // in scope 3 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10
1516
}
1617
}
1718
}
@@ -23,8 +24,11 @@
2324
_2 = &mut _1; // scope 1 at $DIR/mutable_variable_aggregate_mut_ref.rs:+2:13: +2:19
2425
((*_2).1: i32) = const 99_i32; // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+3:5: +3:13
2526
StorageLive(_3); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10
26-
_3 = _1; // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:13: +4:14
27+
StorageLive(_4); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10
28+
_3 = (_1.0: i32); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:13: +4:14
29+
_4 = (_1.1: i32); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:13: +4:14
2730
StorageDead(_3); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:1: +5:2
31+
StorageDead(_4); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:1: +5:2
2832
StorageDead(_2); // scope 1 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:1: +5:2
2933
StorageDead(_1); // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:1: +5:2
3034
return; // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:2: +5:2

‎tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@
44
fn main() -> () {
55
let mut _0: (); // return place in scope 0 at $DIR/mutable_variable_unprop_assign.rs:+0:11: +0:11
66
let _1: i32; // in scope 0 at $DIR/mutable_variable_unprop_assign.rs:+1:9: +1:10
7-
let mut _3: i32; // in scope 0 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12
7+
let mut _2: i32; // in scope 0 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12
88
scope 1 {
99
debug a => _1; // in scope 1 at $DIR/mutable_variable_unprop_assign.rs:+1:9: +1:10
10-
let mut _2: (i32, i32); // in scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14
10+
let mut _5: i32; // in scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14
11+
let mut _6: i32; // in scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14
1112
scope 2 {
12-
debug x => _2; // in scope 2 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14
13-
let _4: i32; // in scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10
13+
debug x => (i32, i32){ .0 => _5, .1 => _6, }; // in scope 2 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14
14+
let _3: i32; // in scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10
1415
scope 3 {
15-
debug y => _4; // in scope 3 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10
16-
let _5: i32; // in scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:9: +5:10
16+
debug y => _3; // in scope 3 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10
17+
let _4: i32; // in scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:9: +5:10
1718
scope 4 {
1819
debug z => _5; // in scope 4 at $DIR/mutable_variable_unprop_assign.rs:+5:9: +5:10
1920
}
@@ -30,21 +31,17 @@
3031
}
3132

3233
bb1: {
33-
StorageLive(_2); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14
34-
- _2 = (const 1_i32, const 2_i32); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35
35-
+ _2 = const (1_i32, 2_i32); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35
36-
StorageLive(_3); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12
37-
_3 = _1; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12
38-
(_2.1: i32) = move _3; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:5: +3:12
39-
StorageDead(_3); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12
40-
StorageLive(_4); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10
41-
_4 = (_2.1: i32); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:13: +4:16
42-
StorageLive(_5); // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:9: +5:10
43-
- _5 = (_2.0: i32); // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:13: +5:16
44-
+ _5 = const 1_i32; // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:13: +5:16
45-
StorageDead(_5); // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2
46-
StorageDead(_4); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2
47-
StorageDead(_2); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2
34+
StorageLive(_6); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14
35+
_5 = const 1_i32; // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35
36+
_6 = const 2_i32; // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35
37+
StorageLive(_2); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12
38+
_2 = _1; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12
39+
_6 = move _2; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:5: +3:12
40+
StorageDead(_2); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12
41+
StorageLive(_3); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10
42+
_3 = _6; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:13: +4:16
43+
StorageDead(_3); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2
44+
StorageDead(_6); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2
4845
StorageDead(_1); // scope 0 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2
4946
return; // scope 0 at $DIR/mutable_variable_unprop_assign.rs:+6:2: +6:2
5047
}

‎tests/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.32bit.diff

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
let _5: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:32: +2:33
1010
let mut _6: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
1111
let mut _7: bool; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
12-
let mut _9: Point; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
12+
let mut _9: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
1313
scope 1 {
1414
debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
1515
let _3: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
1616
scope 2 {
1717
debug y => _3; // in scope 2 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
1818
let _8: u32; // in scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
1919
scope 3 {
20-
debug z => _8; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
20+
debug z => _9; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
2121
}
2222
}
2323
}
@@ -50,13 +50,7 @@
5050
+ _3 = const 3_i32; // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
5151
StorageDead(_5); // scope 1 at $DIR/optimizes_into_variable.rs:+2:34: +2:35
5252
StorageDead(_4); // scope 1 at $DIR/optimizes_into_variable.rs:+2:34: +2:35
53-
StorageLive(_8); // scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
54-
StorageLive(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
55-
_9 = Point { x: const 12_u32, y: const 42_u32 }; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
56-
- _8 = (_9.1: u32); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38
57-
+ _8 = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38
58-
StorageDead(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39
59-
StorageDead(_8); // scope 2 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
53+
_9 = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
6054
StorageDead(_3); // scope 1 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
6155
StorageDead(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
6256
return; // scope 0 at $DIR/optimizes_into_variable.rs:+4:2: +4:2

‎tests/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.64bit.diff

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
let _5: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:32: +2:33
1010
let mut _6: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
1111
let mut _7: bool; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
12-
let mut _9: Point; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
12+
let mut _9: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
1313
scope 1 {
1414
debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
1515
let _3: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
1616
scope 2 {
1717
debug y => _3; // in scope 2 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
1818
let _8: u32; // in scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
1919
scope 3 {
20-
debug z => _8; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
20+
debug z => _9; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
2121
}
2222
}
2323
}
@@ -50,13 +50,7 @@
5050
+ _3 = const 3_i32; // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
5151
StorageDead(_5); // scope 1 at $DIR/optimizes_into_variable.rs:+2:34: +2:35
5252
StorageDead(_4); // scope 1 at $DIR/optimizes_into_variable.rs:+2:34: +2:35
53-
StorageLive(_8); // scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
54-
StorageLive(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
55-
_9 = Point { x: const 12_u32, y: const 42_u32 }; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
56-
- _8 = (_9.1: u32); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38
57-
+ _8 = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38
58-
StorageDead(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39
59-
StorageDead(_8); // scope 2 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
53+
_9 = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
6054
StorageDead(_3); // scope 1 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
6155
StorageDead(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
6256
return; // scope 0 at $DIR/optimizes_into_variable.rs:+4:2: +4:2

‎tests/mir-opt/const_prop/optimizes_into_variable.main.PreCodegen.after.32bit.mir

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
fn main() -> () {
44
let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +0:11
55
let _1: i32; // in scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
6+
let mut _3: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
67
scope 1 {
78
debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
89
let _2: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
910
scope 2 {
1011
debug y => _2; // in scope 2 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
11-
let _3: u32; // in scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
1212
scope 3 {
1313
debug z => _3; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
1414
}
@@ -18,8 +18,6 @@ fn main() -> () {
1818
bb0: {
1919
StorageLive(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
2020
StorageLive(_2); // scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
21-
StorageLive(_3); // scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
22-
StorageDead(_3); // scope 2 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
2321
StorageDead(_2); // scope 1 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
2422
StorageDead(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
2523
return; // scope 0 at $DIR/optimizes_into_variable.rs:+4:2: +4:2

‎tests/mir-opt/const_prop/optimizes_into_variable.main.PreCodegen.after.64bit.mir

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
fn main() -> () {
44
let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +0:11
55
let _1: i32; // in scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
6+
let mut _3: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
67
scope 1 {
78
debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
89
let _2: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
910
scope 2 {
1011
debug y => _2; // in scope 2 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
11-
let _3: u32; // in scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
1212
scope 3 {
1313
debug z => _3; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
1414
}
@@ -18,8 +18,6 @@ fn main() -> () {
1818
bb0: {
1919
StorageLive(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
2020
StorageLive(_2); // scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
21-
StorageLive(_3); // scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
22-
StorageDead(_3); // scope 2 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
2321
StorageDead(_2); // scope 1 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
2422
StorageDead(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
2523
return; // scope 0 at $DIR/optimizes_into_variable.rs:+4:2: +4:2

‎tests/mir-opt/const_prop/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.diff

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
let mut _6: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
1111
let mut _7: bool; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
1212
let mut _9: Point; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
13+
+ let mut _10: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
14+
+ let mut _11: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
1315
scope 1 {
1416
debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
1517
let _3: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
@@ -45,10 +47,20 @@
4547
StorageDead(_5); // scope 1 at $DIR/optimizes_into_variable.rs:+2:34: +2:35
4648
StorageDead(_4); // scope 1 at $DIR/optimizes_into_variable.rs:+2:34: +2:35
4749
StorageLive(_8); // scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
48-
StorageLive(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
49-
_9 = Point { x: const 12_u32, y: const 42_u32 }; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
50-
_8 = (_9.1: u32); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38
51-
StorageDead(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39
50+
- StorageLive(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
51+
- _9 = Point { x: const 12_u32, y: const 42_u32 }; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
52+
- _8 = (_9.1: u32); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38
53+
- StorageDead(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39
54+
+ StorageLive(_10); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
55+
+ StorageLive(_11); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
56+
+ nop; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
57+
+ _10 = const 12_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
58+
+ _11 = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
59+
+ nop; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
60+
+ _8 = _11; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38
61+
+ StorageDead(_10); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39
62+
+ StorageDead(_11); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39
63+
+ nop; // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39
5264
nop; // scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +4:2
5365
StorageDead(_8); // scope 2 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
5466
StorageDead(_3); // scope 1 at $DIR/optimizes_into_variable.rs:+4:1: +4:2

‎tests/mir-opt/const_prop/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.diff

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
let mut _6: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
1111
let mut _7: bool; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
1212
let mut _9: Point; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
13+
+ let mut _10: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
14+
+ let mut _11: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
1315
scope 1 {
1416
debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
1517
let _3: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
@@ -45,10 +47,20 @@
4547
StorageDead(_5); // scope 1 at $DIR/optimizes_into_variable.rs:+2:34: +2:35
4648
StorageDead(_4); // scope 1 at $DIR/optimizes_into_variable.rs:+2:34: +2:35
4749
StorageLive(_8); // scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
48-
StorageLive(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
49-
_9 = Point { x: const 12_u32, y: const 42_u32 }; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
50-
_8 = (_9.1: u32); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38
51-
StorageDead(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39
50+
- StorageLive(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
51+
- _9 = Point { x: const 12_u32, y: const 42_u32 }; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
52+
- _8 = (_9.1: u32); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38
53+
- StorageDead(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39
54+
+ StorageLive(_10); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
55+
+ StorageLive(_11); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
56+
+ nop; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
57+
+ _10 = const 12_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
58+
+ _11 = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
59+
+ nop; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
60+
+ _8 = _11; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38
61+
+ StorageDead(_10); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39
62+
+ StorageDead(_11); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39
63+
+ nop; // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39
5264
nop; // scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +4:2
5365
StorageDead(_8); // scope 2 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
5466
StorageDead(_3); // scope 1 at $DIR/optimizes_into_variable.rs:+4:1: +4:2

‎tests/mir-opt/const_prop/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.mir

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
fn main() -> () {
44
let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +0:11
55
let _1: i32; // in scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
6+
let mut _3: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
67
scope 1 {
78
debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
89
let _2: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
910
scope 2 {
1011
debug y => _2; // in scope 2 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
11-
let _3: u32; // in scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
1212
scope 3 {
1313
debug z => _3; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
1414
}
@@ -18,8 +18,6 @@ fn main() -> () {
1818
bb0: {
1919
StorageLive(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
2020
StorageLive(_2); // scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
21-
StorageLive(_3); // scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
22-
StorageDead(_3); // scope 2 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
2321
StorageDead(_2); // scope 1 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
2422
StorageDead(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
2523
return; // scope 0 at $DIR/optimizes_into_variable.rs:+4:2: +4:2

‎tests/mir-opt/const_prop/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.mir

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
fn main() -> () {
44
let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +0:11
55
let _1: i32; // in scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
6+
let mut _3: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
67
scope 1 {
78
debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
89
let _2: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
910
scope 2 {
1011
debug y => _2; // in scope 2 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
11-
let _3: u32; // in scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
1212
scope 3 {
1313
debug z => _3; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
1414
}
@@ -18,8 +18,6 @@ fn main() -> () {
1818
bb0: {
1919
StorageLive(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
2020
StorageLive(_2); // scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
21-
StorageLive(_3); // scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
22-
StorageDead(_3); // scope 2 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
2321
StorageDead(_2); // scope 1 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
2422
StorageDead(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
2523
return; // scope 0 at $DIR/optimizes_into_variable.rs:+4:2: +4:2

‎tests/mir-opt/simple_option_map_e2e.ezmap.PreCodegen.after.mir

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,22 @@ fn ezmap(_1: Option<i32>) -> Option<i32> {
44
debug x => _1; // in scope 0 at $DIR/simple_option_map_e2e.rs:+0:14: +0:15
55
let mut _0: std::option::Option<i32>; // return place in scope 0 at $DIR/simple_option_map_e2e.rs:+0:33: +0:44
66
let mut _2: [closure@$DIR/simple_option_map_e2e.rs:14:12: 14:15]; // in scope 0 at $DIR/simple_option_map_e2e.rs:+1:12: +1:21
7-
let mut _7: i32; // in scope 0 at $DIR/simple_option_map_e2e.rs:7:25: 7:29
87
scope 1 (inlined map::<i32, i32, [closure@$DIR/simple_option_map_e2e.rs:14:12: 14:15]>) { // at $DIR/simple_option_map_e2e.rs:14:5: 14:22
98
debug slf => _1; // in scope 1 at $DIR/simple_option_map_e2e.rs:2:17: 2:20
109
debug f => _2; // in scope 1 at $DIR/simple_option_map_e2e.rs:2:33: 2:34
1110
let mut _3: isize; // in scope 1 at $DIR/simple_option_map_e2e.rs:7:9: 7:16
1211
let _4: i32; // in scope 1 at $DIR/simple_option_map_e2e.rs:7:14: 7:15
1312
let mut _5: i32; // in scope 1 at $DIR/simple_option_map_e2e.rs:7:25: 7:29
14-
let mut _6: (i32,); // in scope 1 at $DIR/simple_option_map_e2e.rs:7:25: 7:29
1513
scope 2 {
1614
debug x => _4; // in scope 2 at $DIR/simple_option_map_e2e.rs:7:14: 7:15
1715
scope 3 (inlined ezmap::{closure#0}) { // at $DIR/simple_option_map_e2e.rs:7:25: 7:29
18-
debug n => _7; // in scope 3 at $DIR/simple_option_map_e2e.rs:+1:13: +1:14
16+
debug n => _4; // in scope 3 at $DIR/simple_option_map_e2e.rs:+1:13: +1:14
1917
}
2018
}
2119
}
2220

2321
bb0: {
2422
StorageLive(_2); // scope 0 at $DIR/simple_option_map_e2e.rs:+1:12: +1:21
25-
StorageLive(_4); // scope 0 at $DIR/simple_option_map_e2e.rs:+1:5: +1:22
2623
_3 = discriminant(_1); // scope 1 at $DIR/simple_option_map_e2e.rs:6:11: 6:14
2724
switchInt(move _3) -> [0: bb1, 1: bb3, otherwise: bb2]; // scope 1 at $DIR/simple_option_map_e2e.rs:6:5: 6:14
2825
}
@@ -39,20 +36,13 @@ fn ezmap(_1: Option<i32>) -> Option<i32> {
3936
bb3: {
4037
_4 = move ((_1 as Some).0: i32); // scope 1 at $DIR/simple_option_map_e2e.rs:7:14: 7:15
4138
StorageLive(_5); // scope 2 at $DIR/simple_option_map_e2e.rs:7:25: 7:29
42-
StorageLive(_6); // scope 2 at $DIR/simple_option_map_e2e.rs:7:25: 7:29
43-
_6 = (move _4,); // scope 2 at $DIR/simple_option_map_e2e.rs:7:25: 7:29
44-
StorageLive(_7); // scope 2 at $DIR/simple_option_map_e2e.rs:7:25: 7:29
45-
_7 = move (_6.0: i32); // scope 2 at $DIR/simple_option_map_e2e.rs:7:25: 7:29
46-
_5 = Add(_7, const 1_i32); // scope 3 at $DIR/simple_option_map_e2e.rs:+1:16: +1:21
47-
StorageDead(_7); // scope 2 at $DIR/simple_option_map_e2e.rs:7:25: 7:29
48-
StorageDead(_6); // scope 2 at $DIR/simple_option_map_e2e.rs:7:28: 7:29
39+
_5 = Add(_4, const 1_i32); // scope 3 at $DIR/simple_option_map_e2e.rs:+1:16: +1:21
4940
_0 = Option::<i32>::Some(move _5); // scope 2 at $DIR/simple_option_map_e2e.rs:7:20: 7:30
5041
StorageDead(_5); // scope 2 at $DIR/simple_option_map_e2e.rs:7:29: 7:30
5142
goto -> bb4; // scope 1 at $DIR/simple_option_map_e2e.rs:10:1: 10:2
5243
}
5344

5445
bb4: {
55-
StorageDead(_4); // scope 0 at $DIR/simple_option_map_e2e.rs:+1:5: +1:22
5646
StorageDead(_2); // scope 0 at $DIR/simple_option_map_e2e.rs:+1:21: +1:22
5747
return; // scope 0 at $DIR/simple_option_map_e2e.rs:+2:2: +2:2
5848
}
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/sroa.rs:+0:11: +0:12
6+
let mut _0: (); // return place in scope 0 at $DIR/sroa.rs:+0:19: +0:19
7+
let _2: Foo; // in scope 0 at $DIR/sroa.rs:+1:9: +1:10
8+
+ let _11: u8; // in scope 0 at $DIR/sroa.rs:+1:9: +1:10
9+
+ let _12: (); // in scope 0 at $DIR/sroa.rs:+1:9: +1:10
10+
+ let _13: &str; // in scope 0 at $DIR/sroa.rs:+1:9: +1:10
11+
+ let _14: std::option::Option<isize>; // in scope 0 at $DIR/sroa.rs:+1:9: +1:10
12+
scope 1 {
13+
- debug y => _2; // in scope 1 at $DIR/sroa.rs:+1:9: +1:10
14+
+ debug y => Foo{ .0 => _11, .1 => _12, .2 => _13, .3 => _14, }; // in scope 1 at $DIR/sroa.rs:+1:9: +1:10
15+
let _3: u8; // in scope 1 at $DIR/sroa.rs:+2:9: +2:10
16+
scope 2 {
17+
debug t => _3; // in scope 2 at $DIR/sroa.rs:+2:9: +2:10
18+
let _4: &str; // in scope 2 at $DIR/sroa.rs:+3:9: +3:10
19+
scope 3 {
20+
debug u => _4; // in scope 3 at $DIR/sroa.rs:+3:9: +3:10
21+
let _5: Foo; // in scope 3 at $DIR/sroa.rs:+4:9: +4:10
22+
+ let _7: u8; // in scope 3 at $DIR/sroa.rs:+4:9: +4:10
23+
+ let _8: (); // in scope 3 at $DIR/sroa.rs:+4:9: +4:10
24+
+ let _9: &str; // in scope 3 at $DIR/sroa.rs:+4:9: +4:10
25+
+ let _10: std::option::Option<isize>; // in scope 3 at $DIR/sroa.rs:+4:9: +4:10
26+
scope 4 {
27+
- debug z => _5; // in scope 4 at $DIR/sroa.rs:+4:9: +4:10
28+
+ debug z => Foo{ .0 => _7, .1 => _8, .2 => _9, .3 => _10, }; // in scope 4 at $DIR/sroa.rs:+4:9: +4:10
29+
let _6: (); // in scope 4 at $DIR/sroa.rs:+5:9: +5:10
30+
scope 5 {
31+
debug a => _6; // in scope 5 at $DIR/sroa.rs:+5:9: +5:10
32+
}
33+
}
34+
}
35+
}
36+
}
37+
38+
bb0: {
39+
- StorageLive(_2); // scope 0 at $DIR/sroa.rs:+1:9: +1:10
40+
- _2 = _1; // scope 0 at $DIR/sroa.rs:+1:13: +1:14
41+
+ StorageLive(_11); // scope 0 at $DIR/sroa.rs:+1:9: +1:10
42+
+ StorageLive(_12); // scope 0 at $DIR/sroa.rs:+1:9: +1:10
43+
+ StorageLive(_13); // scope 0 at $DIR/sroa.rs:+1:9: +1:10
44+
+ StorageLive(_14); // scope 0 at $DIR/sroa.rs:+1:9: +1:10
45+
+ nop; // scope 0 at $DIR/sroa.rs:+1:9: +1:10
46+
+ _11 = (_1.0: u8); // scope 0 at $DIR/sroa.rs:+1:13: +1:14
47+
+ _12 = (_1.1: ()); // scope 0 at $DIR/sroa.rs:+1:13: +1:14
48+
+ _13 = (_1.2: &str); // scope 0 at $DIR/sroa.rs:+1:13: +1:14
49+
+ _14 = (_1.3: std::option::Option<isize>); // scope 0 at $DIR/sroa.rs:+1:13: +1:14
50+
+ nop; // scope 0 at $DIR/sroa.rs:+1:13: +1:14
51+
StorageLive(_3); // scope 1 at $DIR/sroa.rs:+2:9: +2:10
52+
- _3 = (_2.0: u8); // scope 1 at $DIR/sroa.rs:+2:13: +2:16
53+
+ _3 = _11; // scope 1 at $DIR/sroa.rs:+2:13: +2:16
54+
StorageLive(_4); // scope 2 at $DIR/sroa.rs:+3:9: +3:10
55+
- _4 = (_2.2: &str); // scope 2 at $DIR/sroa.rs:+3:13: +3:16
56+
- StorageLive(_5); // scope 3 at $DIR/sroa.rs:+4:9: +4:10
57+
- _5 = _2; // scope 3 at $DIR/sroa.rs:+4:13: +4:14
58+
+ _4 = _13; // scope 2 at $DIR/sroa.rs:+3:13: +3:16
59+
+ StorageLive(_7); // scope 3 at $DIR/sroa.rs:+4:9: +4:10
60+
+ StorageLive(_8); // scope 3 at $DIR/sroa.rs:+4:9: +4:10
61+
+ StorageLive(_9); // scope 3 at $DIR/sroa.rs:+4:9: +4:10
62+
+ StorageLive(_10); // scope 3 at $DIR/sroa.rs:+4:9: +4:10
63+
+ nop; // scope 3 at $DIR/sroa.rs:+4:9: +4:10
64+
+ _7 = _11; // scope 3 at $DIR/sroa.rs:+4:13: +4:14
65+
+ _8 = _12; // scope 3 at $DIR/sroa.rs:+4:13: +4:14
66+
+ _9 = _13; // scope 3 at $DIR/sroa.rs:+4:13: +4:14
67+
+ _10 = _14; // scope 3 at $DIR/sroa.rs:+4:13: +4:14
68+
+ nop; // scope 3 at $DIR/sroa.rs:+4:13: +4:14
69+
StorageLive(_6); // scope 4 at $DIR/sroa.rs:+5:9: +5:10
70+
- _6 = (_5.1: ()); // scope 4 at $DIR/sroa.rs:+5:13: +5:16
71+
+ _6 = _8; // scope 4 at $DIR/sroa.rs:+5:13: +5:16
72+
_0 = const (); // scope 0 at $DIR/sroa.rs:+0:19: +6:2
73+
StorageDead(_6); // scope 4 at $DIR/sroa.rs:+6:1: +6:2
74+
- StorageDead(_5); // scope 3 at $DIR/sroa.rs:+6:1: +6:2
75+
+ StorageDead(_7); // scope 3 at $DIR/sroa.rs:+6:1: +6:2
76+
+ StorageDead(_8); // scope 3 at $DIR/sroa.rs:+6:1: +6:2
77+
+ StorageDead(_9); // scope 3 at $DIR/sroa.rs:+6:1: +6:2
78+
+ StorageDead(_10); // scope 3 at $DIR/sroa.rs:+6:1: +6:2
79+
+ nop; // scope 3 at $DIR/sroa.rs:+6:1: +6:2
80+
StorageDead(_4); // scope 2 at $DIR/sroa.rs:+6:1: +6:2
81+
StorageDead(_3); // scope 1 at $DIR/sroa.rs:+6:1: +6:2
82+
- StorageDead(_2); // scope 0 at $DIR/sroa.rs:+6:1: +6:2
83+
+ StorageDead(_11); // scope 0 at $DIR/sroa.rs:+6:1: +6:2
84+
+ StorageDead(_12); // scope 0 at $DIR/sroa.rs:+6:1: +6:2
85+
+ StorageDead(_13); // scope 0 at $DIR/sroa.rs:+6:1: +6:2
86+
+ StorageDead(_14); // scope 0 at $DIR/sroa.rs:+6:1: +6:2
87+
+ nop; // scope 0 at $DIR/sroa.rs:+6:1: +6:2
88+
return; // scope 0 at $DIR/sroa.rs:+6:2: +6:2
89+
}
90+
}
91+

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
StorageLive(_5); // scope 0 at $DIR/sroa.rs:+2:34: +2:37
1818
_5 = g() -> bb1; // scope 0 at $DIR/sroa.rs:+2:34: +2:37
1919
// mir::Constant
20-
// + span: $DIR/sroa.rs:78:34: 78:35
20+
// + span: $DIR/sroa.rs:73:34: 73:35
2121
// + literal: Const { ty: fn() -> u32 {g}, val: Value(<ZST>) }
2222
}
2323

@@ -28,7 +28,7 @@
2828
_2 = &raw const (*_3); // scope 0 at $DIR/sroa.rs:+2:7: +2:41
2929
_1 = f(move _2) -> bb2; // scope 0 at $DIR/sroa.rs:+2:5: +2:42
3030
// mir::Constant
31-
// + span: $DIR/sroa.rs:78:5: 78:6
31+
// + span: $DIR/sroa.rs:73:5: 73:6
3232
// + literal: Const { ty: fn(*const u32) {f}, val: Value(<ZST>) }
3333
}
3434

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

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
let mut _5: Foo; // in scope 0 at $DIR/sroa.rs:+1:30: +1:70
1111
let mut _6: (); // in scope 0 at $DIR/sroa.rs:+1:45: +1:47
1212
let mut _7: std::option::Option<isize>; // in scope 0 at $DIR/sroa.rs:+1:60: +1:68
13+
+ let mut _8: u8; // in scope 0 at $DIR/sroa.rs:+1:30: +1:70
14+
+ let mut _9: (); // in scope 0 at $DIR/sroa.rs:+1:30: +1:70
15+
+ let mut _10: &str; // in scope 0 at $DIR/sroa.rs:+1:30: +1:70
16+
+ let mut _11: std::option::Option<isize>; // in scope 0 at $DIR/sroa.rs:+1:30: +1:70
1317
scope 1 {
1418
debug a => _1; // in scope 1 at $DIR/sroa.rs:+1:15: +1:16
1519
debug b => _2; // in scope 1 at $DIR/sroa.rs:+1:18: +1:19
@@ -26,26 +30,45 @@
2630
}
2731

2832
bb0: {
29-
StorageLive(_5); // scope 0 at $DIR/sroa.rs:+1:30: +1:70
33+
- StorageLive(_5); // scope 0 at $DIR/sroa.rs:+1:30: +1:70
34+
+ StorageLive(_8); // scope 0 at $DIR/sroa.rs:+1:30: +1:70
35+
+ StorageLive(_9); // scope 0 at $DIR/sroa.rs:+1:30: +1:70
36+
+ StorageLive(_10); // scope 0 at $DIR/sroa.rs:+1:30: +1:70
37+
+ StorageLive(_11); // scope 0 at $DIR/sroa.rs:+1:30: +1:70
38+
+ nop; // scope 0 at $DIR/sroa.rs:+1:30: +1:70
3039
StorageLive(_6); // scope 0 at $DIR/sroa.rs:+1:45: +1:47
3140
_6 = (); // scope 0 at $DIR/sroa.rs:+1:45: +1:47
3241
StorageLive(_7); // scope 0 at $DIR/sroa.rs:+1:60: +1:68
3342
_7 = Option::<isize>::Some(const -4_isize); // scope 0 at $DIR/sroa.rs:+1:60: +1:68
34-
_5 = Foo { a: const 5_u8, b: move _6, c: const "a", d: move _7 }; // scope 0 at $DIR/sroa.rs:+1:30: +1:70
43+
- _5 = Foo { a: const 5_u8, b: move _6, c: const "a", d: move _7 }; // scope 0 at $DIR/sroa.rs:+1:30: +1:70
44+
+ _8 = const 5_u8; // scope 0 at $DIR/sroa.rs:+1:30: +1:70
45+
+ _9 = move _6; // scope 0 at $DIR/sroa.rs:+1:30: +1:70
46+
+ _10 = const "a"; // scope 0 at $DIR/sroa.rs:+1:30: +1:70
3547
// mir::Constant
36-
// + span: $DIR/sroa.rs:57:52: 57:55
48+
// + span: $DIR/sroa.rs:53:52: 53:55
3749
// + literal: Const { ty: &str, val: Value(Slice(..)) }
50+
+ _11 = move _7; // scope 0 at $DIR/sroa.rs:+1:30: +1:70
51+
+ nop; // scope 0 at $DIR/sroa.rs:+1:30: +1:70
3852
StorageDead(_7); // scope 0 at $DIR/sroa.rs:+1:69: +1:70
3953
StorageDead(_6); // scope 0 at $DIR/sroa.rs:+1:69: +1:70
4054
StorageLive(_1); // scope 0 at $DIR/sroa.rs:+1:15: +1:16
41-
_1 = (_5.0: u8); // scope 0 at $DIR/sroa.rs:+1:15: +1:16
55+
- _1 = (_5.0: u8); // scope 0 at $DIR/sroa.rs:+1:15: +1:16
56+
+ _1 = _8; // scope 0 at $DIR/sroa.rs:+1:15: +1:16
4257
StorageLive(_2); // scope 0 at $DIR/sroa.rs:+1:18: +1:19
43-
_2 = (_5.1: ()); // scope 0 at $DIR/sroa.rs:+1:18: +1:19
58+
- _2 = (_5.1: ()); // scope 0 at $DIR/sroa.rs:+1:18: +1:19
59+
+ _2 = _9; // scope 0 at $DIR/sroa.rs:+1:18: +1:19
4460
StorageLive(_3); // scope 0 at $DIR/sroa.rs:+1:21: +1:22
45-
_3 = (_5.2: &str); // scope 0 at $DIR/sroa.rs:+1:21: +1:22
61+
- _3 = (_5.2: &str); // scope 0 at $DIR/sroa.rs:+1:21: +1:22
62+
+ _3 = _10; // scope 0 at $DIR/sroa.rs:+1:21: +1:22
4663
StorageLive(_4); // scope 0 at $DIR/sroa.rs:+1:24: +1:25
47-
_4 = (_5.3: std::option::Option<isize>); // scope 0 at $DIR/sroa.rs:+1:24: +1:25
48-
StorageDead(_5); // scope 0 at $DIR/sroa.rs:+1:70: +1:71
64+
- _4 = (_5.3: std::option::Option<isize>); // scope 0 at $DIR/sroa.rs:+1:24: +1:25
65+
- StorageDead(_5); // scope 0 at $DIR/sroa.rs:+1:70: +1:71
66+
+ _4 = _11; // scope 0 at $DIR/sroa.rs:+1:24: +1:25
67+
+ StorageDead(_8); // scope 0 at $DIR/sroa.rs:+1:70: +1:71
68+
+ StorageDead(_9); // scope 0 at $DIR/sroa.rs:+1:70: +1:71
69+
+ StorageDead(_10); // scope 0 at $DIR/sroa.rs:+1:70: +1:71
70+
+ StorageDead(_11); // scope 0 at $DIR/sroa.rs:+1:70: +1:71
71+
+ nop; // scope 0 at $DIR/sroa.rs:+1:70: +1:71
4972
_0 = const (); // scope 0 at $DIR/sroa.rs:+0:15: +6:2
5073
StorageDead(_4); // scope 0 at $DIR/sroa.rs:+6:1: +6:2
5174
StorageDead(_3); // scope 0 at $DIR/sroa.rs:+6:1: +6:2
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/sroa.rs:+0:15: +0:16
6+
let mut _0: (); // return place in scope 0 at $DIR/sroa.rs:+0:24: +0:24
7+
let _2: Foo; // in scope 0 at $DIR/sroa.rs:+1:9: +1:10
8+
+ let _5: u8; // in scope 0 at $DIR/sroa.rs:+1:9: +1:10
9+
+ let _6: (); // in scope 0 at $DIR/sroa.rs:+1:9: +1:10
10+
+ let _7: &str; // in scope 0 at $DIR/sroa.rs:+1:9: +1:10
11+
+ let _8: std::option::Option<isize>; // in scope 0 at $DIR/sroa.rs:+1:9: +1:10
12+
scope 1 {
13+
- debug y => _2; // in scope 1 at $DIR/sroa.rs:+1:9: +1:10
14+
+ debug y => Foo{ .0 => _5, .1 => _6, .2 => _7, .3 => _8, }; // in scope 1 at $DIR/sroa.rs:+1:9: +1:10
15+
let _3: u8; // in scope 1 at $DIR/sroa.rs:+2:9: +2:10
16+
scope 2 {
17+
debug t => _3; // in scope 2 at $DIR/sroa.rs:+2:9: +2:10
18+
let _4: &str; // in scope 2 at $DIR/sroa.rs:+3:9: +3:10
19+
scope 3 {
20+
debug u => _4; // in scope 3 at $DIR/sroa.rs:+3:9: +3:10
21+
}
22+
}
23+
}
24+
25+
bb0: {
26+
- StorageLive(_2); // scope 0 at $DIR/sroa.rs:+1:9: +1:10
27+
- _2 = (*_1); // scope 0 at $DIR/sroa.rs:+1:13: +1:15
28+
+ StorageLive(_5); // scope 0 at $DIR/sroa.rs:+1:9: +1:10
29+
+ StorageLive(_6); // scope 0 at $DIR/sroa.rs:+1:9: +1:10
30+
+ StorageLive(_7); // scope 0 at $DIR/sroa.rs:+1:9: +1:10
31+
+ StorageLive(_8); // scope 0 at $DIR/sroa.rs:+1:9: +1:10
32+
+ nop; // scope 0 at $DIR/sroa.rs:+1:9: +1:10
33+
+ _5 = ((*_1).0: u8); // scope 0 at $DIR/sroa.rs:+1:13: +1:15
34+
+ _6 = ((*_1).1: ()); // scope 0 at $DIR/sroa.rs:+1:13: +1:15
35+
+ _7 = ((*_1).2: &str); // scope 0 at $DIR/sroa.rs:+1:13: +1:15
36+
+ _8 = ((*_1).3: std::option::Option<isize>); // scope 0 at $DIR/sroa.rs:+1:13: +1:15
37+
+ nop; // scope 0 at $DIR/sroa.rs:+1:13: +1:15
38+
StorageLive(_3); // scope 1 at $DIR/sroa.rs:+2:9: +2:10
39+
- _3 = (_2.0: u8); // scope 1 at $DIR/sroa.rs:+2:13: +2:16
40+
+ _3 = _5; // scope 1 at $DIR/sroa.rs:+2:13: +2:16
41+
StorageLive(_4); // scope 2 at $DIR/sroa.rs:+3:9: +3:10
42+
- _4 = (_2.2: &str); // scope 2 at $DIR/sroa.rs:+3:13: +3:16
43+
+ _4 = _7; // scope 2 at $DIR/sroa.rs:+3:13: +3:16
44+
_0 = const (); // scope 0 at $DIR/sroa.rs:+0:24: +4:2
45+
StorageDead(_4); // scope 2 at $DIR/sroa.rs:+4:1: +4:2
46+
StorageDead(_3); // scope 1 at $DIR/sroa.rs:+4:1: +4:2
47+
- StorageDead(_2); // scope 0 at $DIR/sroa.rs:+4:1: +4:2
48+
+ StorageDead(_5); // scope 0 at $DIR/sroa.rs:+4:1: +4:2
49+
+ StorageDead(_6); // scope 0 at $DIR/sroa.rs:+4:1: +4:2
50+
+ StorageDead(_7); // scope 0 at $DIR/sroa.rs:+4:1: +4:2
51+
+ StorageDead(_8); // scope 0 at $DIR/sroa.rs:+4:1: +4:2
52+
+ nop; // scope 0 at $DIR/sroa.rs:+4:1: +4:2
53+
return; // scope 0 at $DIR/sroa.rs:+4:2: +4:2
54+
}
55+
}
56+

‎tests/mir-opt/sroa.rs

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,14 @@ impl Drop for Tag {
1212
fn drop(&mut self) {}
1313
}
1414

15-
// EMIT_MIR sroa.dropping.ScalarReplacementOfAggregates.diff
1615
pub fn dropping() {
1716
S(Tag(0), Tag(1), Tag(2)).1;
1817
}
1918

20-
// EMIT_MIR sroa.enums.ScalarReplacementOfAggregates.diff
2119
pub fn enums(a: usize) -> usize {
2220
if let Some(a) = Some(a) { a } else { 0 }
2321
}
2422

25-
// EMIT_MIR sroa.structs.ScalarReplacementOfAggregates.diff
2623
pub fn structs(a: f32) -> f32 {
2724
struct U {
2825
_foo: usize,
@@ -32,7 +29,6 @@ pub fn structs(a: f32) -> f32 {
3229
U { _foo: 0, a }.a
3330
}
3431

35-
// EMIT_MIR sroa.unions.ScalarReplacementOfAggregates.diff
3632
pub fn unions(a: f32) -> u32 {
3733
union Repr {
3834
f: f32,
@@ -41,6 +37,7 @@ pub fn unions(a: f32) -> u32 {
4137
unsafe { Repr { f: a }.u }
4238
}
4339

40+
#[derive(Copy, Clone)]
4441
struct Foo {
4542
a: u8,
4643
b: (),
@@ -52,7 +49,6 @@ fn g() -> u32 {
5249
3
5350
}
5451

55-
// EMIT_MIR sroa.flat.ScalarReplacementOfAggregates.diff
5652
pub fn flat() {
5753
let Foo { a, b, c, d } = Foo { a: 5, b: (), c: "a", d: Some(-4) };
5854
let _ = a;
@@ -72,17 +68,41 @@ fn f(a: *const u32) {
7268
println!("{}", unsafe { *a.add(2) });
7369
}
7470

75-
// EMIT_MIR sroa.escaping.ScalarReplacementOfAggregates.diff
7671
pub fn escaping() {
7772
// Verify this struct is not flattened.
7873
f(&Escaping { a: 1, b: 2, c: g() }.a);
7974
}
8075

76+
fn copies(x: Foo) {
77+
let y = x;
78+
let t = y.a;
79+
let u = y.c;
80+
let z = y;
81+
let a = z.b;
82+
}
83+
84+
fn ref_copies(x: &Foo) {
85+
let y = *x;
86+
let t = y.a;
87+
let u = y.c;
88+
}
89+
8190
fn main() {
8291
dropping();
8392
enums(5);
8493
structs(5.);
8594
unions(5.);
8695
flat();
8796
escaping();
97+
copies(Foo { a: 5, b: (), c: "a", d: Some(-4) });
98+
ref_copies(&Foo { a: 5, b: (), c: "a", d: Some(-4) });
8899
}
100+
101+
// EMIT_MIR sroa.dropping.ScalarReplacementOfAggregates.diff
102+
// EMIT_MIR sroa.enums.ScalarReplacementOfAggregates.diff
103+
// EMIT_MIR sroa.structs.ScalarReplacementOfAggregates.diff
104+
// EMIT_MIR sroa.unions.ScalarReplacementOfAggregates.diff
105+
// EMIT_MIR sroa.flat.ScalarReplacementOfAggregates.diff
106+
// EMIT_MIR sroa.escaping.ScalarReplacementOfAggregates.diff
107+
// EMIT_MIR sroa.copies.ScalarReplacementOfAggregates.diff
108+
// EMIT_MIR sroa.ref_copies.ScalarReplacementOfAggregates.diff

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,27 @@
66
let mut _0: f32; // return place in scope 0 at $DIR/sroa.rs:+0:27: +0:30
77
let mut _2: structs::U; // in scope 0 at $DIR/sroa.rs:+6:5: +6:21
88
let mut _3: f32; // in scope 0 at $DIR/sroa.rs:+6:18: +6:19
9+
+ let mut _4: usize; // in scope 0 at $DIR/sroa.rs:+6:5: +6:21
10+
+ let mut _5: f32; // in scope 0 at $DIR/sroa.rs:+6:5: +6:21
911

1012
bb0: {
11-
StorageLive(_2); // scope 0 at $DIR/sroa.rs:+6:5: +6:21
13+
- StorageLive(_2); // scope 0 at $DIR/sroa.rs:+6:5: +6:21
14+
+ StorageLive(_4); // scope 0 at $DIR/sroa.rs:+6:5: +6:21
15+
+ StorageLive(_5); // scope 0 at $DIR/sroa.rs:+6:5: +6:21
16+
+ nop; // scope 0 at $DIR/sroa.rs:+6:5: +6:21
1217
StorageLive(_3); // scope 0 at $DIR/sroa.rs:+6:18: +6:19
1318
_3 = _1; // scope 0 at $DIR/sroa.rs:+6:18: +6:19
14-
_2 = U { _foo: const 0_usize, a: move _3 }; // scope 0 at $DIR/sroa.rs:+6:5: +6:21
19+
- _2 = U { _foo: const 0_usize, a: move _3 }; // scope 0 at $DIR/sroa.rs:+6:5: +6:21
20+
+ _4 = const 0_usize; // scope 0 at $DIR/sroa.rs:+6:5: +6:21
21+
+ _5 = move _3; // scope 0 at $DIR/sroa.rs:+6:5: +6:21
22+
+ nop; // scope 0 at $DIR/sroa.rs:+6:5: +6:21
1523
StorageDead(_3); // scope 0 at $DIR/sroa.rs:+6:20: +6:21
16-
_0 = (_2.1: f32); // scope 0 at $DIR/sroa.rs:+6:5: +6:23
17-
StorageDead(_2); // scope 0 at $DIR/sroa.rs:+7:1: +7:2
24+
- _0 = (_2.1: f32); // scope 0 at $DIR/sroa.rs:+6:5: +6:23
25+
- StorageDead(_2); // scope 0 at $DIR/sroa.rs:+7:1: +7:2
26+
+ _0 = _5; // scope 0 at $DIR/sroa.rs:+6:5: +6:23
27+
+ StorageDead(_4); // scope 0 at $DIR/sroa.rs:+7:1: +7:2
28+
+ StorageDead(_5); // scope 0 at $DIR/sroa.rs:+7:1: +7:2
29+
+ nop; // scope 0 at $DIR/sroa.rs:+7:1: +7:2
1830
return; // scope 0 at $DIR/sroa.rs:+7:2: +7:2
1931
}
2032
}

0 commit comments

Comments
 (0)
This repository has been archived.