2024-07-27 01:36:17 -05:00
|
|
|
//@ test-mir-pass: InstSimplify-after-simplifycfg
|
2023-10-16 14:30:09 -05:00
|
|
|
|
2022-12-11 20:07:33 -06:00
|
|
|
#![crate_type = "lib"]
|
|
|
|
#![feature(core_intrinsics)]
|
|
|
|
|
|
|
|
// All these assertions pass, so all the intrinsic calls should be deleted.
|
2024-07-27 01:36:17 -05:00
|
|
|
// EMIT_MIR intrinsic_asserts.removable.InstSimplify-after-simplifycfg.diff
|
2022-12-11 20:07:33 -06:00
|
|
|
pub fn removable() {
|
2023-10-16 14:30:09 -05:00
|
|
|
// CHECK-LABEL: fn removable(
|
|
|
|
// CHECK-NOT: assert_inhabited
|
|
|
|
// CHECK-NOT: assert_zero_valid
|
|
|
|
// CHECK-NOT: assert_mem_uninitialized_valid
|
2022-12-11 20:07:33 -06:00
|
|
|
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.
|
2024-07-27 01:36:17 -05:00
|
|
|
// EMIT_MIR intrinsic_asserts.panics.InstSimplify-after-simplifycfg.diff
|
2022-12-11 20:07:33 -06:00
|
|
|
pub fn panics() {
|
2023-10-16 14:30:09 -05:00
|
|
|
// CHECK-LABEL: fn panics(
|
|
|
|
// CHECK: assert_inhabited::<Never>() -> unwind
|
|
|
|
// CHECK: assert_zero_valid::<&u8>() -> unwind
|
|
|
|
// CHECK: assert_mem_uninitialized_valid::<&u8>() -> unwind
|
2022-12-11 20:07:33 -06:00
|
|
|
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.
|
2024-07-27 01:36:17 -05:00
|
|
|
// EMIT_MIR intrinsic_asserts.generic.InstSimplify-after-simplifycfg.diff
|
2022-12-11 20:07:33 -06:00
|
|
|
pub fn generic<T>() {
|
2023-10-16 14:30:09 -05:00
|
|
|
// CHECK-LABEL: fn generic(
|
|
|
|
// CHECK: assert_inhabited::<T>() -> [return:
|
|
|
|
// CHECK: assert_zero_valid::<T>() -> [return:
|
|
|
|
// CHECK: assert_mem_uninitialized_valid::<T>() -> [return:
|
2022-12-11 20:07:33 -06:00
|
|
|
core::intrinsics::assert_inhabited::<T>();
|
|
|
|
core::intrinsics::assert_zero_valid::<T>();
|
|
|
|
core::intrinsics::assert_mem_uninitialized_valid::<T>();
|
|
|
|
}
|
2023-10-16 14:30:09 -05:00
|
|
|
|
|
|
|
// Whether or not these asserts pass isn't known, so they shouldn't be modified.
|
2024-07-27 01:36:17 -05:00
|
|
|
// EMIT_MIR intrinsic_asserts.generic_ref.InstSimplify-after-simplifycfg.diff
|
2023-10-16 14:30:09 -05:00
|
|
|
pub fn generic_ref<T>() {
|
|
|
|
// CHECK-LABEL: fn generic_ref(
|
|
|
|
// CHECK: assert_mem_uninitialized_valid::<&T>() -> [return:
|
|
|
|
core::intrinsics::assert_mem_uninitialized_valid::<&T>();
|
|
|
|
}
|