-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
InstCombine away intrinsic validity assertions
- Loading branch information
Showing
5 changed files
with
239 additions
and
2 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
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,42 @@ | ||
- // MIR for `generic` before InstCombine | ||
+ // MIR for `generic` after InstCombine | ||
|
||
fn generic() -> () { | ||
let mut _0: (); // return place in scope 0 at $DIR/intrinsic_asserts.rs:+0:21: +0:21 | ||
let _1: (); // in scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:46 | ||
let _2: (); // in scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:47 | ||
let _3: (); // in scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:60 | ||
|
||
bb0: { | ||
StorageLive(_1); // scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:46 | ||
_1 = assert_inhabited::<T>() -> bb1; // scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:46 | ||
// mir::Constant | ||
// + span: $DIR/intrinsic_asserts.rs:25:5: 25:44 | ||
// + literal: Const { ty: extern "rust-intrinsic" fn() {assert_inhabited::<T>}, val: Value(<ZST>) } | ||
} | ||
|
||
bb1: { | ||
StorageDead(_1); // scope 0 at $DIR/intrinsic_asserts.rs:+1:46: +1:47 | ||
StorageLive(_2); // scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:47 | ||
_2 = assert_zero_valid::<T>() -> bb2; // scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:47 | ||
// mir::Constant | ||
// + span: $DIR/intrinsic_asserts.rs:26:5: 26:45 | ||
// + literal: Const { ty: extern "rust-intrinsic" fn() {assert_zero_valid::<T>}, val: Value(<ZST>) } | ||
} | ||
|
||
bb2: { | ||
StorageDead(_2); // scope 0 at $DIR/intrinsic_asserts.rs:+2:47: +2:48 | ||
StorageLive(_3); // scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:60 | ||
_3 = assert_mem_uninitialized_valid::<T>() -> bb3; // scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:60 | ||
// mir::Constant | ||
// + span: $DIR/intrinsic_asserts.rs:27:5: 27:58 | ||
// + literal: Const { ty: extern "rust-intrinsic" fn() {assert_mem_uninitialized_valid::<T>}, val: Value(<ZST>) } | ||
} | ||
|
||
bb3: { | ||
StorageDead(_3); // scope 0 at $DIR/intrinsic_asserts.rs:+3:60: +3:61 | ||
nop; // scope 0 at $DIR/intrinsic_asserts.rs:+0:21: +4:2 | ||
return; // scope 0 at $DIR/intrinsic_asserts.rs:+4:2: +4:2 | ||
} | ||
} | ||
|
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,47 @@ | ||
- // MIR for `panics` before InstCombine | ||
+ // MIR for `panics` after InstCombine | ||
|
||
fn panics() -> () { | ||
let mut _0: (); // return place in scope 0 at $DIR/intrinsic_asserts.rs:+0:17: +0:17 | ||
let _1: (); // in scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:50 | ||
let _2: (); // in scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:49 | ||
let _3: (); // in scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:62 | ||
|
||
bb0: { | ||
StorageLive(_1); // scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:50 | ||
- _1 = assert_inhabited::<Never>() -> bb1; // scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:50 | ||
+ _1 = assert_inhabited::<Never>(); // scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:50 | ||
// mir::Constant | ||
// + span: $DIR/intrinsic_asserts.rs:17:5: 17:48 | ||
// + literal: Const { ty: extern "rust-intrinsic" fn() {assert_inhabited::<Never>}, val: Value(<ZST>) } | ||
} | ||
|
||
bb1: { | ||
StorageDead(_1); // scope 0 at $DIR/intrinsic_asserts.rs:+1:50: +1:51 | ||
StorageLive(_2); // scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:49 | ||
- _2 = assert_zero_valid::<&u8>() -> bb2; // scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:49 | ||
+ _2 = assert_zero_valid::<&u8>(); // scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:49 | ||
// mir::Constant | ||
// + span: $DIR/intrinsic_asserts.rs:18:5: 18:47 | ||
// + user_ty: UserType(0) | ||
// + literal: Const { ty: extern "rust-intrinsic" fn() {assert_zero_valid::<&u8>}, val: Value(<ZST>) } | ||
} | ||
|
||
bb2: { | ||
StorageDead(_2); // scope 0 at $DIR/intrinsic_asserts.rs:+2:49: +2:50 | ||
StorageLive(_3); // scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:62 | ||
- _3 = assert_mem_uninitialized_valid::<&u8>() -> bb3; // scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:62 | ||
+ _3 = assert_mem_uninitialized_valid::<&u8>(); // scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:62 | ||
// mir::Constant | ||
// + span: $DIR/intrinsic_asserts.rs:19:5: 19:60 | ||
// + user_ty: UserType(1) | ||
// + literal: Const { ty: extern "rust-intrinsic" fn() {assert_mem_uninitialized_valid::<&u8>}, val: Value(<ZST>) } | ||
} | ||
|
||
bb3: { | ||
StorageDead(_3); // scope 0 at $DIR/intrinsic_asserts.rs:+3:62: +3:63 | ||
nop; // scope 0 at $DIR/intrinsic_asserts.rs:+0:17: +4:2 | ||
return; // scope 0 at $DIR/intrinsic_asserts.rs:+4:2: +4:2 | ||
} | ||
} | ||
|
45 changes: 45 additions & 0 deletions
45
tests/mir-opt/intrinsic_asserts.removable.InstCombine.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,45 @@ | ||
- // MIR for `removable` before InstCombine | ||
+ // MIR for `removable` after InstCombine | ||
|
||
fn removable() -> () { | ||
let mut _0: (); // return place in scope 0 at $DIR/intrinsic_asserts.rs:+0:20: +0:20 | ||
let _1: (); // in scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:47 | ||
let _2: (); // in scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:48 | ||
let _3: (); // in scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:61 | ||
|
||
bb0: { | ||
StorageLive(_1); // scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:47 | ||
- _1 = assert_inhabited::<()>() -> bb1; // scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:47 | ||
- // mir::Constant | ||
- // + span: $DIR/intrinsic_asserts.rs:7:5: 7:45 | ||
- // + literal: Const { ty: extern "rust-intrinsic" fn() {assert_inhabited::<()>}, val: Value(<ZST>) } | ||
+ goto -> bb1; // scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:47 | ||
} | ||
|
||
bb1: { | ||
StorageDead(_1); // scope 0 at $DIR/intrinsic_asserts.rs:+1:47: +1:48 | ||
StorageLive(_2); // scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:48 | ||
- _2 = assert_zero_valid::<u8>() -> bb2; // scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:48 | ||
- // mir::Constant | ||
- // + span: $DIR/intrinsic_asserts.rs:8:5: 8:46 | ||
- // + literal: Const { ty: extern "rust-intrinsic" fn() {assert_zero_valid::<u8>}, val: Value(<ZST>) } | ||
+ goto -> bb2; // scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:48 | ||
} | ||
|
||
bb2: { | ||
StorageDead(_2); // scope 0 at $DIR/intrinsic_asserts.rs:+2:48: +2:49 | ||
StorageLive(_3); // scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:61 | ||
- _3 = assert_mem_uninitialized_valid::<u8>() -> bb3; // scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:61 | ||
- // mir::Constant | ||
- // + span: $DIR/intrinsic_asserts.rs:9:5: 9:59 | ||
- // + literal: Const { ty: extern "rust-intrinsic" fn() {assert_mem_uninitialized_valid::<u8>}, val: Value(<ZST>) } | ||
+ goto -> bb3; // scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:61 | ||
} | ||
|
||
bb3: { | ||
StorageDead(_3); // scope 0 at $DIR/intrinsic_asserts.rs:+3:61: +3:62 | ||
nop; // scope 0 at $DIR/intrinsic_asserts.rs:+0:20: +4:2 | ||
return; // scope 0 at $DIR/intrinsic_asserts.rs:+4:2: +4:2 | ||
} | ||
} | ||
|
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,28 @@ | ||
#![crate_type = "lib"] | ||
#![feature(core_intrinsics)] | ||
|
||
// All these assertions pass, so all the intrinsic calls should be deleted. | ||
// EMIT_MIR intrinsic_asserts.removable.InstCombine.diff | ||
pub fn removable() { | ||
core::intrinsics::assert_inhabited::<()>(); | ||
core::intrinsics::assert_zero_valid::<u8>(); | ||
core::intrinsics::assert_mem_uninitialized_valid::<u8>(); | ||
} | ||
|
||
enum Never {} | ||
|
||
// These assertions all diverge, so their target blocks should become None. | ||
// EMIT_MIR intrinsic_asserts.panics.InstCombine.diff | ||
pub fn panics() { | ||
core::intrinsics::assert_inhabited::<Never>(); | ||
core::intrinsics::assert_zero_valid::<&u8>(); | ||
core::intrinsics::assert_mem_uninitialized_valid::<&u8>(); | ||
} | ||
|
||
// Whether or not these asserts pass isn't known, so they shouldn't be modified. | ||
// EMIT_MIR intrinsic_asserts.generic.InstCombine.diff | ||
pub fn generic<T>() { | ||
core::intrinsics::assert_inhabited::<T>(); | ||
core::intrinsics::assert_zero_valid::<T>(); | ||
core::intrinsics::assert_mem_uninitialized_valid::<T>(); | ||
} |