Skip to content

Commit 465ff89

Browse files
committed
Added another small test to gvn storage
1 parent 7bd4589 commit 465ff89

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
- // MIR for `f_dead` before GVN
2+
+ // MIR for `f_dead` after GVN
3+
4+
fn f_dead(_1: u32) -> () {
5+
let mut _0: ();
6+
let mut _2: S;
7+
let mut _3: S;
8+
9+
bb0: {
10+
- StorageLive(_2);
11+
+ nop;
12+
_2 = S(copy _1, const 2_u32);
13+
- StorageDead(_2);
14+
+ nop;
15+
StorageLive(_3);
16+
- _3 = S(copy _1, const 2_u32);
17+
+ _3 = copy _2;
18+
StorageDead(_3);
19+
return;
20+
}
21+
}
22+

tests/mir-opt/gvn_storage_issue_141649.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//@ test-mir-pass: GVN
33
// EMIT_MIR gvn_storage_issue_141649.f.GVN.diff
44
// EMIT_MIR gvn_storage_issue_141649.f_borrowed.GVN.diff
5+
// EMIT_MIR gvn_storage_issue_141649.f_dead.GVN.diff
56

67
#![feature(custom_mir, core_intrinsics)]
78

@@ -57,3 +58,26 @@ pub fn f_borrowed(_1: u32) {
5758
}
5859
}
5960
}
61+
62+
#[custom_mir(dialect = "runtime")]
63+
pub fn f_dead(_1: u32) {
64+
// CHECK-LABEL: fn f_dead(
65+
mir! {
66+
let _2: S;
67+
let _3: S;
68+
{
69+
// CHECK-NOT: StorageLive(_2);
70+
// CHECK: StorageLive(_3);
71+
// CHECK: _3 = copy _2;
72+
// CHECK: StorageDead(_3);
73+
// CHECK-NOT: StorageDead(_2);
74+
StorageLive(_2);
75+
_2 = S(_1, 2);
76+
StorageDead(_2);
77+
StorageLive(_3);
78+
_3 = S(_1, 2);
79+
StorageDead(_3);
80+
Return()
81+
}
82+
}
83+
}

0 commit comments

Comments
 (0)