1
Fork 0

Lower to a memset(undef) when Rvalue::Repeat repeats uninit

This commit is contained in:
Ben Kimock 2025-03-17 21:29:07 -04:00
parent 43a2e9d2c7
commit 8e7d8ddffe
3 changed files with 66 additions and 4 deletions

View 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] }
}