Skip to content

Conversation

@cfallin
Copy link
Member

@cfallin cfallin commented Dec 23, 2025

These Pulley instructions are an optimization: they incorporate moves from other registers to x0/x1/x2/x3 as part of the call itself.

This works fine for the default calling convention, but the logic that absorbs these moves and removes them from the list given to the rest of the VCode/ABI machinery embeds a tacit assumption: the argument registers are volatile (caller-saved). In particular, this is because the call{1,2,3,4} instructions are not marked as clobbering x0/x1/x2/x3 explicitly.

To fix this issue, this PR simply omits the magical folding that happens in the emission code. An alternative would be to try to add the clobbers to the special instructions, but actually we don't want these to be just "clobbers": we want the usual regalloc constraints to take effect and the values to be represented as continuing valid/live in the registers after return, and the proper way to do that is to leave the args on the call and let the regalloc operand pass add the fixed-reg operands.

Discovered while trying to land #12183.

These Pulley instructions are an optimization: they incorporate moves
from other registers to x0/x1/x2/x3 as part of the call itself.

This works fine for the default calling convention, but the logic that
absorbs these moves and removes them from the list given to the rest of
the VCode/ABI machinery embeds a tacit assumption: the argument
registers are volatile (caller-saved). In particular, this is because
the call{1,2,3,4} instructions are *not* marked as clobbering
x0/x1/x2/x3 explicitly.

To fix this issue, this PR simply omits the magical folding that happens
in the emission code. An alternative would be to try to add the clobbers
to the special instructions, but actually we don't want these to be just
"clobbers": we want the usual regalloc constraints to take effect and
the values to be represented as continuing valid/live in the registers
after return, and the proper way to do that is to leave the `args` on
the call and let the regalloc operand pass add the fixed-reg operands.

Discovered while trying to land bytecodealliance#12183.
@cfallin cfallin requested a review from a team as a code owner December 23, 2025 04:04
@cfallin cfallin requested review from fitzgen and removed request for a team December 23, 2025 04:05
@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator isle Related to the ISLE domain-specific language labels Dec 23, 2025
@github-actions
Copy link

Subscribe to Label Action

cc @cfallin, @fitzgen

Details This issue or pull request has been labeled: "cranelift", "isle"

Thus the following users have been cc'd because of the following labels:

  • cfallin: isle
  • fitzgen: isle

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

@alexcrichton alexcrichton added this pull request to the merge queue Dec 23, 2025
Merged via the queue into bytecodealliance:main with commit d9474b1 Dec 23, 2025
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cranelift Issues related to the Cranelift code generator isle Related to the ISLE domain-specific language

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants