codegen: skip stores for entirely-uninit constant aggregate fields#157797
codegen: skip stores for entirely-uninit constant aggregate fields#157797glandium wants to merge 1 commit into
Conversation
|
r? @jackh726 rustbot has assigned @jackh726. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Uhh...not code I'm familiar with. Let's see if a reroll helps. @rustbot reroll |
|
@rustbot reroll |
|
@rustbot reroll |
|
Reminder, once the PR becomes ready for a review, use |
|
|
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This comment has been minimized.
This comment has been minimized.
…constants MIR GVN propagates MaybeUninit::uninit() as `const <uninit>` in aggregate constructions and codegen emits a memcpy from an `[N x i8] undef` global for each such field, which LLVM materializes as zero-initialization. Instead of special-casing `all_bytes_uninit` at each call site, add a new `OperandValue::Uninit` variant that `eval_mir_constant_to_operand` returns for any all-bytes-uninit constant. `store_with_flags` is a no-op for this variant, so the fix applies uniformly across `Rvalue::Use`, `Rvalue::Repeat`, and `Rvalue::Aggregate` without per-site checks. The variant propagates through field extraction and transmutes, and is handled appropriately at the remaining call sites (function arguments, discriminant reads, debug info, etc.).
|
The job Click to see the possible cause of the failure (guessed by this bot) |
MIR GVN (since #147827) propagates MaybeUninit::uninit() as
const <uninit>in aggregate constructions. Without this fix, codegen would emit a memcpy from an[N x i8] undefglobal for each such field, which LLVM materializes as zero-initialization.This mirrors the existing
all_bytes_uninitskip already present forRvalue::Use(added in #147827) into theRvalue::Aggregatefield loop.Fixes: #157743