Skip to content

aarch64: fix apple_aarch64 stack slot size for sext/uext spilled args - #14235

Merged
cfallin merged 1 commit into
bytecodealliance:mainfrom
dsecurity49:fix-apple-aarch64-stack-slot-overflow
Sep 3, 2026
Merged

aarch64: fix apple_aarch64 stack slot size for sext/uext spilled args#14235
cfallin merged 1 commit into
bytecodealliance:mainfrom
dsecurity49:fix-apple-aarch64-stack-slot-overflow

Conversation

@dsecurity49

@dsecurity49 dsecurity49 commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Fixes #13973

For apple_aarch64, get_ext_mode returns specified extensions (sext/uext), which causes caller/callee to load and store full 64-bit words for stack arguments. The slot size condition previously allowed sub-word sizes for spilled arguments whenever args_or_rets == Args, causing 8-byte stores to overwrite adjacent stack slots.

This updates the check to only allow sub-word stack slots when param.extension == None.

@dsecurity49
dsecurity49 requested review from a team as code owners August 30, 2026 14:22
@dsecurity49
dsecurity49 requested review from alexcrichton and cfallin and removed request for a team August 30, 2026 14:22
@github-actions github-actions Bot added cranelift Issues related to the Cranelift code generator cranelift:area:aarch64 Issues related to AArch64 backend. labels Aug 30, 2026
@cfallin

cfallin commented Aug 31, 2026

Copy link
Copy Markdown
Member

If I understand this right, you are asserting that the Apple aarch64 convention actually does 8-align args just because they are extended to 64 bits (in registers). That doesn't sound right to me but I'm happy to be corrected; could you link the documentation you're using as a reference for this change? Thanks!

(If the extension only applies to in-register values instead, as I suspect, then the correct fix is instead to do narrow (true-width) loads/stores when values live on the stack, I think.)

@dsecurity49
dsecurity49 force-pushed the fix-apple-aarch64-stack-slot-overflow branch from c6bf9ee to a5120cd Compare September 1, 2026 06:00
@dsecurity49
dsecurity49 requested a review from a team as a code owner September 1, 2026 06:00
@dsecurity49
dsecurity49 force-pushed the fix-apple-aarch64-stack-slot-overflow branch 2 times, most recently from 5b858ab to 6dc6bd1 Compare September 1, 2026 06:06
@dsecurity49

Copy link
Copy Markdown
Contributor Author

you're right. The extension should only apply to registers. get_ext_mode didn't know the location though, so it was forcing 8-byte loads/stores for anything extended.

I've updated the PR to thread an ABIArgLocation into get_ext_mode so we can correctly return None for stack args on apple AArch64. I also added a precise-output test for it.

@github-actions github-actions Bot added cranelift:area:machinst Issues related to instruction selection and the new MachInst backend. cranelift:area:x64 Issues related to x64 codegen labels Sep 1, 2026
@alexcrichton
alexcrichton removed request for a team and alexcrichton September 1, 2026 16:25
@cfallin

cfallin commented Sep 3, 2026

Copy link
Copy Markdown
Member

Thanks! I'll repeat a question from earlier:

could you link the documentation you're using as a reference for this change? Thanks!

Both for my own use and ideally linked in a comment so we can have a canonical source going forward.

@dsecurity49
dsecurity49 force-pushed the fix-apple-aarch64-stack-slot-overflow branch from 6dc6bd1 to e61cf2e Compare September 3, 2026 05:41
@dsecurity49

Copy link
Copy Markdown
Contributor Author

@cfallin cfallin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@cfallin
cfallin added this pull request to the merge queue Sep 3, 2026
Merged via the queue into bytecodealliance:main with commit e253c25 Sep 3, 2026
81 checks passed
@dsecurity49
dsecurity49 deleted the fix-apple-aarch64-stack-slot-overflow branch September 3, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cranelift:area:aarch64 Issues related to AArch64 backend. cranelift:area:machinst Issues related to instruction selection and the new MachInst backend. cranelift:area:x64 Issues related to x64 codegen cranelift Issues related to the Cranelift code generator

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aarch64: Cranelift's apple_aarch64 calling convention writes past the end of outgoing arguments

2 participants