Skip to content

callconv: mips64: Match GCC for alignment of 16-byte scalars - #163653

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
Gelbpunkt:mips64-16-byte-scalar-alignment
Oct 4, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
Gelbpunkt:mips64-16-byte-scalar-alignment

Conversation

@Gelbpunkt

@Gelbpunkt Gelbpunkt commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Previously, the calling convention code would not register align 16-byte scalars to even/odd register pairs.

It seems like GCC does not differentiate between integer and floating point scalars when calculating whether a scalar is aligned. To our understanding, the MIPS n64 ABI 1 would require doing so for integer and floating point parameters respectively 2, but GCC violates the specification here and will happily pass an f128 in an odd-even floating point register pair and therefore sometimes shift following integer arguments due to unnecessary (if the spec is to be believed) inserted integer padding.

Fixes #161679

r? folkertdev
cc @beetrees

Footnotes

  1. https://web.archive.org/web/20160121005457/http://techpubs.sgi.com/library/manuals/2000/007-2816-005/pdf/007-2816-005.pdf#page=20 ↩

  2. "This requires that they be passed in even-odd floating point register pairs, even if doing so requires skipping a register parameter" ↩

@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 2, 2026
Previously, the calling convention code would not register align 16-byte
scalars to even/odd register pairs.

It seems like GCC does not differentiate between integer and floating
point scalars when calculating whether a scalar is aligned. To our
understanding, the MIPS n64 ABI [1] would require doing so for integer and
floating point parameters respectively [2], but GCC violates the
specification here and will happily pass an f128 in an odd-even floating
point register pair and therefore sometimes shift following integer
arguments due to unnecessary (if the spec is to be believed) inserted integer
padding.

[1]: https://web.archive.org/web/20160121005457/http://techpubs.sgi.com/library/manuals/2000/007-2816-005/pdf/007-2816-005.pdf#page=20
[2]: "This requires that they be passed in even-odd floating point
register pairs, even if doing so requires skipping a register parameter"
@Gelbpunkt
Gelbpunkt force-pushed the mips64-16-byte-scalar-alignment branch from 6125daf to 22067c7 Compare October 2, 2026 16:19

@folkertdev folkertdev left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've confirmed that this change is consistent with GCC and Clang 24 on both mips64 and mips64el

@bors r+ rollup

View changes since this review

@rust-bors

rust-bors Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 22067c7 has been approved by folkertdev

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 4, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 4, 2026
…r=folkertdev

callconv: mips64: Match GCC for alignment of 16-byte scalars

Previously, the calling convention code would not register align 16-byte scalars to even/odd register pairs.

It seems like GCC does not differentiate between integer and floating point scalars when calculating whether a scalar is aligned. To our understanding, the MIPS n64 ABI [^1] would require doing so for integer and floating point parameters respectively [^2], but GCC violates the specification here and will happily pass an f128 in an odd-even floating point register pair and therefore sometimes shift following integer arguments due to unnecessary (if the spec is to be believed) inserted integer padding.

[^1]: https://web.archive.org/web/20160121005457/http://techpubs.sgi.com/library/manuals/2000/007-2816-005/pdf/007-2816-005.pdf#page=20
[^2]: "This requires that they be passed in even-odd floating point register pairs, even if doing so requires skipping a register parameter"

Fixes #161679

r? folkertdev
cc @beetrees
rust-bors Bot pushed a commit that referenced this pull request Oct 4, 2026
…uwer

Rollup of 6 pull requests

Successful merges:

 - #161491 (Rip out old solver coherence)
 - #163223 (regression test for async handler normalization ICE)
 - #163653 (callconv: mips64: Match GCC for alignment of 16-byte scalars)
 - #163742 (Add the `movdir64b` and `movdiri` x86 target features)
 - #163752 (Revert "implement PartialEq<VecDeque<U>> for Vec<T>, &[T], &mut [T], [T; N], &[T; N] and &mut [T; N]")
 - #163755 (fix -Z track-diagnostics for errors and lints emitted from rustc_attr_parsing)
rust-bors Bot pushed a commit that referenced this pull request Oct 4, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - #161491 (Rip out old solver coherence)
 - #163533 (Run cg_gcc tests with the correct compiler)
 - #163223 (regression test for async handler normalization ICE)
 - #163367 (simplify rustc_log a bit)
 - #163622 (x86: c-variadic functions don't use registers with `-Zregparm`)
 - #163653 (callconv: mips64: Match GCC for alignment of 16-byte scalars)
 - #163665 (Parser: Refactor & better document `should_continue_as_assoc_expr` & `can_continue_expr_unambiguously`)
 - #163742 (Add the `movdir64b` and `movdiri` x86 target features)
 - #163752 (Revert "implement PartialEq<VecDeque<U>> for Vec<T>, &[T], &mut [T], [T; N], &[T; N] and &mut [T; N]")
@rust-bors
rust-bors Bot merged commit d7d462d into rust-lang:main Oct 4, 2026
14 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 4, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 4, 2026
Rollup merge of #163653 - Gelbpunkt:mips64-16-byte-scalar-alignment, r=folkertdev

callconv: mips64: Match GCC for alignment of 16-byte scalars

Previously, the calling convention code would not register align 16-byte scalars to even/odd register pairs.

It seems like GCC does not differentiate between integer and floating point scalars when calculating whether a scalar is aligned. To our understanding, the MIPS n64 ABI [^1] would require doing so for integer and floating point parameters respectively [^2], but GCC violates the specification here and will happily pass an f128 in an odd-even floating point register pair and therefore sometimes shift following integer arguments due to unnecessary (if the spec is to be believed) inserted integer padding.

[^1]: https://web.archive.org/web/20160121005457/http://techpubs.sgi.com/library/manuals/2000/007-2816-005/pdf/007-2816-005.pdf#page=20
[^2]: "This requires that they be passed in even-odd floating point register pairs, even if doing so requires skipping a register parameter"

Fixes #161679

r? folkertdev
cc @beetrees
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

mips64 ABI bug passing 16-byte aligned scalars

3 participants