summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/passes/Print.cpp29
-rw-r--r--src/wasm/wasm.cpp2
2 files changed, 29 insertions, 2 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index 1392ccb6f..ef78bf582 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -1926,7 +1926,7 @@ struct PrintExpressionContents
// where if the ref is unreachable, we don't know what heap type to print),
// then print the children in a block, which is good enough as this
// instruction is never reached anyhow.
- printMedium(o, "block ");
+ printMedium(o, "block");
}
void printFieldName(HeapType type, Index index) {
processFieldName(wasm, type, index, [&](Name name) {
@@ -2346,6 +2346,33 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> {
o << " ;; end try";
}
}
+ void printUnreachableReplacement(Expression* curr) {
+ // See the parallel function in PrintExpressionContents for background.
+ //
+ // Emit a block with drops of the children.
+ o << "(block";
+ incIndent();
+ for (auto* child : ChildIterator(curr)) {
+ Drop drop;
+ drop.value = child;
+ printFullLine(&drop);
+ }
+ decIndent();
+ }
+ void visitStructSet(StructSet* curr) {
+ if (curr->ref->type == Type::unreachable) {
+ printUnreachableReplacement(curr);
+ return;
+ }
+ visitExpression(curr);
+ }
+ void visitStructGet(StructGet* curr) {
+ if (curr->ref->type == Type::unreachable) {
+ printUnreachableReplacement(curr);
+ return;
+ }
+ visitExpression(curr);
+ }
// Module-level visitors
void handleSignature(Signature curr, Name name = Name()) {
o << "(func";
diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp
index 410ba0573..69464e73f 100644
--- a/src/wasm/wasm.cpp
+++ b/src/wasm/wasm.cpp
@@ -977,7 +977,7 @@ void StructGet::finalize() {
}
void StructSet::finalize() {
- if (ref->type == Type::unreachable) {
+ if (ref->type == Type::unreachable || value->type == Type::unreachable) {
type = Type::unreachable;
} else {
type = Type::none;