Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6917040

Browse files
authoredFeb 2, 2023
Rollup merge of #107524 - cjgillot:both-storage, r=RalfJung
Remove both StorageLive and StorageDead in CopyProp. Fixes #107511 #106908 removed StorageDead without the accompanying StorageLive. In loops, execution would see repeated StorageLive, without any StorageDead, which is UB. So when removing storage statements, we have to remove both StorageLive and StorageDead. ~I also added a MIR validation pass for StorageLive. It may be a bit overzealous.~
2 parents 230c9e9 + e8ac040 commit 6917040

20 files changed

+176
-48
lines changed
 

‎compiler/rustc_mir_transform/src/copy_prop.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -162,17 +162,20 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> {
162162
}
163163

164164
fn visit_statement(&mut self, stmt: &mut Statement<'tcx>, loc: Location) {
165-
if let StatementKind::StorageDead(l) = stmt.kind
166-
&& self.storage_to_remove.contains(l)
167-
{
168-
stmt.make_nop();
169-
} else if let StatementKind::Assign(box (ref place, ref mut rvalue)) = stmt.kind
170-
&& place.as_local().is_some()
171-
{
172-
// Do not replace assignments.
173-
self.visit_rvalue(rvalue, loc)
174-
} else {
175-
self.super_statement(stmt, loc);
165+
match stmt.kind {
166+
// When removing storage statements, we need to remove both (#107511).
167+
StatementKind::StorageLive(l) | StatementKind::StorageDead(l)
168+
if self.storage_to_remove.contains(l) =>
169+
{
170+
stmt.make_nop()
171+
}
172+
StatementKind::Assign(box (ref place, ref mut rvalue))
173+
if place.as_local().is_some() =>
174+
{
175+
// Do not replace assignments.
176+
self.visit_rvalue(rvalue, loc)
177+
}
178+
_ => self.super_statement(stmt, loc),
176179
}
177180
}
178181
}

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,8 @@
5656
}
5757

5858
bb0: {
59-
StorageLive(_1); // scope 0 at $DIR/const_debuginfo.rs:+1:9: +1:10
6059
_1 = const 1_u8; // scope 0 at $DIR/const_debuginfo.rs:+1:13: +1:16
61-
StorageLive(_2); // scope 1 at $DIR/const_debuginfo.rs:+2:9: +2:10
6260
_2 = const 2_u8; // scope 1 at $DIR/const_debuginfo.rs:+2:13: +2:16
63-
StorageLive(_3); // scope 2 at $DIR/const_debuginfo.rs:+3:9: +3:10
6461
_3 = const 3_u8; // scope 2 at $DIR/const_debuginfo.rs:+3:13: +3:16
6562
StorageLive(_4); // scope 3 at $DIR/const_debuginfo.rs:+4:9: +4:12
6663
StorageLive(_5); // scope 3 at $DIR/const_debuginfo.rs:+4:15: +4:20

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
}
1919

2020
bb0: {
21-
StorageLive(_1); // scope 0 at $DIR/bad_op_mod_by_zero.rs:+1:9: +1:10
2221
_1 = const 0_i32; // scope 0 at $DIR/bad_op_mod_by_zero.rs:+1:13: +1:14
2322
StorageLive(_2); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:9: +2:11
2423
- _4 = Eq(_1, const 0_i32); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
}
1212

1313
bb0: {
14-
StorageLive(_1); // scope 0 at $DIR/scalar_literal_propagation.rs:+1:9: +1:10
1514
_1 = const 1_u32; // scope 0 at $DIR/scalar_literal_propagation.rs:+1:13: +1:14
1615
StorageLive(_2); // scope 1 at $DIR/scalar_literal_propagation.rs:+2:5: +2:15
1716
- _2 = consume(_1) -> bb1; // scope 1 at $DIR/scalar_literal_propagation.rs:+2:5: +2:15

‎tests/mir-opt/copy-prop/cycle.main.CopyProp.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
}
3030

3131
bb1: {
32-
StorageLive(_2); // scope 1 at $DIR/cycle.rs:+2:9: +2:10
32+
- StorageLive(_2); // scope 1 at $DIR/cycle.rs:+2:9: +2:10
3333
_2 = _1; // scope 1 at $DIR/cycle.rs:+2:13: +2:14
3434
- StorageLive(_3); // scope 2 at $DIR/cycle.rs:+3:9: +3:10
3535
- _3 = _2; // scope 2 at $DIR/cycle.rs:+3:13: +3:14

‎tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.mir

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ fn f(_1: usize) -> usize {
1111
}
1212

1313
bb0: {
14-
StorageLive(_2); // scope 0 at $DIR/dead_stores_79191.rs:+1:9: +1:10
1514
_2 = _1; // scope 0 at $DIR/dead_stores_79191.rs:+1:13: +1:14
1615
_1 = const 5_usize; // scope 1 at $DIR/dead_stores_79191.rs:+2:5: +2:10
1716
_1 = _2; // scope 1 at $DIR/dead_stores_79191.rs:+3:5: +3:10

‎tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.mir

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ fn f(_1: usize) -> usize {
1111
}
1212

1313
bb0: {
14-
StorageLive(_2); // scope 0 at $DIR/dead_stores_better.rs:+1:9: +1:10
1514
_2 = _1; // scope 0 at $DIR/dead_stores_better.rs:+1:13: +1:14
1615
_1 = const 5_usize; // scope 1 at $DIR/dead_stores_better.rs:+2:5: +2:10
1716
_1 = _2; // scope 1 at $DIR/dead_stores_better.rs:+3:5: +3:10
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
- // MIR for `main` before CopyProp
2+
+ // MIR for `main` after CopyProp
3+
4+
fn main() -> () {
5+
let mut _0: (); // return place in scope 0 at $DIR/issue_107511.rs:+0:11: +0:11
6+
let mut _1: i32; // in scope 0 at $DIR/issue_107511.rs:+1:9: +1:16
7+
let mut _3: std::ops::Range<usize>; // in scope 0 at $DIR/issue_107511.rs:+6:14: +6:24
8+
let mut _4: std::ops::Range<usize>; // in scope 0 at $DIR/issue_107511.rs:+6:14: +6:24
9+
let mut _5: usize; // in scope 0 at $DIR/issue_107511.rs:+6:17: +6:24
10+
let mut _6: &[i32]; // in scope 0 at $DIR/issue_107511.rs:+6:17: +6:24
11+
let mut _7: &[i32; 4]; // in scope 0 at $DIR/issue_107511.rs:+6:17: +6:24
12+
let mut _9: (); // in scope 0 at $DIR/issue_107511.rs:+0:1: +9:2
13+
let _10: (); // in scope 0 at $DIR/issue_107511.rs:+6:14: +6:24
14+
let mut _11: std::option::Option<usize>; // in scope 0 at $DIR/issue_107511.rs:+6:14: +6:24
15+
let mut _12: &mut std::ops::Range<usize>; // in scope 0 at $DIR/issue_107511.rs:+6:14: +6:24
16+
let mut _13: &mut std::ops::Range<usize>; // in scope 0 at $DIR/issue_107511.rs:+6:14: +6:24
17+
let mut _14: isize; // in scope 0 at $DIR/issue_107511.rs:+6:5: +8:6
18+
let mut _15: !; // in scope 0 at $DIR/issue_107511.rs:+6:5: +8:6
19+
let mut _17: i32; // in scope 0 at $DIR/issue_107511.rs:+7:16: +7:20
20+
let _18: usize; // in scope 0 at $DIR/issue_107511.rs:+7:18: +7:19
21+
let mut _19: usize; // in scope 0 at $DIR/issue_107511.rs:+7:16: +7:20
22+
let mut _20: bool; // in scope 0 at $DIR/issue_107511.rs:+7:16: +7:20
23+
scope 1 {
24+
debug sum => _1; // in scope 1 at $DIR/issue_107511.rs:+1:9: +1:16
25+
let _2: [i32; 4]; // in scope 1 at $DIR/issue_107511.rs:+2:9: +2:10
26+
scope 2 {
27+
debug a => _2; // in scope 2 at $DIR/issue_107511.rs:+2:9: +2:10
28+
let mut _8: std::ops::Range<usize>; // in scope 2 at $DIR/issue_107511.rs:+6:14: +6:24
29+
scope 3 {
30+
debug iter => _8; // in scope 3 at $DIR/issue_107511.rs:+6:14: +6:24
31+
let _16: usize; // in scope 3 at $DIR/issue_107511.rs:+6:9: +6:10
32+
scope 4 {
33+
debug i => _16; // in scope 4 at $DIR/issue_107511.rs:+6:9: +6:10
34+
}
35+
}
36+
}
37+
}
38+
39+
bb0: {
40+
StorageLive(_1); // scope 0 at $DIR/issue_107511.rs:+1:9: +1:16
41+
_1 = const 0_i32; // scope 0 at $DIR/issue_107511.rs:+1:19: +1:20
42+
StorageLive(_2); // scope 1 at $DIR/issue_107511.rs:+2:9: +2:10
43+
_2 = [const 0_i32, const 10_i32, const 20_i32, const 30_i32]; // scope 1 at $DIR/issue_107511.rs:+2:13: +2:28
44+
StorageLive(_3); // scope 2 at $DIR/issue_107511.rs:+6:14: +6:24
45+
StorageLive(_4); // scope 2 at $DIR/issue_107511.rs:+6:14: +6:24
46+
StorageLive(_5); // scope 2 at $DIR/issue_107511.rs:+6:17: +6:24
47+
StorageLive(_6); // scope 2 at $DIR/issue_107511.rs:+6:17: +6:24
48+
StorageLive(_7); // scope 2 at $DIR/issue_107511.rs:+6:17: +6:24
49+
_7 = &_2; // scope 2 at $DIR/issue_107511.rs:+6:17: +6:24
50+
_6 = move _7 as &[i32] (Pointer(Unsize)); // scope 2 at $DIR/issue_107511.rs:+6:17: +6:24
51+
StorageDead(_7); // scope 2 at $DIR/issue_107511.rs:+6:17: +6:18
52+
_5 = core::slice::<impl [i32]>::len(move _6) -> bb1; // scope 2 at $DIR/issue_107511.rs:+6:17: +6:24
53+
// mir::Constant
54+
// + span: $DIR/issue_107511.rs:10:19: 10:22
55+
// + literal: Const { ty: for<'a> fn(&'a [i32]) -> usize {core::slice::<impl [i32]>::len}, val: Value(<ZST>) }
56+
}
57+
58+
bb1: {
59+
StorageDead(_6); // scope 2 at $DIR/issue_107511.rs:+6:23: +6:24
60+
Deinit(_4); // scope 2 at $DIR/issue_107511.rs:+6:14: +6:24
61+
(_4.0: usize) = const 0_usize; // scope 2 at $DIR/issue_107511.rs:+6:14: +6:24
62+
(_4.1: usize) = move _5; // scope 2 at $DIR/issue_107511.rs:+6:14: +6:24
63+
StorageDead(_5); // scope 2 at $DIR/issue_107511.rs:+6:23: +6:24
64+
_3 = <std::ops::Range<usize> as IntoIterator>::into_iter(move _4) -> bb2; // scope 2 at $DIR/issue_107511.rs:+6:14: +6:24
65+
// mir::Constant
66+
// + span: $DIR/issue_107511.rs:10:14: 10:24
67+
// + literal: Const { ty: fn(std::ops::Range<usize>) -> <std::ops::Range<usize> as IntoIterator>::IntoIter {<std::ops::Range<usize> as IntoIterator>::into_iter}, val: Value(<ZST>) }
68+
}
69+
70+
bb2: {
71+
StorageDead(_4); // scope 2 at $DIR/issue_107511.rs:+6:23: +6:24
72+
StorageLive(_8); // scope 2 at $DIR/issue_107511.rs:+6:14: +6:24
73+
_8 = move _3; // scope 2 at $DIR/issue_107511.rs:+6:14: +6:24
74+
goto -> bb3; // scope 3 at $DIR/issue_107511.rs:+6:5: +8:6
75+
}
76+
77+
bb3: {
78+
- StorageLive(_10); // scope 3 at $DIR/issue_107511.rs:+6:14: +6:24
79+
StorageLive(_11); // scope 3 at $DIR/issue_107511.rs:+6:14: +6:24
80+
StorageLive(_12); // scope 3 at $DIR/issue_107511.rs:+6:14: +6:24
81+
StorageLive(_13); // scope 3 at $DIR/issue_107511.rs:+6:14: +6:24
82+
_13 = &mut _8; // scope 3 at $DIR/issue_107511.rs:+6:14: +6:24
83+
_12 = &mut (*_13); // scope 3 at $DIR/issue_107511.rs:+6:14: +6:24
84+
_11 = <std::ops::Range<usize> as Iterator>::next(move _12) -> bb4; // scope 3 at $DIR/issue_107511.rs:+6:14: +6:24
85+
// mir::Constant
86+
// + span: $DIR/issue_107511.rs:10:14: 10:24
87+
// + literal: Const { ty: for<'a> fn(&'a mut std::ops::Range<usize>) -> Option<<std::ops::Range<usize> as Iterator>::Item> {<std::ops::Range<usize> as Iterator>::next}, val: Value(<ZST>) }
88+
}
89+
90+
bb4: {
91+
StorageDead(_12); // scope 3 at $DIR/issue_107511.rs:+6:23: +6:24
92+
_14 = discriminant(_11); // scope 3 at $DIR/issue_107511.rs:+6:14: +6:24
93+
switchInt(move _14) -> [0: bb7, 1: bb5, otherwise: bb6]; // scope 3 at $DIR/issue_107511.rs:+6:14: +6:24
94+
}
95+
96+
bb5: {
97+
- StorageLive(_16); // scope 3 at $DIR/issue_107511.rs:+6:9: +6:10
98+
_16 = ((_11 as Some).0: usize); // scope 3 at $DIR/issue_107511.rs:+6:9: +6:10
99+
StorageLive(_17); // scope 4 at $DIR/issue_107511.rs:+7:16: +7:20
100+
- StorageLive(_18); // scope 4 at $DIR/issue_107511.rs:+7:18: +7:19
101+
- _18 = _16; // scope 4 at $DIR/issue_107511.rs:+7:18: +7:19
102+
_19 = Len(_2); // scope 4 at $DIR/issue_107511.rs:+7:16: +7:20
103+
- _20 = Lt(_18, _19); // scope 4 at $DIR/issue_107511.rs:+7:16: +7:20
104+
- assert(move _20, "index out of bounds: the length is {} but the index is {}", move _19, _18) -> bb8; // scope 4 at $DIR/issue_107511.rs:+7:16: +7:20
105+
+ _20 = Lt(_16, _19); // scope 4 at $DIR/issue_107511.rs:+7:16: +7:20
106+
+ assert(move _20, "index out of bounds: the length is {} but the index is {}", move _19, _16) -> bb8; // scope 4 at $DIR/issue_107511.rs:+7:16: +7:20
107+
}
108+
109+
bb6: {
110+
unreachable; // scope 3 at $DIR/issue_107511.rs:+6:14: +6:24
111+
}
112+
113+
bb7: {
114+
_0 = const (); // scope 3 at $DIR/issue_107511.rs:+6:5: +8:6
115+
StorageDead(_13); // scope 3 at $DIR/issue_107511.rs:+8:5: +8:6
116+
StorageDead(_11); // scope 3 at $DIR/issue_107511.rs:+8:5: +8:6
117+
- StorageDead(_10); // scope 3 at $DIR/issue_107511.rs:+8:5: +8:6
118+
StorageDead(_8); // scope 2 at $DIR/issue_107511.rs:+8:5: +8:6
119+
StorageDead(_3); // scope 2 at $DIR/issue_107511.rs:+8:5: +8:6
120+
StorageDead(_2); // scope 1 at $DIR/issue_107511.rs:+9:1: +9:2
121+
StorageDead(_1); // scope 0 at $DIR/issue_107511.rs:+9:1: +9:2
122+
return; // scope 0 at $DIR/issue_107511.rs:+9:2: +9:2
123+
}
124+
125+
bb8: {
126+
- _17 = _2[_18]; // scope 4 at $DIR/issue_107511.rs:+7:16: +7:20
127+
+ _17 = _2[_16]; // scope 4 at $DIR/issue_107511.rs:+7:16: +7:20
128+
_1 = Add(_1, move _17); // scope 4 at $DIR/issue_107511.rs:+7:9: +7:20
129+
StorageDead(_17); // scope 4 at $DIR/issue_107511.rs:+7:19: +7:20
130+
- StorageDead(_18); // scope 4 at $DIR/issue_107511.rs:+7:20: +7:21
131+
- _10 = const (); // scope 4 at $DIR/issue_107511.rs:+6:25: +8:6
132+
- StorageDead(_16); // scope 3 at $DIR/issue_107511.rs:+8:5: +8:6
133+
StorageDead(_13); // scope 3 at $DIR/issue_107511.rs:+8:5: +8:6
134+
StorageDead(_11); // scope 3 at $DIR/issue_107511.rs:+8:5: +8:6
135+
- StorageDead(_10); // scope 3 at $DIR/issue_107511.rs:+8:5: +8:6
136+
- _9 = const (); // scope 3 at $DIR/issue_107511.rs:+6:5: +8:6
137+
goto -> bb3; // scope 3 at $DIR/issue_107511.rs:+6:5: +8:6
138+
}
139+
}
140+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// unit-test: CopyProp
2+
3+
// EMIT_MIR issue_107511.main.CopyProp.diff
4+
fn main() {
5+
let mut sum = 0;
6+
let a = [0, 10, 20, 30];
7+
8+
// `i` is assigned in a loop. Only removing its `StorageDead` would mean that
9+
// execution sees repeated `StorageLive`. This would be UB.
10+
for i in 0..a.len() {
11+
sum += a[i];
12+
}
13+
}

‎tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.diff

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
}
1717

1818
bb0: {
19-
StorageLive(_1); // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47
2019
_1 = const u8::MAX; // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47
21-
StorageLive(_2); // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47
2220
_2 = const 1_u8; // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47
2321
_5 = CheckedAdd(const u8::MAX, const 1_u8); // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL
2422
assert(!move (_5.1: bool), "attempt to compute `{} + {}`, which would overflow", const u8::MAX, const 1_u8) -> bb1; // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL

‎tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.diff

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@
7979
}
8080

8181
bb6: {
82-
StorageLive(_10); // scope 3 at $DIR/funky_arms.rs:+13:17: +13:26
8382
_10 = ((_7 as Some).0: usize); // scope 3 at $DIR/funky_arms.rs:+13:17: +13:26
8483
StorageLive(_11); // scope 3 at $DIR/funky_arms.rs:+15:43: +15:46
8584
_11 = &mut (*_1); // scope 3 at $DIR/funky_arms.rs:+15:43: +15:46

‎tests/mir-opt/issue_101973.inner.ConstProp.diff

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
bb0: {
3434
StorageLive(_2); // scope 0 at $DIR/issue_101973.rs:+1:5: +1:65
3535
StorageLive(_3); // scope 0 at $DIR/issue_101973.rs:+1:5: +1:58
36-
StorageLive(_4); // scope 0 at $DIR/issue_101973.rs:+1:5: +1:17
3736
StorageLive(_12); // scope 2 at $DIR/issue_101973.rs:7:12: 7:27
3837
StorageLive(_13); // scope 2 at $DIR/issue_101973.rs:7:12: 7:20
3938
_14 = CheckedShr(_1, const 0_i32); // scope 2 at $DIR/issue_101973.rs:7:12: 7:20
@@ -63,7 +62,6 @@
6362
StorageDead(_13); // scope 2 at $DIR/issue_101973.rs:7:26: 7:27
6463
_4 = BitOr(const 0_u32, move _12); // scope 2 at $DIR/issue_101973.rs:7:5: 7:27
6564
StorageDead(_12); // scope 2 at $DIR/issue_101973.rs:7:26: 7:27
66-
StorageLive(_6); // scope 0 at $DIR/issue_101973.rs:+1:31: +1:57
6765
StorageLive(_7); // scope 0 at $DIR/issue_101973.rs:+1:31: +1:52
6866
StorageLive(_8); // scope 0 at $DIR/issue_101973.rs:+1:32: +1:45
6967
_10 = CheckedShr(_1, const 8_i32); // scope 0 at $DIR/issue_101973.rs:+1:32: +1:45

‎tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
bb0: {
3131
StorageLive(_2); // scope 0 at $DIR/issue_76432.rs:+1:9: +1:10
32-
StorageLive(_4); // scope 0 at $DIR/issue_76432.rs:+1:19: +1:29
3332
StorageLive(_5); // scope 0 at $DIR/issue_76432.rs:+1:20: +1:29
3433
_5 = [_1, _1, _1]; // scope 0 at $DIR/issue_76432.rs:+1:20: +1:29
3534
_4 = &_5; // scope 0 at $DIR/issue_76432.rs:+1:19: +1:29

‎tests/mir-opt/simplify_match.main.ConstProp.diff

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
}
1111

1212
bb0: {
13-
StorageLive(_2); // scope 0 at $DIR/simplify_match.rs:+1:17: +1:18
1413
_2 = const false; // scope 0 at $DIR/simplify_match.rs:+1:21: +1:26
1514
- switchInt(_2) -> [0: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify_match.rs:+1:5: +1:31
1615
+ switchInt(const false) -> [0: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify_match.rs:+1:5: +1:31

‎tests/mir-opt/slice_filter.variant_a-{closure#0}.CopyProp.diff

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,16 @@
101101
}
102102

103103
bb0: {
104-
StorageLive(_3); // scope 0 at $DIR/slice_filter.rs:+0:27: +0:28
104+
- StorageLive(_3); // scope 0 at $DIR/slice_filter.rs:+0:27: +0:28
105105
_25 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:27: +0:28
106106
_3 = &((*_25).0: usize); // scope 0 at $DIR/slice_filter.rs:+0:27: +0:28
107-
StorageLive(_4); // scope 0 at $DIR/slice_filter.rs:+0:30: +0:31
107+
- StorageLive(_4); // scope 0 at $DIR/slice_filter.rs:+0:30: +0:31
108108
_26 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:30: +0:31
109109
_4 = &((*_26).1: usize); // scope 0 at $DIR/slice_filter.rs:+0:30: +0:31
110-
StorageLive(_5); // scope 0 at $DIR/slice_filter.rs:+0:33: +0:34
110+
- StorageLive(_5); // scope 0 at $DIR/slice_filter.rs:+0:33: +0:34
111111
_27 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:33: +0:34
112112
_5 = &((*_27).2: usize); // scope 0 at $DIR/slice_filter.rs:+0:33: +0:34
113-
StorageLive(_6); // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37
113+
- StorageLive(_6); // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37
114114
_28 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37
115115
_6 = &((*_28).3: usize); // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37
116116
StorageLive(_7); // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56

‎tests/mir-opt/slice_filter.variant_a-{closure#0}.DestinationPropagation.diff

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,12 @@
8585
}
8686

8787
bb0: {
88-
StorageLive(_3); // scope 0 at $DIR/slice_filter.rs:+0:27: +0:28
8988
_25 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:27: +0:28
9089
_3 = &((*_25).0: usize); // scope 0 at $DIR/slice_filter.rs:+0:27: +0:28
91-
StorageLive(_4); // scope 0 at $DIR/slice_filter.rs:+0:30: +0:31
9290
_26 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:30: +0:31
9391
_4 = &((*_26).1: usize); // scope 0 at $DIR/slice_filter.rs:+0:30: +0:31
94-
StorageLive(_5); // scope 0 at $DIR/slice_filter.rs:+0:33: +0:34
9592
_27 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:33: +0:34
9693
_5 = &((*_27).2: usize); // scope 0 at $DIR/slice_filter.rs:+0:33: +0:34
97-
StorageLive(_6); // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37
9894
_28 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37
9995
_6 = &((*_28).3: usize); // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37
10096
- StorageLive(_7); // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56

‎tests/mir-opt/slice_filter.variant_b-{closure#0}.CopyProp.diff

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@
3333
}
3434

3535
bb0: {
36-
StorageLive(_3); // scope 0 at $DIR/slice_filter.rs:+0:29: +0:30
36+
- StorageLive(_3); // scope 0 at $DIR/slice_filter.rs:+0:29: +0:30
3737
_21 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:29: +0:30
3838
_3 = ((*_21).0: usize); // scope 0 at $DIR/slice_filter.rs:+0:29: +0:30
39-
StorageLive(_4); // scope 0 at $DIR/slice_filter.rs:+0:32: +0:33
39+
- StorageLive(_4); // scope 0 at $DIR/slice_filter.rs:+0:32: +0:33
4040
_22 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:32: +0:33
4141
_4 = ((*_22).1: usize); // scope 0 at $DIR/slice_filter.rs:+0:32: +0:33
42-
StorageLive(_5); // scope 0 at $DIR/slice_filter.rs:+0:35: +0:36
42+
- StorageLive(_5); // scope 0 at $DIR/slice_filter.rs:+0:35: +0:36
4343
_23 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:35: +0:36
4444
_5 = ((*_23).2: usize); // scope 0 at $DIR/slice_filter.rs:+0:35: +0:36
45-
StorageLive(_6); // scope 0 at $DIR/slice_filter.rs:+0:38: +0:39
45+
- StorageLive(_6); // scope 0 at $DIR/slice_filter.rs:+0:38: +0:39
4646
_24 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:38: +0:39
4747
_6 = ((*_24).3: usize); // scope 0 at $DIR/slice_filter.rs:+0:38: +0:39
4848
StorageLive(_7); // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58

‎tests/mir-opt/slice_filter.variant_b-{closure#0}.DestinationPropagation.diff

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,12 @@
2525
}
2626

2727
bb0: {
28-
StorageLive(_3); // scope 0 at $DIR/slice_filter.rs:+0:29: +0:30
2928
_13 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:29: +0:30
3029
_3 = ((*_13).0: usize); // scope 0 at $DIR/slice_filter.rs:+0:29: +0:30
31-
StorageLive(_4); // scope 0 at $DIR/slice_filter.rs:+0:32: +0:33
3230
_14 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:32: +0:33
3331
_4 = ((*_14).1: usize); // scope 0 at $DIR/slice_filter.rs:+0:32: +0:33
34-
StorageLive(_5); // scope 0 at $DIR/slice_filter.rs:+0:35: +0:36
3532
_15 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:35: +0:36
3633
_5 = ((*_15).2: usize); // scope 0 at $DIR/slice_filter.rs:+0:35: +0:36
37-
StorageLive(_6); // scope 0 at $DIR/slice_filter.rs:+0:38: +0:39
3834
_16 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:38: +0:39
3935
_6 = ((*_16).3: usize); // scope 0 at $DIR/slice_filter.rs:+0:38: +0:39
4036
- StorageLive(_7); // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58

‎tests/mir-opt/try_identity_e2e.new.PreCodegen.after.mir

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ fn new(_1: Result<T, E>) -> Result<T, E> {
3030
}
3131

3232
bb1: {
33-
StorageLive(_5); // scope 0 at $DIR/try_identity_e2e.rs:+5:21: +5:22
3433
_5 = move ((_1 as Err).0: E); // scope 0 at $DIR/try_identity_e2e.rs:+5:21: +5:22
3534
Deinit(_2); // scope 2 at $DIR/try_identity_e2e.rs:+5:27: +5:48
3635
((_2 as Break).0: E) = move _5; // scope 2 at $DIR/try_identity_e2e.rs:+5:27: +5:48
@@ -40,7 +39,6 @@ fn new(_1: Result<T, E>) -> Result<T, E> {
4039
}
4140

4241
bb2: {
43-
StorageLive(_4); // scope 0 at $DIR/try_identity_e2e.rs:+4:20: +4:21
4442
_4 = move ((_1 as Ok).0: T); // scope 0 at $DIR/try_identity_e2e.rs:+4:20: +4:21
4543
Deinit(_2); // scope 1 at $DIR/try_identity_e2e.rs:+4:26: +4:50
4644
((_2 as Continue).0: T) = move _4; // scope 1 at $DIR/try_identity_e2e.rs:+4:26: +4:50
@@ -50,7 +48,6 @@ fn new(_1: Result<T, E>) -> Result<T, E> {
5048
}
5149

5250
bb3: {
53-
StorageLive(_8); // scope 0 at $DIR/try_identity_e2e.rs:+9:32: +9:33
5451
_8 = move ((_2 as Break).0: E); // scope 0 at $DIR/try_identity_e2e.rs:+9:32: +9:33
5552
Deinit(_0); // scope 4 at $DIR/try_identity_e2e.rs:+9:45: +9:51
5653
((_0 as Err).0: E) = move _8; // scope 4 at $DIR/try_identity_e2e.rs:+9:45: +9:51
@@ -64,7 +61,6 @@ fn new(_1: Result<T, E>) -> Result<T, E> {
6461
}
6562

6663
bb5: {
67-
StorageLive(_7); // scope 0 at $DIR/try_identity_e2e.rs:+8:35: +8:36
6864
_7 = move ((_2 as Continue).0: T); // scope 0 at $DIR/try_identity_e2e.rs:+8:35: +8:36
6965
Deinit(_0); // scope 0 at $DIR/try_identity_e2e.rs:+1:5: +11:6
7066
((_0 as Ok).0: T) = move _7; // scope 0 at $DIR/try_identity_e2e.rs:+1:5: +11:6

‎tests/mir-opt/try_identity_e2e.old.PreCodegen.after.mir

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ fn old(_1: Result<T, E>) -> Result<T, E> {
1919
}
2020

2121
bb1: {
22-
StorageLive(_4); // scope 0 at $DIR/try_identity_e2e.rs:+4:17: +4:18
2322
_4 = move ((_1 as Err).0: E); // scope 0 at $DIR/try_identity_e2e.rs:+4:17: +4:18
2423
Deinit(_0); // scope 2 at $DIR/try_identity_e2e.rs:+4:30: +4:36
2524
((_0 as Err).0: E) = move _4; // scope 2 at $DIR/try_identity_e2e.rs:+4:30: +4:36
@@ -32,7 +31,6 @@ fn old(_1: Result<T, E>) -> Result<T, E> {
3231
}
3332

3433
bb3: {
35-
StorageLive(_3); // scope 0 at $DIR/try_identity_e2e.rs:+3:16: +3:17
3634
_3 = move ((_1 as Ok).0: T); // scope 0 at $DIR/try_identity_e2e.rs:+3:16: +3:17
3735
Deinit(_0); // scope 0 at $DIR/try_identity_e2e.rs:+1:5: +6:6
3836
((_0 as Ok).0: T) = move _3; // scope 0 at $DIR/try_identity_e2e.rs:+1:5: +6:6

0 commit comments

Comments
 (0)
Please sign in to comment.