summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai (kripken) <alonzakai@gmail.com>2017-07-10 15:43:21 -0700
committerAlon Zakai (kripken) <alonzakai@gmail.com>2017-07-11 11:07:45 -0700
commit5c4c6ba03e1c42cee86e580c09b8c66a6bb1a71c (patch)
tree1e4a19d462d105d006f2413e10f2b7cd91d42d42
parent987003944456c3d04f74c12067ac950feca1a81e (diff)
downloadbinaryen-5c4c6ba03e1c42cee86e580c09b8c66a6bb1a71c.tar.gz
binaryen-5c4c6ba03e1c42cee86e580c09b8c66a6bb1a71c.tar.bz2
binaryen-5c4c6ba03e1c42cee86e580c09b8c66a6bb1a71c.zip
properly handle if arm removal in vacuum
-rw-r--r--src/passes/Vacuum.cpp4
-rw-r--r--test/passes/vacuum.txt12
-rw-r--r--test/passes/vacuum.wast30
3 files changed, 46 insertions, 0 deletions
diff --git a/src/passes/Vacuum.cpp b/src/passes/Vacuum.cpp
index 4adfc1289..b58bea4b3 100644
--- a/src/passes/Vacuum.cpp
+++ b/src/passes/Vacuum.cpp
@@ -204,9 +204,13 @@ struct Vacuum : public WalkerPass<PostWalker<Vacuum>> {
Expression* child;
if (value->value.getInteger()) {
child = curr->ifTrue;
+ if (curr->ifFalse) {
+ typeUpdater.noteRecursiveRemoval(curr->ifFalse);
+ }
} else {
if (curr->ifFalse) {
child = curr->ifFalse;
+ typeUpdater.noteRecursiveRemoval(curr->ifTrue);
} else {
ExpressionManipulator::nop(curr);
return;
diff --git a/test/passes/vacuum.txt b/test/passes/vacuum.txt
index 30474280e..cb85838ac 100644
--- a/test/passes/vacuum.txt
+++ b/test/passes/vacuum.txt
@@ -235,4 +235,16 @@
)
)
)
+ (func $executed-if-in-block (type $0)
+ (unreachable)
+ )
+ (func $executed-if-in-block2 (type $0)
+ (unreachable)
+ )
+ (func $executed-if-in-block3 (type $0)
+ (block $label$0
+ (br $label$0)
+ )
+ (unreachable)
+ )
)
diff --git a/test/passes/vacuum.wast b/test/passes/vacuum.wast
index 594554846..2b8486384 100644
--- a/test/passes/vacuum.wast
+++ b/test/passes/vacuum.wast
@@ -534,4 +534,34 @@
(f64.const 2097914503796645752267195e31)
)
)
+ (func $executed-if-in-block
+ (block $label$0
+ (if
+ (i32.const 170996275)
+ (unreachable)
+ (br $label$0)
+ )
+ )
+ (unreachable)
+ )
+ (func $executed-if-in-block2
+ (block $label$0
+ (if
+ (i32.const 170996275)
+ (nop)
+ (br $label$0)
+ )
+ )
+ (unreachable)
+ )
+ (func $executed-if-in-block3
+ (block $label$0
+ (if
+ (i32.const 170996275)
+ (br $label$0)
+ (nop)
+ )
+ )
+ (unreachable)
+ )
)