summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/wasm-stack.h6
-rw-r--r--src/wasm-traversal.h6
-rw-r--r--src/wasm/wasm-stack.cpp3
-rw-r--r--test/passes/Os_print-stack-ir.txt8
-rw-r--r--test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_all-features.txt1
5 files changed, 17 insertions, 7 deletions
diff --git a/src/wasm-stack.h b/src/wasm-stack.h
index 91c0c5383..5f0bf12af 100644
--- a/src/wasm-stack.h
+++ b/src/wasm-stack.h
@@ -779,14 +779,12 @@ void BinaryenIRWriter<SubType>::visitDrop(Drop* curr) {
template<typename SubType>
void BinaryenIRWriter<SubType>::visitPush(Push* curr) {
- // Turns into nothing in the binary format: leave the child on the stack for
- // others to use.
visit(curr->value);
+ emit(curr);
}
template<typename SubType> void BinaryenIRWriter<SubType>::visitPop(Pop* curr) {
- // Turns into nothing in the binary format: just get a value that is already
- // on the stack.
+ emit(curr);
}
// Binaryen IR to binary writer
diff --git a/src/wasm-traversal.h b/src/wasm-traversal.h
index c9290cbab..eae4634b5 100644
--- a/src/wasm-traversal.h
+++ b/src/wasm-traversal.h
@@ -1185,7 +1185,8 @@ struct ControlFlowWalker : public PostWalker<SubType, VisitorType> {
switch (curr->_id) {
case Expression::Id::BlockId:
case Expression::Id::IfId:
- case Expression::Id::LoopId: {
+ case Expression::Id::LoopId:
+ case Expression::Id::TryId: {
self->pushTask(SubType::doPostVisitControlFlow, currp);
break;
}
@@ -1197,7 +1198,8 @@ struct ControlFlowWalker : public PostWalker<SubType, VisitorType> {
switch (curr->_id) {
case Expression::Id::BlockId:
case Expression::Id::IfId:
- case Expression::Id::LoopId: {
+ case Expression::Id::LoopId:
+ case Expression::Id::TryId: {
self->pushTask(SubType::doPreVisitControlFlow, currp);
break;
}
diff --git a/src/wasm/wasm-stack.cpp b/src/wasm/wasm-stack.cpp
index 22d6a0036..a308ecb7a 100644
--- a/src/wasm/wasm-stack.cpp
+++ b/src/wasm/wasm-stack.cpp
@@ -1797,7 +1797,8 @@ StackInst* StackIRGenerator::makeStackInst(StackInst::Op op,
ret->op = op;
ret->origin = origin;
auto stackType = origin->type;
- if (origin->is<Block>() || origin->is<Loop>() || origin->is<If>()) {
+ if (origin->is<Block>() || origin->is<Loop>() || origin->is<If>() ||
+ origin->is<Try>()) {
if (stackType == unreachable) {
// There are no unreachable blocks, loops, or ifs. we emit extra
// unreachables to fix that up, so that they are valid as having none
diff --git a/test/passes/Os_print-stack-ir.txt b/test/passes/Os_print-stack-ir.txt
index 7b34da8e1..2ac10ff03 100644
--- a/test/passes/Os_print-stack-ir.txt
+++ b/test/passes/Os_print-stack-ir.txt
@@ -50,15 +50,23 @@
(export "ppf64" (func $3))
(func $0 (; 0 ;) (result i32)
i32.const 1
+ push
+ i32.pop
)
(func $1 (; 1 ;) (result i64)
i64.const 1
+ push
+ i64.pop
)
(func $2 (; 2 ;) (result f32)
f32.const 1
+ push
+ f32.pop
)
(func $3 (; 3 ;) (result f64)
f64.const 1
+ push
+ f64.pop
)
)
(module
diff --git a/test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_all-features.txt b/test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_all-features.txt
index 8e9dfc415..4a5f8e8ee 100644
--- a/test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_all-features.txt
+++ b/test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_all-features.txt
@@ -8,6 +8,7 @@
i32.const 0
throw $e0
catch
+ exnref.pop
local.set $exn
block $l0 (result i32)
local.get $exn