Skip to content

Array-as-Immediate array ABI is missing noundef parameter metadata #123183

Open
@scottmcm

Description

@scottmcm

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-codegenArea: Code generationC-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions