diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-04-07 19:09:05 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-04-07 19:09:05 -0700 |
commit | 0a03aacd4ea32476714066eebe0cded77c87ca66 (patch) | |
tree | 4ec1b99e7dae8f43cdcf4f2baccf5dee0b5e6a11 | |
parent | e98b5a7d1866a9f29c5bf06a9b231894222ad30b (diff) | |
download | binaryen-0a03aacd4ea32476714066eebe0cded77c87ca66.tar.gz binaryen-0a03aacd4ea32476714066eebe0cded77c87ca66.tar.bz2 binaryen-0a03aacd4ea32476714066eebe0cded77c87ca66.zip |
blocks must mark as branching in effects analyzer, as control flow can join there if the end of the block was branched to
-rw-r--r-- | src/ast_utils.h | 1 | ||||
-rw-r--r-- | test/emcc_hello_world.fromasm | 19 | ||||
-rw-r--r-- | test/emcc_hello_world.fromasm.imprecise | 19 | ||||
-rw-r--r-- | test/passes/simplify-locals.txt | 14 | ||||
-rw-r--r-- | test/passes/simplify-locals.wast | 10 |
5 files changed, 45 insertions, 18 deletions
diff --git a/src/ast_utils.h b/src/ast_utils.h index 190b2876e..bf42d10e1 100644 --- a/src/ast_utils.h +++ b/src/ast_utils.h @@ -61,6 +61,7 @@ struct EffectAnalyzer : public WasmWalker<EffectAnalyzer> { || (accessesMemory() && (other.writesMemory || other.calls)) || (accessesLocal() && other.writesLocal); } + void visitBlock(Block *curr) { branches = true; } void visitIf(If *curr) { branches = true; } void visitBreak(Break *curr) { branches = true; } void visitSwitch(Switch *curr) { branches = true; } diff --git a/test/emcc_hello_world.fromasm b/test/emcc_hello_world.fromasm index 6c877aa3b..be7a45cec 100644 --- a/test/emcc_hello_world.fromasm +++ b/test/emcc_hello_world.fromasm @@ -299,9 +299,9 @@ ) ) (func $_frexp (param $$x f64) (param $$e i32) (result f64) + (local $$retval$0 f64) (local $$x$addr$0 f64) (local $$storemerge i32) - (local $$retval$0 f64) (local $$1 i32) (local $$0 i32) (local $$sub8 i32) @@ -463,19 +463,20 @@ ) (get_local $$6) ) - ) - ) - (return - (set_local $$retval$0 - (set_local $$7 - (f64.load - (i32.load - (i32.const 24) + (set_local $$retval$0 + (set_local $$7 + (f64.load + (i32.load + (i32.const 24) + ) ) ) ) ) ) + (return + (get_local $$retval$0) + ) ) (func $_frexpl (param $$x f64) (param $$e i32) (result f64) (local $sp i32) diff --git a/test/emcc_hello_world.fromasm.imprecise b/test/emcc_hello_world.fromasm.imprecise index 343ab13a6..fc4418930 100644 --- a/test/emcc_hello_world.fromasm.imprecise +++ b/test/emcc_hello_world.fromasm.imprecise @@ -297,9 +297,9 @@ ) ) (func $_frexp (param $$x f64) (param $$e i32) (result f64) + (local $$retval$0 f64) (local $$x$addr$0 f64) (local $$storemerge i32) - (local $$retval$0 f64) (local $$1 i32) (local $$0 i32) (local $$sub8 i32) @@ -461,19 +461,20 @@ ) (get_local $$6) ) - ) - ) - (return - (set_local $$retval$0 - (set_local $$7 - (f64.load - (i32.load - (i32.const 24) + (set_local $$retval$0 + (set_local $$7 + (f64.load + (i32.load + (i32.const 24) + ) ) ) ) ) ) + (return + (get_local $$retval$0) + ) ) (func $_frexpl (param $$x f64) (param $$e i32) (result f64) (local $sp i32) diff --git a/test/passes/simplify-locals.txt b/test/passes/simplify-locals.txt index 477d95250..88c00dbe9 100644 --- a/test/passes/simplify-locals.txt +++ b/test/passes/simplify-locals.txt @@ -226,5 +226,19 @@ (get_local $a) (call_import $waka) ) + (block $out-of-block + (set_local $a + (i32.const 1337) + ) + (block $b + (block $c + (br $b) + ) + (set_local $a + (i32.const 9876) + ) + ) + (get_local $a) + ) ) ) diff --git a/test/passes/simplify-locals.wast b/test/passes/simplify-locals.wast index 6f33db4e2..5b1db2d12 100644 --- a/test/passes/simplify-locals.wast +++ b/test/passes/simplify-locals.wast @@ -126,6 +126,16 @@ (get_local $a) ;; no (call_import $waka) ) + (block $out-of-block + (set_local $a (i32.const 1337)) + (block $b + (block $c + (br $b) + ) + (set_local $a (i32.const 9876)) + ) + (get_local $a) + ) ) ) |