FileCheck intrinsic_asserts.

This commit is contained in:
Camille GILLOT 2023-10-16 19:30:09 +00:00
parent ddc328c2f1
commit f856247cc9
6 changed files with 46 additions and 37 deletions

View File

@ -1,12 +0,0 @@
// skip-filecheck
// compile-flags: --crate-type=lib
// unit-test: InstSimplify
#![feature(core_intrinsics)]
// Want to make sure this assertion isn't compiled away in generic code.
// EMIT_MIR dont_yeet_assert.generic.InstSimplify.diff
pub fn generic<T>() {
core::intrinsics::assert_mem_uninitialized_valid::<&T>();
}

View File

@ -8,25 +8,25 @@
let _3: (); let _3: ();
bb0: { bb0: {
nop; StorageLive(_1);
_1 = assert_inhabited::<T>() -> [return: bb1, unwind unreachable]; _1 = assert_inhabited::<T>() -> [return: bb1, unwind unreachable];
} }
bb1: { bb1: {
nop; StorageDead(_1);
nop; StorageLive(_2);
_2 = assert_zero_valid::<T>() -> [return: bb2, unwind unreachable]; _2 = assert_zero_valid::<T>() -> [return: bb2, unwind unreachable];
} }
bb2: { bb2: {
nop; StorageDead(_2);
nop; StorageLive(_3);
_3 = assert_mem_uninitialized_valid::<T>() -> [return: bb3, unwind unreachable]; _3 = assert_mem_uninitialized_valid::<T>() -> [return: bb3, unwind unreachable];
} }
bb3: { bb3: {
nop; StorageDead(_3);
nop; _0 = const ();
return; return;
} }
} }

View File

@ -1,7 +1,7 @@
- // MIR for `generic` before InstSimplify - // MIR for `generic_ref` before InstSimplify
+ // MIR for `generic` after InstSimplify + // MIR for `generic_ref` after InstSimplify
fn generic() -> () { fn generic_ref() -> () {
let mut _0: (); let mut _0: ();
let _1: (); let _1: ();

View File

@ -8,28 +8,28 @@
let _3: (); let _3: ();
bb0: { bb0: {
nop; StorageLive(_1);
- _1 = assert_inhabited::<Never>() -> [return: bb1, unwind unreachable]; - _1 = assert_inhabited::<Never>() -> [return: bb1, unwind unreachable];
+ _1 = assert_inhabited::<Never>() -> unwind unreachable; + _1 = assert_inhabited::<Never>() -> unwind unreachable;
} }
bb1: { bb1: {
nop; StorageDead(_1);
nop; StorageLive(_2);
- _2 = assert_zero_valid::<&u8>() -> [return: bb2, unwind unreachable]; - _2 = assert_zero_valid::<&u8>() -> [return: bb2, unwind unreachable];
+ _2 = assert_zero_valid::<&u8>() -> unwind unreachable; + _2 = assert_zero_valid::<&u8>() -> unwind unreachable;
} }
bb2: { bb2: {
nop; StorageDead(_2);
nop; StorageLive(_3);
- _3 = assert_mem_uninitialized_valid::<&u8>() -> [return: bb3, unwind unreachable]; - _3 = assert_mem_uninitialized_valid::<&u8>() -> [return: bb3, unwind unreachable];
+ _3 = assert_mem_uninitialized_valid::<&u8>() -> unwind unreachable; + _3 = assert_mem_uninitialized_valid::<&u8>() -> unwind unreachable;
} }
bb3: { bb3: {
nop; StorageDead(_3);
nop; _0 = const ();
return; return;
} }
} }

View File

@ -8,28 +8,28 @@
let _3: (); let _3: ();
bb0: { bb0: {
nop; StorageLive(_1);
- _1 = assert_inhabited::<()>() -> [return: bb1, unwind unreachable]; - _1 = assert_inhabited::<()>() -> [return: bb1, unwind unreachable];
+ goto -> bb1; + goto -> bb1;
} }
bb1: { bb1: {
nop; StorageDead(_1);
nop; StorageLive(_2);
- _2 = assert_zero_valid::<u8>() -> [return: bb2, unwind unreachable]; - _2 = assert_zero_valid::<u8>() -> [return: bb2, unwind unreachable];
+ goto -> bb2; + goto -> bb2;
} }
bb2: { bb2: {
nop; StorageDead(_2);
nop; StorageLive(_3);
- _3 = assert_mem_uninitialized_valid::<u8>() -> [return: bb3, unwind unreachable]; - _3 = assert_mem_uninitialized_valid::<u8>() -> [return: bb3, unwind unreachable];
+ goto -> bb3; + goto -> bb3;
} }
bb3: { bb3: {
nop; StorageDead(_3);
nop; _0 = const ();
return; return;
} }
} }

View File

@ -1,10 +1,15 @@
// skip-filecheck // unit-test: InstSimplify
#![crate_type = "lib"] #![crate_type = "lib"]
#![feature(core_intrinsics)] #![feature(core_intrinsics)]
// All these assertions pass, so all the intrinsic calls should be deleted. // All these assertions pass, so all the intrinsic calls should be deleted.
// EMIT_MIR intrinsic_asserts.removable.InstSimplify.diff // EMIT_MIR intrinsic_asserts.removable.InstSimplify.diff
pub fn removable() { pub fn removable() {
// CHECK-LABEL: fn removable(
// CHECK-NOT: assert_inhabited
// CHECK-NOT: assert_zero_valid
// CHECK-NOT: assert_mem_uninitialized_valid
core::intrinsics::assert_inhabited::<()>(); core::intrinsics::assert_inhabited::<()>();
core::intrinsics::assert_zero_valid::<u8>(); core::intrinsics::assert_zero_valid::<u8>();
core::intrinsics::assert_mem_uninitialized_valid::<u8>(); core::intrinsics::assert_mem_uninitialized_valid::<u8>();
@ -15,6 +20,10 @@ enum Never {}
// These assertions all diverge, so their target blocks should become None. // These assertions all diverge, so their target blocks should become None.
// EMIT_MIR intrinsic_asserts.panics.InstSimplify.diff // EMIT_MIR intrinsic_asserts.panics.InstSimplify.diff
pub fn panics() { pub fn panics() {
// CHECK-LABEL: fn panics(
// CHECK: assert_inhabited::<Never>() -> unwind
// CHECK: assert_zero_valid::<&u8>() -> unwind
// CHECK: assert_mem_uninitialized_valid::<&u8>() -> unwind
core::intrinsics::assert_inhabited::<Never>(); core::intrinsics::assert_inhabited::<Never>();
core::intrinsics::assert_zero_valid::<&u8>(); core::intrinsics::assert_zero_valid::<&u8>();
core::intrinsics::assert_mem_uninitialized_valid::<&u8>(); core::intrinsics::assert_mem_uninitialized_valid::<&u8>();
@ -23,7 +32,19 @@ pub fn panics() {
// Whether or not these asserts pass isn't known, so they shouldn't be modified. // Whether or not these asserts pass isn't known, so they shouldn't be modified.
// EMIT_MIR intrinsic_asserts.generic.InstSimplify.diff // EMIT_MIR intrinsic_asserts.generic.InstSimplify.diff
pub fn generic<T>() { pub fn generic<T>() {
// CHECK-LABEL: fn generic(
// CHECK: assert_inhabited::<T>() -> [return:
// CHECK: assert_zero_valid::<T>() -> [return:
// CHECK: assert_mem_uninitialized_valid::<T>() -> [return:
core::intrinsics::assert_inhabited::<T>(); core::intrinsics::assert_inhabited::<T>();
core::intrinsics::assert_zero_valid::<T>(); core::intrinsics::assert_zero_valid::<T>();
core::intrinsics::assert_mem_uninitialized_valid::<T>(); core::intrinsics::assert_mem_uninitialized_valid::<T>();
} }
// Whether or not these asserts pass isn't known, so they shouldn't be modified.
// EMIT_MIR intrinsic_asserts.generic_ref.InstSimplify.diff
pub fn generic_ref<T>() {
// CHECK-LABEL: fn generic_ref(
// CHECK: assert_mem_uninitialized_valid::<&T>() -> [return:
core::intrinsics::assert_mem_uninitialized_valid::<&T>();
}