Heap2Local: Handle unreachable ref.test replacement#8605
Merged
kripken merged 2 commits intoWebAssembly:mainfrom Apr 15, 2026
Merged
Heap2Local: Handle unreachable ref.test replacement#8605kripken merged 2 commits intoWebAssembly:mainfrom
kripken merged 2 commits intoWebAssembly:mainfrom
Conversation
tlively
reviewed
Apr 15, 2026
Comment on lines
+1413
to
+1415
| ;; The ref.test's input will become unreachable after we optimize. We should | ||
| ;; not emit a const for the test result, even though we know it, as this is | ||
| ;; unreachable code which would not validate. |
Member
There was a problem hiding this comment.
Can you be more specific about where the validation failure would be? It looks like the constant would flow into the drop, but that would be perfectly valid.
Member
Author
There was a problem hiding this comment.
It's the usual issue with local.get, like we do in a few other places,
binaryen/src/passes/Heap2Local.cpp
Lines 978 to 985 in 95d8876
If we don't skip this code, we emit a block with an unreachable child followed by a concrete one (here, a const). So yes, there is a drop of the block that ends in the constant, but the problem is that the block has the wrong type.
tlively
approved these changes
Apr 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As with
local.getin other cases, here we replace with somethingconcrete (a
const), and we can't do that if we became unreachable.