-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Box::new(uninitialized) creates a big alloca #58201
Comments
Feels like an LLVM limitation to me. It should be replacing the |
For reference: https://rust.godbolt.org/z/6ea0aL LLVM is capable of optimizing a memcpy of undef alloca away, this just runs into the usual limitation that all of memcpyopt doesn't work across BBs. |
This is such a long-standing issue. Seems like it might be wise to have someone working on fixing this. |
@arielb1 Someone has already worked on this, see https://reviews.llvm.org/D38374. It's a bit hard to track, but unfortunately this got reverted again (multiple times). I suspect that this is only going to get really resolved once memcpyopt moves to memssa -- which someone has also worked on in the past (https://reviews.llvm.org/D26739), but which never really went anywhere. |
The alloca and memcpy are no longer present on nightly, as a result of #82806. |
The FIXME in the test is still there, needs a test. |
The following code
generates some really awful LLVM IR:
The same happens with
std::mem::MaybeUninit::uninitialized()
.Cc @arielb1, who made me write these tests, and @rust-lang/wg-codegen
The text was updated successfully, but these errors were encountered: