Lower to a memset(undef) when Rvalue::Repeat repeats uninit
This commit is contained in:
parent
43a2e9d2c7
commit
8e7d8ddffe
3 changed files with 66 additions and 4 deletions
21
tests/codegen/uninit-repeat-in-aggregate.rs
Normal file
21
tests/codegen/uninit-repeat-in-aggregate.rs
Normal file
|
@ -0,0 +1,21 @@
|
|||
//@ compile-flags: -Copt-level=3
|
||||
|
||||
#![crate_type = "lib"]
|
||||
|
||||
use std::mem::MaybeUninit;
|
||||
|
||||
// We need to make sure len is at offset 0, otherwise codegen needs an extra instruction
|
||||
#[repr(C)]
|
||||
pub struct SmallVec<T> {
|
||||
pub len: u64,
|
||||
pub arr: [MaybeUninit<T>; 24],
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @uninit_arr_via_const
|
||||
#[no_mangle]
|
||||
pub fn uninit_arr_via_const() -> SmallVec<String> {
|
||||
// CHECK-NEXT: start:
|
||||
// CHECK-NEXT: store i64 0,
|
||||
// CHECK-NEXT: ret
|
||||
SmallVec { len: 0, arr: [const { MaybeUninit::uninit() }; 24] }
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue