Skip to content

Fix Hexagon ABI calling convention for small aggregates#151572

Merged
rust-bors[bot] merged 2 commits intorust-lang:mainfrom
androm3da:bcain/abi_cconv
Mar 12, 2026
Merged

Fix Hexagon ABI calling convention for small aggregates#151572
rust-bors[bot] merged 2 commits intorust-lang:mainfrom
androm3da:bcain/abi_cconv

Conversation

@androm3da
Copy link
Contributor

Small structs (<= 64 bits) were being passed with their fields split into separate arguments instead of being packed into register-sized chunks. This caused ABI mismatches.

The fix properly casts small aggregates to consecutive register-sized chunks using Uniform::consecutive(), matching the Hexagon C ABI where small structs are packed into R1:0 register pair.

This fixes tests like extern-pass-TwoU16s.rs and extern-pass-TwoU8s.rs.

Small structs (<= 64 bits) were being passed with their fields split
into separate arguments instead of being packed into register-sized
chunks. This caused ABI mismatches.

The fix properly casts small aggregates to consecutive register-sized
chunks using Uniform::consecutive(), matching the Hexagon C ABI where
small structs are packed into R1:0 register pair.

This fixes tests like extern-pass-TwoU16s.rs and extern-pass-TwoU8s.rs.
@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 Jan 24, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 24, 2026

r? @BoxyUwU

rustbot has assigned @BoxyUwU.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@BoxyUwU
Copy link
Member

BoxyUwU commented Jan 24, 2026

r? compiler

@rustbot rustbot assigned chenyukang and unassigned BoxyUwU Jan 24, 2026
Correct the handling of aggregate types in extern "C" functions to match
the Hexagon ABI specification:

- Aggregates up to 32 bits: passed/returned in a single register (R0)
- Aggregates 33-64 bits: passed/returned in a register pair (R1:R0)
- Aggregates > 64 bits: passed on stack via byval, returned via sret

This fixes all tests/ui/abi/extern/ tests for Hexagon, including:
- extern-pass-TwoU8s, extern-pass-TwoU16s, extern-pass-TwoU32s
- extern-pass-TwoU64s, extern-pass-FiveU16s
- extern-return-TwoU8s, extern-return-TwoU16s, extern-return-TwoU32s
- extern-return-TwoU64s, extern-return-FiveU16s
@chenyukang
Copy link
Member

@rustbot reroll

@rustbot rustbot assigned SparrowLii and unassigned chenyukang Jan 27, 2026
@androm3da
Copy link
Contributor Author

ping @SparrowLii

@androm3da
Copy link
Contributor Author

Can I do a

@rustbot reroll

... ?

@rustbot rustbot assigned jackh726 and unassigned SparrowLii Feb 15, 2026
@androm3da
Copy link
Contributor Author

ping @jackh726

@madsmtm
Copy link
Contributor

madsmtm commented Mar 12, 2026

r? me

@rustbot rustbot assigned madsmtm and unassigned jackh726 Mar 12, 2026
@wesleywiser
Copy link
Member

@bors r+ rollup

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 12, 2026

📌 Commit b1925a9 has been approved by wesleywiser

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 Mar 12, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 12, 2026
…ywiser

Fix Hexagon ABI calling convention for small aggregates

Small structs (<= 64 bits) were being passed with their fields split into separate arguments instead of being packed into register-sized chunks. This caused ABI mismatches.

The fix properly casts small aggregates to consecutive register-sized chunks using Uniform::consecutive(), matching the Hexagon C ABI where small structs are packed into R1:0 register pair.

This fixes tests like extern-pass-TwoU16s.rs and extern-pass-TwoU8s.rs.
rust-bors bot pushed a commit that referenced this pull request Mar 12, 2026
…uwer

Rollup of 5 pull requests

Successful merges:

 - #153751 (Detect existing turbofish on method calls to suppress useless suggestion)
 - #153780 (Remove `MTLock`)
 - #151194 (Fix wrong suggestion for returning async closure)
 - #151572 (Fix Hexagon ABI calling convention for small aggregates)
 - #153725 (Fix that `./x test --no-doc` actually keeps the same behaviour for backwards compatability)
rust-bors bot pushed a commit that referenced this pull request Mar 12, 2026
…uwer

Rollup of 5 pull requests

Successful merges:

 - #153705 (Always generate generics in delegation that match trait in trait impl scenario)
 - #153751 (Detect existing turbofish on method calls to suppress useless suggestion)
 - #153780 (Remove `MTLock`)
 - #151572 (Fix Hexagon ABI calling convention for small aggregates)
 - #153725 (Fix that `./x test --no-doc` actually keeps the same behaviour for backwards compatability)
@rust-bors rust-bors bot merged commit 1af198e into rust-lang:main Mar 12, 2026
11 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Mar 12, 2026
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Mar 16, 2026
…uwer

Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#153705 (Always generate generics in delegation that match trait in trait impl scenario)
 - rust-lang/rust#153751 (Detect existing turbofish on method calls to suppress useless suggestion)
 - rust-lang/rust#153780 (Remove `MTLock`)
 - rust-lang/rust#151572 (Fix Hexagon ABI calling convention for small aggregates)
 - rust-lang/rust#153725 (Fix that `./x test --no-doc` actually keeps the same behaviour for backwards compatability)
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.

8 participants