Skip to content

Emit noundef on small aggregate returns in the x86 Win32 ABI - #160368

Open
Vastargazing wants to merge 1 commit into
rust-lang:mainfrom
Vastargazing:abi-noundef-foreign-win32
Open

Emit noundef on small aggregate returns in the x86 Win32 ABI#160368
Vastargazing wants to merge 1 commit into
rust-lang:mainfrom
Vastargazing:abi-noundef-foreign-win32

Conversation

@Vastargazing

@Vastargazing Vastargazing commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #160313

Now that ArgAbi::cast_to_maybe_noundef is in place, this PR switches the x86 Win32 (MSVC) small-aggregate return casts over to it.

With this change, returns whose layout is provably free of uninit bytes keep noundef, while padded layouts correctly omit it.

As discussed on Zulip, this is the foreign-ABI follow-up split out from the original PR.

Added tests/codegen-llvm/abi-noundef-cast-win32.rs covering both positive (unpadded struct -> noundef) and negative (padded struct -> no noundef) cases on i686-pc-windows-msvc.

r? @RalfJung

The x86 Win32 (MSVC) ABI returns small aggregates in an integer register via
`cast_to`, which drops the argument attributes -- so these returns never carried
`noundef`, unlike scalars, which get it from `arg_attrs_for_rust_scalar`.

Switch those casts to `cast_to_maybe_noundef` so a return whose layout is provably
free of uninit bytes gets `noundef`, while padded layouts correctly omit it.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 2, 2026
@rustbot

rustbot commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

RalfJung is not on the review rotation at the moment.
They may take a while to respond.

@RalfJung

RalfJung commented Aug 2, 2026

Copy link
Copy Markdown
Member

I'm not sure what is special about win32 that we would only do this there. Anyway evaluating actual ABI adjustments is outside what I can do.
r? @workingjubilee

@rustbot rustbot assigned workingjubilee and unassigned RalfJung Aug 2, 2026
@rustbot

rustbot commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

workingjubilee is currently at their maximum review capacity.
They may take a while to respond.

@Vastargazing

Copy link
Copy Markdown
Contributor Author

Yep, win32 was just an easy first target for the cast_to_maybe_noundef helper, nothing special about it. No strong preference on the rest: small per-arch PRs, or fold them into this one, whatever's easiest to review. No rush, happy to follow your lead 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants