diff options
Diffstat (limited to 'src/passes')
-rw-r--r-- | src/passes/Print.cpp | 10 | ||||
-rw-r--r-- | src/passes/RemoveUnusedBrs.cpp | 5 |
2 files changed, 11 insertions, 4 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 81e3ae989..c1064b7db 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -2143,13 +2143,19 @@ struct PrintExpressionContents printMedium(o, "br_on_cast "); printName(curr->name, o); o << ' '; - printHeapType(o, curr->intendedType, wasm); + if (curr->castType.isNullable()) { + printMedium(o, "null "); + } + printHeapType(o, curr->castType.getHeapType(), wasm); return; case BrOnCastFail: printMedium(o, "br_on_cast_fail "); printName(curr->name, o); o << ' '; - printHeapType(o, curr->intendedType, wasm); + if (curr->castType.isNullable()) { + printMedium(o, "null "); + } + printHeapType(o, curr->castType.getHeapType(), wasm); return; case BrOnFunc: printMedium(o, "br_on_func "); diff --git a/src/passes/RemoveUnusedBrs.cpp b/src/passes/RemoveUnusedBrs.cpp index f465d46c1..4edfb8b5e 100644 --- a/src/passes/RemoveUnusedBrs.cpp +++ b/src/passes/RemoveUnusedBrs.cpp @@ -713,12 +713,13 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> { } // First, check for a possible null which would prevent all other - // optimizations. + // optimizations (except for br_on_cast variants). // TODO: Look into using BrOnNonNull here, to replace a br_on_func whose // input is (ref null func) with br_on_non_null (as only the null check // would be needed). auto refType = curr->ref->type; - if (refType.isNullable()) { + if (refType.isNullable() && curr->op != BrOnCast && + curr->op != BrOnCastFail) { return; } |