diff options
author | Alon Zakai <azakai@google.com> | 2023-04-05 12:25:01 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-05 12:25:01 -0700 |
commit | 02277fb28f3a0632819b1046fddd0ec3de52a8a3 (patch) | |
tree | b12df1cde09b066fec99ec4de93226918591bf6d /src | |
parent | 30097e5da0a99fa42dac1af1efeb435c5f15e1f0 (diff) | |
download | binaryen-02277fb28f3a0632819b1046fddd0ec3de52a8a3.tar.gz binaryen-02277fb28f3a0632819b1046fddd0ec3de52a8a3.tar.bz2 binaryen-02277fb28f3a0632819b1046fddd0ec3de52a8a3.zip |
Wasm GC] Handle unreachability in a select child in trapOnNull() (#5630)
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/OptimizeInstructions.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/passes/OptimizeInstructions.cpp b/src/passes/OptimizeInstructions.cpp index c9e1ced19..f5a0c6756 100644 --- a/src/passes/OptimizeInstructions.cpp +++ b/src/passes/OptimizeInstructions.cpp @@ -1632,7 +1632,12 @@ struct OptimizeInstructions } if (auto* select = ref->dynCast<Select>()) { - if (select->ifTrue->type.isNull()) { + // We must check for unreachability explicitly here because a full + // refinalize only happens at the end. That is, the select may stil be + // reachable after we turned one child into an unreachable, and we are + // calling getResultOfFirst which will error on unreachability. + if (select->ifTrue->type.isNull() && + select->ifFalse->type != Type::unreachable) { ref = builder.makeSequence( builder.makeDrop(select->ifTrue), getResultOfFirst(select->ifFalse, |