x86: Correctly pass larger structs/types in registers with -Zregparm by sulix · Pull Request #147628 · rust-lang/rust

@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

Oct 13, 2025

@sulix sulix mentioned this pull request

Oct 13, 2025

This was referenced

Oct 13, 2025

@rustbot rustbot added S-waiting-on-author

Status: This is awaiting some action (such as code changes or more information) from the author.

and removed S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

labels

Oct 13, 2025

@sulix

The -Zregparm option for 32-bit x86 modifies the calling convention to pass
a number of arguments in registers instead of on the stack. (This is primarily
used by the Linux kernel.)

Currently, rustc will only pass integers of size <= 32 bits in registers, but
gcc (and clang) will pass larger integers (e.g., 64-bit integers) across two
registers if possible. This is not the case with fastcall/vectorcall.

Note that gcc/clang with -mregparm will also pass some structs in registers:
this patch does not attempt to fix that case.