Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
saethlin opened this issue May 12, 2023 · 1 comment
Labels
A-codegen Area: Code generation A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-mir Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html

Comments

@saethlin
Copy link
Member

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)

@scottmcm
Copy link
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.

@jyn514 jyn514 added A-mir Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-codegen Area: Code generation labels May 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-mir Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html
Projects
None yet
Development

No branches or pull requests

3 participants