summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ast_utils.h1
-rw-r--r--test/emcc_hello_world.fromasm19
-rw-r--r--test/emcc_hello_world.fromasm.imprecise19
-rw-r--r--test/passes/simplify-locals.txt14
-rw-r--r--test/passes/simplify-locals.wast10
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)
+ )
)
)