Check which places are dead

Fixes #78192
This commit is contained in:
Simon Vandel Sillesen 2020-10-22 22:22:17 +02:00
parent a9cd294cf2
commit 57d01a9aee
6 changed files with 55 additions and 9 deletions

View file

@ -19,7 +19,7 @@
// + span: $DIR/ref_deref.rs:5:6: 5:10
// + literal: Const { ty: &i32, val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ ref_deref[317d]::main), const_param_did: None }, [], Some(promoted[0])) }
_2 = _4; // scope 0 at $DIR/ref_deref.rs:5:6: 5:10
- _1 = (*_2); // scope 0 at $DIR/ref_deref.rs:5:5: 5:10
- _1 = (*_4); // scope 0 at $DIR/ref_deref.rs:5:5: 5:10
+ _1 = const 4_i32; // scope 0 at $DIR/ref_deref.rs:5:5: 5:10
StorageDead(_2); // scope 0 at $DIR/ref_deref.rs:5:10: 5:11
StorageDead(_1); // scope 0 at $DIR/ref_deref.rs:5:10: 5:11

View file

@ -19,7 +19,7 @@
// + span: $DIR/ref_deref_project.rs:5:6: 5:17
// + literal: Const { ty: &(i32, i32), val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ ref_deref_project[317d]::main), const_param_did: None }, [], Some(promoted[0])) }
_2 = &((*_4).1: i32); // scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17
_1 = (*_2); // scope 0 at $DIR/ref_deref_project.rs:5:5: 5:17
_1 = ((*_4).1: i32); // scope 0 at $DIR/ref_deref_project.rs:5:5: 5:17
StorageDead(_2); // scope 0 at $DIR/ref_deref_project.rs:5:17: 5:18
StorageDead(_1); // scope 0 at $DIR/ref_deref_project.rs:5:17: 5:18
_0 = const (); // scope 0 at $DIR/ref_deref_project.rs:4:11: 6:2

View file

@ -1,4 +1,4 @@
// compile-flags: -O -Zunsound-mir-opts
// compile-flags: -O
// EMIT_MIR inst_combine_deref.simple_opt.InstCombine.diff
fn simple_opt() -> u64 {
let x = 5;

View file

@ -0,0 +1,9 @@
// EMIT_MIR issue_78192.f.InstCombine.diff
pub fn f<T>(a: &T) -> *const T {
let b: &*const T = &(a as *const T);
*b
}
fn main() {
f(&2);
}

View file

@ -0,0 +1,29 @@
- // MIR for `f` before InstCombine
+ // MIR for `f` after InstCombine
fn f(_1: &T) -> *const T {
debug a => _1; // in scope 0 at $DIR/issue-78192.rs:2:13: 2:14
let mut _0: *const T; // return place in scope 0 at $DIR/issue-78192.rs:2:23: 2:31
let _2: &*const T; // in scope 0 at $DIR/issue-78192.rs:3:9: 3:10
let _3: &*const T; // in scope 0 at $DIR/issue-78192.rs:3:24: 3:40
let _4: *const T; // in scope 0 at $DIR/issue-78192.rs:3:25: 3:40
scope 1 {
debug b => _2; // in scope 1 at $DIR/issue-78192.rs:3:9: 3:10
}
bb0: {
StorageLive(_2); // scope 0 at $DIR/issue-78192.rs:3:9: 3:10
StorageLive(_3); // scope 0 at $DIR/issue-78192.rs:3:24: 3:40
StorageLive(_4); // scope 0 at $DIR/issue-78192.rs:3:25: 3:40
_4 = &raw const (*_1); // scope 0 at $DIR/issue-78192.rs:3:26: 3:27
_3 = &_4; // scope 0 at $DIR/issue-78192.rs:3:24: 3:40
- _2 = &(*_3); // scope 0 at $DIR/issue-78192.rs:3:24: 3:40
+ _2 = _3; // scope 0 at $DIR/issue-78192.rs:3:24: 3:40
StorageDead(_3); // scope 0 at $DIR/issue-78192.rs:3:40: 3:41
_0 = (*_2); // scope 1 at $DIR/issue-78192.rs:4:5: 4:7
StorageDead(_4); // scope 0 at $DIR/issue-78192.rs:5:1: 5:2
StorageDead(_2); // scope 0 at $DIR/issue-78192.rs:5:1: 5:2
return; // scope 0 at $DIR/issue-78192.rs:5:2: 5:2
}
}