Today, these
#[no_mangle]
pub fn replace_short_array_1(r: &mut [u32; 1], v: [u32; 1]) -> [u32; 1] { … }
#[no_mangle]
pub fn replace_short_array_2(r: &mut [u32; 2], v: [u32; 2]) -> [u32; 2] { … }
give https://play.rust-lang.org/?version=nightly&mode=release&edition=2021&gist=084e57540370e8a6a2c51dd98053396a
define i32 @replace_short_array_1(ptr noalias nocapture noundef align 4 dereferenceable(4) %r, i32 %0) unnamed_addr #0 { … }
define i64 @replace_short_array_2(ptr noalias nocapture noundef align 4 dereferenceable(8) %r, i64 %0) unnamed_addr #0 { … }
Note specifically how they have i32 %0 and i64 %0 -- that means we're not telling LLVM that the array must be initialized (non-undef and non-poison).
#106294 did this for normal scalars. For example if you change that first one to
#[no_mangle]
pub fn replace_short_array_1_alt(r: &mut [u32; 1], v: u32) -> [u32; 1] {
std::mem::replace(r, [v])
}
then you correctly get i32 noundef %v.
It looks like it was just missed in some of the trickier ABI cases.
Today, these
give https://play.rust-lang.org/?version=nightly&mode=release&edition=2021&gist=084e57540370e8a6a2c51dd98053396a
Note specifically how they have
i32 %0andi64 %0-- that means we're not telling LLVM that the array must be initialized (non-undef and non-poison).#106294 did this for normal scalars. For example if you change that first one to
then you correctly get
i32 noundef %v.It looks like it was just missed in some of the trickier ABI cases.