Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
FileCheck intrinsic_asserts.
  • Loading branch information
cjgillot committed Oct 19, 2023
commit f856247cc94dd3c3fcffb5222c54a22e6521160f
12 changes: 0 additions & 12 deletions tests/mir-opt/dont_yeet_assert.rs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@
let _3: ();

bb0: {
nop;
StorageLive(_1);
_1 = assert_inhabited::<T>() -> [return: bb1, unwind unreachable];
}

bb1: {
nop;
nop;
StorageDead(_1);
StorageLive(_2);
_2 = assert_zero_valid::<T>() -> [return: bb2, unwind unreachable];
}

bb2: {
nop;
nop;
StorageDead(_2);
StorageLive(_3);
_3 = assert_mem_uninitialized_valid::<T>() -> [return: bb3, unwind unreachable];
}

bb3: {
nop;
nop;
StorageDead(_3);
_0 = const ();
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- // MIR for `generic` before InstSimplify
+ // MIR for `generic` after InstSimplify
- // MIR for `generic_ref` before InstSimplify
+ // MIR for `generic_ref` after InstSimplify

fn generic() -> () {
fn generic_ref() -> () {
let mut _0: ();
let _1: ();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@
let _3: ();

bb0: {
nop;
StorageLive(_1);
- _1 = assert_inhabited::<Never>() -> [return: bb1, unwind unreachable];
+ _1 = assert_inhabited::<Never>() -> unwind unreachable;
}

bb1: {
nop;
nop;
StorageDead(_1);
StorageLive(_2);
- _2 = assert_zero_valid::<&u8>() -> [return: bb2, unwind unreachable];
+ _2 = assert_zero_valid::<&u8>() -> unwind unreachable;
}

bb2: {
nop;
nop;
StorageDead(_2);
StorageLive(_3);
- _3 = assert_mem_uninitialized_valid::<&u8>() -> [return: bb3, unwind unreachable];
+ _3 = assert_mem_uninitialized_valid::<&u8>() -> unwind unreachable;
}

bb3: {
nop;
nop;
StorageDead(_3);
_0 = const ();
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@
let _3: ();

bb0: {
nop;
StorageLive(_1);
- _1 = assert_inhabited::<()>() -> [return: bb1, unwind unreachable];
+ goto -> bb1;
}

bb1: {
nop;
nop;
StorageDead(_1);
StorageLive(_2);
- _2 = assert_zero_valid::<u8>() -> [return: bb2, unwind unreachable];
+ goto -> bb2;
}

bb2: {
nop;
nop;
StorageDead(_2);
StorageLive(_3);
- _3 = assert_mem_uninitialized_valid::<u8>() -> [return: bb3, unwind unreachable];
+ goto -> bb3;
}

bb3: {
nop;
nop;
StorageDead(_3);
_0 = const ();
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
// skip-filecheck
// unit-test: InstSimplify

#![crate_type = "lib"]
#![feature(core_intrinsics)]

// All these assertions pass, so all the intrinsic calls should be deleted.
// EMIT_MIR intrinsic_asserts.removable.InstSimplify.diff
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_zero_valid::<u8>();
core::intrinsics::assert_mem_uninitialized_valid::<u8>();
Expand All @@ -15,6 +20,10 @@ enum Never {}
// These assertions all diverge, so their target blocks should become None.
// EMIT_MIR intrinsic_asserts.panics.InstSimplify.diff
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_zero_valid::<&u8>();
core::intrinsics::assert_mem_uninitialized_valid::<&u8>();
Expand All @@ -23,7 +32,19 @@ pub fn panics() {
// Whether or not these asserts pass isn't known, so they shouldn't be modified.
// EMIT_MIR intrinsic_asserts.generic.InstSimplify.diff
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_zero_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>();
}