-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #105582 - saethlin:instcombine-assert-inhabited, r=cjgi…
…llot InstCombine away intrinsic validity assertions This optimization (currently) fires 246 times on the standard library. It seems to fire hardly at all on the big crates in the benchmark suite. Interesting.
- Loading branch information
Showing
12 changed files
with
276 additions
and
16 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
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
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
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
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 | ||
} | ||
} | ||
|
Oops, something went wrong.