Skip to content

[I64ToI32Lowering] Fix return_call_indirect result type - #9325

Merged
kripken merged 1 commit into
WebAssembly:mainfrom
akshat-lakhera:fix/9244-return-call-indirect-type
Oct 29, 2026
Merged

kripken merged 1 commit into
WebAssembly:mainfrom
akshat-lakhera:fix/9244-return-call-indirect-type

Conversation

@akshat-lakhera

Copy link
Copy Markdown
Contributor

Fixes #9244.

I64ToI32Lowering rebuilt return_call_indirect using the results passed in from the call's own type, but a return call has type unreachable, so when the callee's signature had results the lowered call_indirect ended up with a signature that had none. The fix is in visitCallIndirect: for return calls the results now come from the heap type's signature instead. i64 results on return calls still hit the existing Fatal, so this only affects signatures whose results don't need lowering.

I added a lit test, i64-to-i32-lowering-return-call-indirect.wast, with CHECK lines generated by update_lit_checks.py. It covers a return_call_indirect with no results and one with an i64 param and an i32 result, and it fails without the change and passes with it. The rest of the lit suite shows no new failures locally.

Fixes #9244.

Signed-off-by: Akshat Lakhera <akshatlnct2024@gmail.com>
@akshat-lakhera
akshat-lakhera requested a review from a team as a code owner October 29, 2026 14:40
@akshat-lakhera
akshat-lakhera requested review from kripken and removed request for a team October 29, 2026 14:40

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request updates the I64ToI32Lowering pass to ensure that return calls, which have an unreachable type, correctly preserve the results of their original signature. Specifically, if the call is a return call, the results are retrieved from the original signature instead of the call's type. A new LIT test has also been added to verify this behavior. There are no review comments, and I have no additional feedback to provide.

@akshat-lakhera

Copy link
Copy Markdown
Contributor Author

PTAL @tlively @kripken

@kripken
kripken merged commit 38313a1 into WebAssembly:main Oct 29, 2026
17 checks passed
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.

I64ToI32Lowering: return_call_indirect gets a (func (result unreachable)) type, binary writer hits UNREACHABLE

2 participants