Skip to content

riscv64: Consider vstate clobbered on calls#11048

Merged
cfallin merged 3 commits into
bytecodealliance:mainfrom
alexcrichton:riscv64-clobber-vstate
Jun 15, 2025
Merged

riscv64: Consider vstate clobbered on calls#11048
cfallin merged 3 commits into
bytecodealliance:mainfrom
alexcrichton:riscv64-clobber-vstate

Conversation

@alexcrichton

@alexcrichton alexcrichton commented Jun 15, 2025

Copy link
Copy Markdown
Member

This commit fixes an issue in the riscv64 backend where the tracking for the vector state register was only considered clobbered on the entry to basic blocks as opposed to also after call instructions. This updates the vector state upon encountering these instructions to ensure that after a call the vector state is re-updated in case it was changed by the callee.

Closes #10951
Closes #11033

This commit fixes an issue in the riscv64 backend where the tracking for
the vector state register was only considered clobbered on the entry to
basic blocks as opposed to also after call instructions. This updates
the vector state upon encountering these instructions to ensure that
after a call the vector state is re-updated in case it was changed by
the callee.

Closes bytecodealliance#10951
@alexcrichton
alexcrichton requested a review from a team as a code owner June 15, 2025 16:41
@alexcrichton
alexcrichton requested review from abrown and removed request for a team June 15, 2025 16:41
@github-actions github-actions Bot added the cranelift Issues related to the Cranelift code generator label Jun 15, 2025

@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.

Good find! I remember thinking through this emit-state mechanism for vectors initially and I have no idea why we didn't consider the ABI...

@cfallin
cfallin added this pull request to the merge queue Jun 15, 2025
Merged via the queue into bytecodealliance:main with commit 0f36d5d Jun 15, 2025
71 checks passed
@alexcrichton
alexcrichton deleted the riscv64-clobber-vstate branch June 15, 2025 19:28
bongjunj pushed a commit to prosyslab/wasmtime that referenced this pull request Oct 20, 2025
* riscv64: Consider vstate clobbered on calls

This commit fixes an issue in the riscv64 backend where the tracking for
the vector state register was only considered clobbered on the entry to
basic blocks as opposed to also after call instructions. This updates
the vector state upon encountering these instructions to ensure that
after a call the vector state is re-updated in case it was changed by
the callee.

Closes bytecodealliance#10951

* Fix some runtests

* Update test expectations
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cranelift: Unexpected illegal instruction on riscv64 Cranelift: Function call causes unexpected value changes on riscv64

2 participants