Skip to content

Fix Hexagon ABI calling convention for small aggregates#151572

Open
androm3da wants to merge 2 commits intorust-lang:mainfrom
androm3da:bcain/abi_cconv
Open

Fix Hexagon ABI calling convention for small aggregates#151572
androm3da wants to merge 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

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.

6 participants