Skip to content

Optimization regression: array argument somehow produces null check? #139415

@alex

Description

@alex

Minimal reproducer:

#[no_mangle] pub fn f1(v: [&mut usize; 1]) { for x in v { *x += 1; } }

Results in:

f1:  test rdi, rdi  je .LBB0_2  inc qword ptr [rdi] .LBB0_2:  ret

Rust's semantics don't allow v to ever be NULL! I don't know where the test rdi, rdi is coming from!

This regressed between 1.78 and 1.79.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ABIArea: Concerning the application binary interface (ABI)A-codegenArea: Code generationC-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchI-slowIssue: Problems and improvements with respect to performance of generated code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions