Skip to content

Commit 432d579

Browse files
committed
fixup! mir-opt: Eliminate dead statements even if they are used by debuginfos
Add a test case for a invalid place on debuginfos
1 parent f7cb799 commit 432d579

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// MIR for `invalid_place` after PreCodegen
2+
3+
fn invalid_place(_1: bool) -> bool {
4+
debug c1_ref => _2;
5+
let mut _0: bool;
6+
let mut _2: &bool;
7+
8+
bb0: {
9+
// DBG: _2 = &?;
10+
_0 = copy _1;
11+
return;
12+
}
13+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#![feature(core_intrinsics, custom_mir)]
2+
#![crate_type = "lib"]
3+
4+
use std::intrinsics::mir::*;
5+
6+
// EMIT_MIR dead_on_invalid_place.invalid_place.PreCodegen.after.mir
7+
#[custom_mir(dialect = "runtime")]
8+
pub fn invalid_place(c: bool) -> bool {
9+
// CHECK-LABEL: fn invalid_place
10+
// CHECK: debug c1_ref => [[c1_ref:_[0-9]+]];
11+
// CHECK: bb0: {
12+
// We cannot read the reference, since `c1` is dead.
13+
// CHECK-NEXT: DBG: [[c1_ref]] = &?
14+
// CHECK-NEXT: _0 = copy _1;
15+
// CHECK-NEXT: return;
16+
mir! {
17+
let _c1_ref: &bool;
18+
let c1: bool;
19+
debug c1_ref => _c1_ref;
20+
{
21+
c1 = c;
22+
_c1_ref = &c1;
23+
RET = c;
24+
Return()
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)