summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai (kripken) <alonzakai@gmail.com>2017-07-13 10:31:28 -0700
committerAlon Zakai (kripken) <alonzakai@gmail.com>2017-07-13 11:54:03 -0700
commit29cf8735b0a0dd1cd6640e27206f2e2ac78503c1 (patch)
tree626cf50c3e0711945cced649f120c2a1cf3919c9
parentf755250db869781db4206eee8db00c8060ac398b (diff)
downloadbinaryen-29cf8735b0a0dd1cd6640e27206f2e2ac78503c1.tar.gz
binaryen-29cf8735b0a0dd1cd6640e27206f2e2ac78503c1.tar.bz2
binaryen-29cf8735b0a0dd1cd6640e27206f2e2ac78503c1.zip
note changes when removing an if body in vacuum
-rw-r--r--src/passes/Vacuum.cpp4
-rw-r--r--test/passes/vacuum.txt14
-rw-r--r--test/passes/vacuum.wast26
3 files changed, 44 insertions, 0 deletions
diff --git a/src/passes/Vacuum.cpp b/src/passes/Vacuum.cpp
index 0178a794d..3f27fb36a 100644
--- a/src/passes/Vacuum.cpp
+++ b/src/passes/Vacuum.cpp
@@ -234,6 +234,10 @@ struct Vacuum : public WalkerPass<PostWalker<Vacuum>> {
}
// if the condition is unreachable, just return it
if (curr->condition->type == unreachable) {
+ typeUpdater.noteRecursiveRemoval(curr->ifTrue);
+ if (curr->ifFalse) {
+ typeUpdater.noteRecursiveRemoval(curr->ifFalse);
+ }
replaceCurrent(curr->condition);
return;
}
diff --git a/test/passes/vacuum.txt b/test/passes/vacuum.txt
index 7cee4edf1..f3b06af1a 100644
--- a/test/passes/vacuum.txt
+++ b/test/passes/vacuum.txt
@@ -287,4 +287,18 @@
)
)
)
+ (func $if-arm-vanishes (type $3) (result i32)
+ (block $label$0 (result i32)
+ (br $label$0
+ (i32.const 1)
+ )
+ )
+ )
+ (func $if-arm-vanishes-2 (type $3) (result i32)
+ (block $label$0 (result i32)
+ (br $label$0
+ (i32.const 1)
+ )
+ )
+ )
)
diff --git a/test/passes/vacuum.wast b/test/passes/vacuum.wast
index 1885da09b..db4bf6749 100644
--- a/test/passes/vacuum.wast
+++ b/test/passes/vacuum.wast
@@ -611,4 +611,30 @@
)
)
)
+ (func $if-arm-vanishes (result i32)
+ (block $label$0 (result i32)
+ (block $label$1
+ (if
+ (br $label$0
+ (i32.const 1)
+ )
+ (br $label$1)
+ )
+ )
+ (i32.const 1579493952)
+ )
+ )
+ (func $if-arm-vanishes-2 (result i32)
+ (block $label$0 (result i32)
+ (block $label$1
+ (if
+ (br $label$0
+ (i32.const 1)
+ )
+ (br $label$1)
+ )
+ )
+ (i32.const 1579493952)
+ )
+ )
)