Add regression test for option initialization
This commit is contained in:
parent
88ab2d8acb
commit
aec51564a5
1 changed files with 28 additions and 0 deletions
|
@ -63,6 +63,34 @@ pub fn nonzero_integer_array() {
|
|||
opaque(&x);
|
||||
}
|
||||
|
||||
const N: usize = 100;
|
||||
|
||||
// FIXME: The two bytes of the u16 are the same, so we should
|
||||
// just use memset, too.
|
||||
// CHECK-LABEL: @u16_init_one_bytes
|
||||
#[no_mangle]
|
||||
pub fn u16_init_one_bytes() -> [u16; N] {
|
||||
// CHECK-NOT: select
|
||||
// CHECK: br
|
||||
// CHECK-NOT: switch
|
||||
// CHECK: icmp
|
||||
// CHECK-NOT: call void @llvm.memset.p0
|
||||
[const { u16::from_be_bytes([1, 1]) }; N]
|
||||
}
|
||||
|
||||
// FIXME: undef bytes can just be initialized with the same value as the
|
||||
// defined bytes, if the defines bytes are all the same.
|
||||
// CHECK-LABEL: @option_none_init
|
||||
#[no_mangle]
|
||||
pub fn option_none_init() -> [Option<u8>; N] {
|
||||
// CHECK-NOT: select
|
||||
// CHECK: br label %repeat_loop_header{{.*}}
|
||||
// CHECK-NOT: switch
|
||||
// CHECK: icmp
|
||||
// CHECK-NOT: call void @llvm.memset.p0
|
||||
[None; N]
|
||||
}
|
||||
|
||||
// Use an opaque function to prevent rustc from removing useless drops.
|
||||
#[inline(never)]
|
||||
pub fn opaque(_: impl Sized) {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue