Skip to content

Comments

s390x: Fix epilog for some tail-call ABI routines#11689

Merged
alexcrichton merged 1 commit intobytecodealliance:mainfrom
uweigand:s390x-regabi-fix
Sep 11, 2025
Merged

s390x: Fix epilog for some tail-call ABI routines#11689
alexcrichton merged 1 commit intobytecodealliance:mainfrom
uweigand:s390x-regabi-fix

Conversation

@uweigand
Copy link
Member

When using the tail-call ABI and the callee needs to pop a non-zero amount of bytes, the stack pointer may never be implicitly restored via the LOAD MULTIPLE instruction in the epilog, but will always be manually updated.

In some rare cases involving exception handling, the epilog for such functions incorrectly did include the stack pointer in the LOAD MULTIPLE list. It turns out that the
is_reg_saved_in_prologue routine did not handle the stack pointer correctly.

Note that this only makes any difference for functions where cranelift common code includes the stack pointer in the list of clobbered registers passed to compute_frame_layout, which normally never happens as modifications to the stack pointer should be invisible to common code register tracking ...

Fixes: #11602

When using the tail-call ABI and the callee needs to pop
a non-zero amount of bytes, the stack pointer may never be
implicitly restored via the LOAD MULTIPLE instruction in the
epilog, but will always be manually updated.

In some rare cases involving exception handling, the epilog
for such functions incorrectly did include the stack pointer
in the LOAD MULTIPLE list.  It turns out that the
is_reg_saved_in_prologue routine did not handle the stack
pointer correctly.

Note that this only makes any difference for functions where
cranelift common code includes the stack pointer in the list
of clobbered registers passed to compute_frame_layout, which
normally never happens as modifications to the stack pointer
should be invisible to common code register tracking ...

Fixes: bytecodealliance#11602
@uweigand uweigand requested review from a team as code owners September 11, 2025 22:31
@uweigand uweigand requested review from abrown and alexcrichton and removed request for a team September 11, 2025 22:31
Copy link
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

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

Thanks!

@alexcrichton alexcrichton added this pull request to the merge queue Sep 11, 2025
Merged via the queue into bytecodealliance:main with commit 3ba4d97 Sep 11, 2025
44 checks passed
bongjunj pushed a commit to prosyslab/wasmtime that referenced this pull request Oct 20, 2025
…1689)

When using the tail-call ABI and the callee needs to pop
a non-zero amount of bytes, the stack pointer may never be
implicitly restored via the LOAD MULTIPLE instruction in the
epilog, but will always be manually updated.

In some rare cases involving exception handling, the epilog
for such functions incorrectly did include the stack pointer
in the LOAD MULTIPLE list.  It turns out that the
is_reg_saved_in_prologue routine did not handle the stack
pointer correctly.

Note that this only makes any difference for functions where
cranelift common code includes the stack pointer in the list
of clobbered registers passed to compute_frame_layout, which
normally never happens as modifications to the stack pointer
should be invisible to common code register tracking ...

Fixes: bytecodealliance#11602
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

s390x: Incorrect ABI (?) when mixing exceptions and many params/results

2 participants