-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
43 changes: 43 additions & 0 deletions
43
tests/mir-opt/pre-codegen/deref_nested_borrows.src.GVN.panic-abort.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
|
43 changes: 43 additions & 0 deletions
43
tests/mir-opt/pre-codegen/deref_nested_borrows.src.GVN.panic-unwind.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
|
23 changes: 23 additions & 0 deletions
23
tests/mir-opt/pre-codegen/deref_nested_borrows.src.PreCodegen.after.panic-abort.mir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
tests/mir-opt/pre-codegen/deref_nested_borrows.src.PreCodegen.after.panic-unwind.mir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |