File tree Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Original file line number Diff line number Diff line change
1
+ - // MIR for `f_borrowed` before GVN
2
+ + // MIR for `f_borrowed` after GVN
3
+
4
+ fn f_borrowed(_1: u32) -> () {
5
+ let mut _0: ();
6
+ let mut _2: S;
7
+ let mut _3: S;
8
+ let mut _4: &S;
9
+ let mut _5: S;
10
+
11
+ bb0: {
12
+ - StorageLive(_2);
13
+ + nop;
14
+ _2 = S(copy _1, const 2_u32);
15
+ - _3 = S(copy _1, const 2_u32);
16
+ + _3 = copy _2;
17
+ _4 = &_3;
18
+ - StorageDead(_2);
19
+ - _5 = copy (*_4);
20
+ + nop;
21
+ + _5 = copy _2;
22
+ return;
23
+ }
24
+ }
25
+
Original file line number Diff line number Diff line change 1
1
//! Check that we do not remove storage statements when possible.
2
2
//@ test-mir-pass: GVN
3
3
// EMIT_MIR gvn_storage_issue_141649.f.GVN.diff
4
+ // EMIT_MIR gvn_storage_issue_141649.f_borrowed.GVN.diff
4
5
5
6
#![ feature( custom_mir, core_intrinsics) ]
6
7
@@ -30,3 +31,29 @@ pub fn f(_1: u32) {
30
31
}
31
32
}
32
33
}
34
+
35
+ #[ custom_mir( dialect = "runtime" ) ]
36
+ pub fn f_borrowed ( _1 : u32 ) {
37
+ // CHECK-LABEL: fn f_borrowed(
38
+ mir ! {
39
+ let _2: S ;
40
+ let _3: S ;
41
+ let _4: & S ;
42
+ let _5: S ;
43
+ {
44
+ // CHECK-NOT: StorageLive(_2);
45
+ // CHECK: _3 = copy _2;
46
+ // CHECK-NOT: StorageDead(_2);
47
+ // CHECK: _5 = copy _2;
48
+ StorageLive ( _2) ;
49
+ _2 = S ( _1, 2 ) ;
50
+ _3 = S ( _1, 2 ) ;
51
+ _4 = & _3;
52
+ StorageDead ( _2) ;
53
+ // Because `*_4` will be replaced with `_2`,
54
+ // we have to remove the storage statements of `_2`.
55
+ _5 = * _4;
56
+ Return ( )
57
+ }
58
+ }
59
+ }
You can’t perform that action at this time.
0 commit comments