Skip to content

Commit bde405a

Browse files
committed
Added test for preserving head storage
1 parent f4ecbcf commit bde405a

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
- // MIR for `f` before CopyProp
2+
+ // MIR for `f` after CopyProp
3+
4+
fn f(_1: &mut usize) -> () {
5+
let mut _0: ();
6+
let mut _2: usize;
7+
let mut _3: usize;
8+
9+
bb0: {
10+
StorageLive(_2);
11+
_2 = const 0_usize;
12+
- _3 = copy _2;
13+
- (*_1) = copy _3;
14+
+ (*_1) = copy _2;
15+
StorageDead(_2);
16+
(*_1) = copy _2;
17+
return;
18+
}
19+
}
20+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// skip-filecheck
2+
//@ test-mir-pass: CopyProp
3+
//@ compile-flags: -Zlint-mir=false
4+
5+
#![feature(custom_mir, core_intrinsics)]
6+
use std::intrinsics::mir::*;
7+
8+
// EMIT_MIR copy_prop_storage_preserve_head.f.CopyProp.diff
9+
10+
#[custom_mir(dialect = "runtime", phase = "post-cleanup")]
11+
pub fn f(_1: &mut usize) {
12+
mir! {
13+
let _2: usize;
14+
let _3: usize;
15+
{
16+
StorageLive(_2);
17+
_2 = 0;
18+
_3 = _2;
19+
(*_1) = _3;
20+
StorageDead(_2);
21+
(*_1) = _2;
22+
Return()
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)