Skip to content

Commit bebe274

Browse files
committed
Add test case
1 parent 0da281b commit bebe274

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// compile-flags: -Zmir-opt-level=2
2+
// mir-opt-level is fixed at 2 because that's the max level that can be set on stable
3+
// EMIT_MIR constant_local_debuginfo.main.DeadStoreElimination.diff
4+
fn main() {
5+
let a = 1;
6+
let b = 4;
7+
8+
foo(a + b);
9+
}
10+
11+
#[inline(never)]
12+
fn foo(x: i32) {
13+
std::process::exit(x);
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
- // MIR for `main` before DeadStoreElimination
2+
+ // MIR for `main` after DeadStoreElimination
3+
4+
fn main() -> () {
5+
let mut _0: (); // return place in scope 0 at $DIR/constant-local-debuginfo.rs:+0:11: +0:11
6+
let _1: i32; // in scope 0 at $DIR/constant-local-debuginfo.rs:+1:9: +1:10
7+
let _3: (); // in scope 0 at $DIR/constant-local-debuginfo.rs:+4:5: +4:15
8+
let mut _4: i32; // in scope 0 at $DIR/constant-local-debuginfo.rs:+4:9: +4:14
9+
let mut _5: i32; // in scope 0 at $DIR/constant-local-debuginfo.rs:+4:9: +4:10
10+
let mut _6: i32; // in scope 0 at $DIR/constant-local-debuginfo.rs:+4:13: +4:14
11+
scope 1 {
12+
debug a => _1; // in scope 1 at $DIR/constant-local-debuginfo.rs:+1:9: +1:10
13+
let _2: i32; // in scope 1 at $DIR/constant-local-debuginfo.rs:+2:9: +2:10
14+
scope 2 {
15+
debug b => _2; // in scope 2 at $DIR/constant-local-debuginfo.rs:+2:9: +2:10
16+
}
17+
}
18+
19+
bb0: {
20+
StorageLive(_1); // scope 0 at $DIR/constant-local-debuginfo.rs:+1:9: +1:10
21+
- _1 = const 1_i32; // scope 0 at $DIR/constant-local-debuginfo.rs:+1:13: +1:14
22+
+ nop; // scope 0 at $DIR/constant-local-debuginfo.rs:+1:13: +1:14
23+
StorageLive(_2); // scope 1 at $DIR/constant-local-debuginfo.rs:+2:9: +2:10
24+
- _2 = const 4_i32; // scope 1 at $DIR/constant-local-debuginfo.rs:+2:13: +2:14
25+
+ nop; // scope 1 at $DIR/constant-local-debuginfo.rs:+2:13: +2:14
26+
StorageLive(_3); // scope 2 at $DIR/constant-local-debuginfo.rs:+4:5: +4:15
27+
StorageLive(_4); // scope 2 at $DIR/constant-local-debuginfo.rs:+4:9: +4:14
28+
StorageLive(_5); // scope 2 at $DIR/constant-local-debuginfo.rs:+4:9: +4:10
29+
- _5 = const 1_i32; // scope 2 at $DIR/constant-local-debuginfo.rs:+4:9: +4:10
30+
+ nop; // scope 2 at $DIR/constant-local-debuginfo.rs:+4:9: +4:10
31+
StorageLive(_6); // scope 2 at $DIR/constant-local-debuginfo.rs:+4:13: +4:14
32+
- _6 = const 4_i32; // scope 2 at $DIR/constant-local-debuginfo.rs:+4:13: +4:14
33+
+ nop; // scope 2 at $DIR/constant-local-debuginfo.rs:+4:13: +4:14
34+
_4 = const 5_i32; // scope 2 at $DIR/constant-local-debuginfo.rs:+4:9: +4:14
35+
StorageDead(_6); // scope 2 at $DIR/constant-local-debuginfo.rs:+4:13: +4:14
36+
StorageDead(_5); // scope 2 at $DIR/constant-local-debuginfo.rs:+4:13: +4:14
37+
_3 = foo(move _4) -> bb1; // scope 2 at $DIR/constant-local-debuginfo.rs:+4:5: +4:15
38+
// mir::Constant
39+
// + span: $DIR/constant-local-debuginfo.rs:8:5: 8:8
40+
// + literal: Const { ty: fn(i32) {foo}, val: Value(<ZST>) }
41+
}
42+
43+
bb1: {
44+
StorageDead(_4); // scope 2 at $DIR/constant-local-debuginfo.rs:+4:14: +4:15
45+
StorageDead(_3); // scope 2 at $DIR/constant-local-debuginfo.rs:+4:15: +4:16
46+
nop; // scope 0 at $DIR/constant-local-debuginfo.rs:+0:11: +5:2
47+
StorageDead(_2); // scope 1 at $DIR/constant-local-debuginfo.rs:+5:1: +5:2
48+
StorageDead(_1); // scope 0 at $DIR/constant-local-debuginfo.rs:+5:1: +5:2
49+
return; // scope 0 at $DIR/constant-local-debuginfo.rs:+5:2: +5:2
50+
}
51+
}
52+

0 commit comments

Comments
 (0)