Repository navigation
Heap2Local: Handle unreachable ref.test replacement - #8605
Conversation
| ;; 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. |
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.
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.
As with
local.getin other cases, here we replace with somethingconcrete (a
const), and we can't do that if we became unreachable.