summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/passes/Print.cpp5
-rw-r--r--test/passes/Os_print-stack-ir.txt16
-rw-r--r--test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_all-features.txt2
3 files changed, 14 insertions, 9 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index 51e78c8a7..549aa661d 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -2504,6 +2504,11 @@ WasmPrinter::printStackIR(StackIR* ir, std::ostream& o, Function* func) {
switch (inst->op) {
case StackInst::Basic: {
doIndent();
+ // push and pop are pseudo instructions and should not be printed in the
+ // stack IR format to make it valid wat form.
+ if (inst->origin->is<Push>() || inst->origin->is<Pop>()) {
+ break;
+ }
PrintExpressionContents(func, o).visit(inst->origin);
break;
}
diff --git a/test/passes/Os_print-stack-ir.txt b/test/passes/Os_print-stack-ir.txt
index 2ac10ff03..7dfee65de 100644
--- a/test/passes/Os_print-stack-ir.txt
+++ b/test/passes/Os_print-stack-ir.txt
@@ -50,23 +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 4a5f8e8ee..bb031c48b 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,7 +8,7 @@
i32.const 0
throw $e0
catch
- exnref.pop
+
local.set $exn
block $l0 (result i32)
local.get $exn