[EH][GC] Fix nested pop after removing ref.cast #4407
Merged
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.
ref.cast
can be statically removed when the ref's type is a subtype ofthe intended RTT type and either of
--ignore-implicit-traps
or--traps-never-happen
is given:binaryen/src/passes/OptimizeInstructions.cpp
Lines 1603 to 1624 in 083ab98
Some more context: #4097 (comment)
But this can create a block in which a
pop
is nested, which makes thecatch
invalid. The test in this PR is the same as the example given by@kripken in #4237. This calls the fixup function
EHUtils::handleBlockNestedPops
at the end of the pass to fix this.Also, because this pass creates a lot of blocks in other patterns, I
think it is possible there can be other patterns to cause this kind of
pop
nesting.