Add test.

This commit is contained in:
Camille GILLOT 2024-11-01 14:38:19 +00:00 committed by Ralf Jung
parent 7db7489f9b
commit 2cc0ee65d9
5 changed files with 154 additions and 0 deletions

View File

@ -0,0 +1,22 @@
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
fn src(x: &&u8) -> bool {
// CHECK-LABEL: fn src(
// CHECK: _0 = const true;
let y = **x;
unsafe { unknown() };
**x == y
}
#[inline(never)]
unsafe fn unknown() {
// CHECK-LABEL: fn unknown(
}
fn main() {
// CHECK-LABEL: fn main(
src(&&0);
}
// EMIT_MIR deref_nested_borrows.src.GVN.diff
// EMIT_MIR deref_nested_borrows.src.PreCodegen.after.mir

View File

@ -0,0 +1,43 @@
- // MIR for `src` before GVN
+ // MIR for `src` after GVN
fn src(_1: &&u8) -> bool {
debug x => _1;
let mut _0: bool;
let _2: u8;
let _3: ();
let mut _4: u8;
let mut _5: u8;
let mut _6: &u8;
let mut _7: &u8;
scope 1 {
debug y => _2;
}
bb0: {
- StorageLive(_2);
- _6 = deref_copy (*_1);
+ nop;
+ _6 = copy (*_1);
_2 = copy (*_6);
_3 = unknown() -> [return: bb1, unwind unreachable];
}
bb1: {
StorageLive(_4);
- _7 = deref_copy (*_1);
- _4 = copy (*_7);
+ _7 = copy _6;
+ _4 = copy _2;
StorageLive(_5);
_5 = copy _2;
- _0 = Eq(move _4, move _5);
+ _0 = const true;
StorageDead(_5);
StorageDead(_4);
- StorageDead(_2);
+ nop;
return;
}
}

View File

@ -0,0 +1,43 @@
- // MIR for `src` before GVN
+ // MIR for `src` after GVN
fn src(_1: &&u8) -> bool {
debug x => _1;
let mut _0: bool;
let _2: u8;
let _3: ();
let mut _4: u8;
let mut _5: u8;
let mut _6: &u8;
let mut _7: &u8;
scope 1 {
debug y => _2;
}
bb0: {
- StorageLive(_2);
- _6 = deref_copy (*_1);
+ nop;
+ _6 = copy (*_1);
_2 = copy (*_6);
_3 = unknown() -> [return: bb1, unwind continue];
}
bb1: {
StorageLive(_4);
- _7 = deref_copy (*_1);
- _4 = copy (*_7);
+ _7 = copy _6;
+ _4 = copy _2;
StorageLive(_5);
_5 = copy _2;
- _0 = Eq(move _4, move _5);
+ _0 = const true;
StorageDead(_5);
StorageDead(_4);
- StorageDead(_2);
+ nop;
return;
}
}

View File

@ -0,0 +1,23 @@
// MIR for `src` after PreCodegen
fn src(_1: &&u8) -> bool {
debug x => _1;
let mut _0: bool;
let mut _2: &u8;
let _3: u8;
let _4: ();
scope 1 {
debug y => _3;
}
bb0: {
_2 = copy (*_1);
_3 = copy (*_2);
_4 = unknown() -> [return: bb1, unwind unreachable];
}
bb1: {
_0 = const true;
return;
}
}

View File

@ -0,0 +1,23 @@
// MIR for `src` after PreCodegen
fn src(_1: &&u8) -> bool {
debug x => _1;
let mut _0: bool;
let mut _2: &u8;
let _3: u8;
let _4: ();
scope 1 {
debug y => _3;
}
bb0: {
_2 = copy (*_1);
_3 = copy (*_2);
_4 = unknown() -> [return: bb1, unwind continue];
}
bb1: {
_0 = const true;
return;
}
}