Skip to content

Commit 94c25e5

Browse files
committed
Add regression test for 147485
1 parent acf2437 commit 94c25e5

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed

tests/crashes/147485.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//@ known-bug: #147485
2+
//@ compile-flags: -g -O
3+
4+
#![crate_type = "lib"]
5+
6+
pub fn f(x: *const usize) -> &'static usize {
7+
let mut a = unsafe { &*x };
8+
a = unsafe { &*x };
9+
a
10+
}
11+
12+
pub fn g() {
13+
f(&0);
14+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
- // MIR for `remap_debuginfo_locals` before ReferencePropagation
2+
+ // MIR for `remap_debuginfo_locals` after ReferencePropagation
3+
4+
fn remap_debuginfo_locals() -> () {
5+
let mut _0: ();
6+
let _1: &usize;
7+
let mut _2: *const usize;
8+
let _3: &usize;
9+
let _4: usize;
10+
let mut _5: &usize;
11+
scope 1 (inlined foo) {
12+
- debug a => _1;
13+
+ debug a => _5;
14+
}
15+
16+
bb0: {
17+
- StorageLive(_1);
18+
- StorageLive(_2);
19+
- StorageLive(_3);
20+
_5 = const remap_debuginfo_locals::promoted[0];
21+
- _3 = &(*_5);
22+
- _2 = &raw const (*_3);
23+
- // DBG: _1 = &(*_2);
24+
- _1 = &(*_2);
25+
- StorageDead(_2);
26+
- StorageDead(_3);
27+
- StorageDead(_1);
28+
+ // DBG: _1 = &(*_5);
29+
_0 = const ();
30+
return;
31+
}
32+
}
33+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// skip-filecheck
2+
//@ test-mir-pass: ReferencePropagation
3+
//@ compile-flags: -g -Zub_checks=false -Zinline-mir -Zmir-enable-passes=+DeadStoreElimination-initial
4+
5+
#![feature(core_intrinsics, custom_mir)]
6+
#![crate_type = "lib"]
7+
8+
use std::intrinsics::mir::*;
9+
10+
// EMIT_MIR ref_prop.remap_debuginfo_locals.ReferencePropagation.diff
11+
pub fn remap_debuginfo_locals() {
12+
foo(&0);
13+
}
14+
15+
#[custom_mir(dialect = "runtime", phase = "post-cleanup")]
16+
#[inline]
17+
fn foo(x: *const usize) -> &'static usize {
18+
mir! {
19+
debug a => RET;
20+
{
21+
RET = &*x;
22+
RET = &*x;
23+
Return()
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)