Skip to content

Combining place projections in MIR makes codegen forget that NonNull is nonnull #111518

Open

Description

@saethlin

In #105808 I am adding a hack to prevent combining place projections where one of assignments that would be optimized away contains a niche. This is because optimizing Vec::as_ptr to a single MIR statement that just loads the underlying *const T makes us lose the nonnull LLVM attribute in codegen.

(I am opening this issue early so I can link to it in the PR)

Activity

  1. scottmcm commented on May 12, 2023

    @scottmcm
    Member

    The reminds me of why I dislike the "it's just a field" approach in the first place (and thus I dislike rust-lang/rfcs#3334), and reminds me of similar problems that repr(simd) hit with looking at fields (see https://rust-lang.zulipchat.com/#narrow/stream/257879-project-portable-simd/topic/splat.20no.20longer.20compiles.20for.20release.20builds/near/351948961).

    So maybe we should use the same approach that repr(simd) is moving towards: just disallow place projections to the inner field entirely for such types. That makes this issue irrelevant -- as the project isn't there to be combined -- and the niche support ends up in the transmutes and such instead, where it sees the different types properly instead of just projections.

  2. added
    A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html
    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
    A-codegenArea: Code generation
    on May 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-codegenArea: Code generation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions