diff options
author | Alon Zakai <azakai@google.com> | 2021-05-17 14:27:08 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-17 14:27:08 -0700 |
commit | 9f8fca1456fe754ead197b4f9899be190e978c92 (patch) | |
tree | e50907f1b5be6eed29ada14542622b53da9c2df6 /src | |
parent | 7296f51567d5db95c23247dbec116e35812df5a8 (diff) | |
download | binaryen-9f8fca1456fe754ead197b4f9899be190e978c92.tar.gz binaryen-9f8fca1456fe754ead197b4f9899be190e978c92.tar.bz2 binaryen-9f8fca1456fe754ead197b4f9899be190e978c92.zip |
[Wasm GC] Fix printing of unreachable Array operations (#3892)
Similar to struct operations, if the reference is unreachable then we do
not know the heap type, and cannot print the full expression.
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/Print.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 41e800352..9f283ddcc 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -1977,6 +1977,10 @@ struct PrintExpressionContents TypeNamePrinter(o, wasm).print(curr->rtt->type.getHeapType()); } void visitArrayGet(ArrayGet* curr) { + if (curr->ref->type == Type::unreachable) { + printUnreachableReplacement(); + return; + } const auto& element = curr->ref->type.getHeapType().getArray().element; if (element.type == Type::i32 && element.packedType != Field::not_packed) { if (curr->signed_) { @@ -1990,6 +1994,10 @@ struct PrintExpressionContents TypeNamePrinter(o, wasm).print(curr->ref->type.getHeapType()); } void visitArraySet(ArraySet* curr) { + if (curr->ref->type == Type::unreachable) { + printUnreachableReplacement(); + return; + } printMedium(o, "array.set "); TypeNamePrinter(o, wasm).print(curr->ref->type.getHeapType()); } @@ -2376,6 +2384,20 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> { } visitExpression(curr); } + void visitArraySet(ArraySet* curr) { + if (curr->ref->type == Type::unreachable) { + printUnreachableReplacement(curr); + return; + } + visitExpression(curr); + } + void visitArrayGet(ArrayGet* curr) { + if (curr->ref->type == Type::unreachable) { + printUnreachableReplacement(curr); + return; + } + visitExpression(curr); + } // Module-level visitors void handleSignature(Signature curr, Name name = Name()) { o << "(func"; |