summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/passes/Vacuum.cpp2
-rw-r--r--test/unit.asm.js11
-rw-r--r--test/unit.fromasm12
-rw-r--r--test/unit.fromasm.imprecise12
-rw-r--r--test/unit.fromasm.imprecise.no-opts21
-rw-r--r--test/unit.fromasm.no-opts21
6 files changed, 78 insertions, 1 deletions
diff --git a/src/passes/Vacuum.cpp b/src/passes/Vacuum.cpp
index 150593713..89ef7359e 100644
--- a/src/passes/Vacuum.cpp
+++ b/src/passes/Vacuum.cpp
@@ -190,7 +190,7 @@ struct Vacuum : public WalkerPass<ExpressionStackWalker<Vacuum, Visitor<Vacuum>>
// no else
if (curr->ifTrue->is<Nop>()) {
// no nothing
- replaceCurrent(curr->condition);
+ replaceCurrent(Builder(*getModule()).makeDrop(curr->condition));
}
}
}
diff --git a/test/unit.asm.js b/test/unit.asm.js
index b4c10b1d2..8f0812e29 100644
--- a/test/unit.asm.js
+++ b/test/unit.asm.js
@@ -308,6 +308,17 @@ function asm(global, env, buffer) {
} while(0);
}
+ function ifChainEmpty(label) {
+ label = label | 0;
+ if ((label|0) == 4) {
+ return 0;
+ }
+ else if ((label|0) == 7) {
+ // unreachable;
+ }
+ return 0;
+ }
+
function z() {
}
function w() {
diff --git a/test/unit.fromasm b/test/unit.fromasm
index cecbeef22..bc5281ed5 100644
--- a/test/unit.fromasm
+++ b/test/unit.fromasm
@@ -558,4 +558,16 @@
)
)
)
+ (func $ifChainEmpty (param $0 i32) (result i32)
+ (if
+ (i32.eq
+ (get_local $0)
+ (i32.const 4)
+ )
+ (return
+ (i32.const 0)
+ )
+ )
+ (i32.const 0)
+ )
)
diff --git a/test/unit.fromasm.imprecise b/test/unit.fromasm.imprecise
index ba1af7916..945d6cc8e 100644
--- a/test/unit.fromasm.imprecise
+++ b/test/unit.fromasm.imprecise
@@ -540,4 +540,16 @@
)
)
)
+ (func $ifChainEmpty (param $0 i32) (result i32)
+ (if
+ (i32.eq
+ (get_local $0)
+ (i32.const 4)
+ )
+ (return
+ (i32.const 0)
+ )
+ )
+ (i32.const 0)
+ )
)
diff --git a/test/unit.fromasm.imprecise.no-opts b/test/unit.fromasm.imprecise.no-opts
index 0c02680da..f06912d08 100644
--- a/test/unit.fromasm.imprecise.no-opts
+++ b/test/unit.fromasm.imprecise.no-opts
@@ -932,6 +932,27 @@
(nop)
)
)
+ (func $ifChainEmpty (param $label i32) (result i32)
+ (if
+ (i32.eq
+ (get_local $label)
+ (i32.const 4)
+ )
+ (return
+ (i32.const 0)
+ )
+ (if
+ (i32.eq
+ (get_local $label)
+ (i32.const 7)
+ )
+ (nop)
+ )
+ )
+ (return
+ (i32.const 0)
+ )
+ )
(func $z
(nop)
)
diff --git a/test/unit.fromasm.no-opts b/test/unit.fromasm.no-opts
index fbbc6e7ff..222e0fa65 100644
--- a/test/unit.fromasm.no-opts
+++ b/test/unit.fromasm.no-opts
@@ -938,6 +938,27 @@
(nop)
)
)
+ (func $ifChainEmpty (param $label i32) (result i32)
+ (if
+ (i32.eq
+ (get_local $label)
+ (i32.const 4)
+ )
+ (return
+ (i32.const 0)
+ )
+ (if
+ (i32.eq
+ (get_local $label)
+ (i32.const 7)
+ )
+ (nop)
+ )
+ )
+ (return
+ (i32.const 0)
+ )
+ )
(func $z
(nop)
)