Add a MIR test for align_of_val on a slice
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
- // MIR for `of_val_slice` before InstSimplify-after-simplifycfg
|
||||
+ // MIR for `of_val_slice` after InstSimplify-after-simplifycfg
|
||||
|
||||
fn of_val_slice(_1: &[T]) -> usize {
|
||||
debug slice => _1;
|
||||
let mut _0: usize;
|
||||
let mut _2: *const [T];
|
||||
|
||||
bb0: {
|
||||
StorageLive(_2);
|
||||
_2 = &raw const (*_1);
|
||||
_0 = std::intrinsics::align_of_val::<[T]>(move _2) -> [return: bb1, unwind unreachable];
|
||||
}
|
||||
|
||||
bb1: {
|
||||
StorageDead(_2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
13
tests/mir-opt/instsimplify/align_of_slice.rs
Normal file
13
tests/mir-opt/instsimplify/align_of_slice.rs
Normal file
@@ -0,0 +1,13 @@
|
||||
//@ test-mir-pass: InstSimplify-after-simplifycfg
|
||||
//@ needs-unwind
|
||||
|
||||
#![crate_type = "lib"]
|
||||
#![feature(core_intrinsics)]
|
||||
|
||||
// EMIT_MIR align_of_slice.of_val_slice.InstSimplify-after-simplifycfg.diff
|
||||
pub fn of_val_slice<T>(slice: &[T]) -> usize {
|
||||
// CHECK-LABEL: fn of_val_slice(_1: &[T])
|
||||
// CHECK: _2 = &raw const (*_1);
|
||||
// CHECK: _0 = std::intrinsics::align_of_val::<[T]>(move _2)
|
||||
unsafe { core::intrinsics::align_of_val(slice) }
|
||||
}
|
||||
Reference in New Issue
Block a user