diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-04-07 19:04:29 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-04-07 19:04:29 -0700 |
commit | e98b5a7d1866a9f29c5bf06a9b231894222ad30b (patch) | |
tree | 1b775d9f30b9ced7a7250668dde8e1f020f0123d | |
parent | 0d267afdf948de326055e58a94e5f48d9310a52a (diff) | |
download | binaryen-e98b5a7d1866a9f29c5bf06a9b231894222ad30b.tar.gz binaryen-e98b5a7d1866a9f29c5bf06a9b231894222ad30b.tar.bz2 binaryen-e98b5a7d1866a9f29c5bf06a9b231894222ad30b.zip |
fix invalidation logic in SimplifyLocals, visit each node as we hit it, do not walk it to look for invalidating elements that are children, we already saw them
-rw-r--r-- | src/passes/SimplifyLocals.cpp | 4 | ||||
-rw-r--r-- | test/emcc_hello_world.fromasm | 19 | ||||
-rw-r--r-- | test/emcc_hello_world.fromasm.imprecise | 19 |
3 files changed, 21 insertions, 21 deletions
diff --git a/src/passes/SimplifyLocals.cpp b/src/passes/SimplifyLocals.cpp index 5c7b7475a..a0f843bbd 100644 --- a/src/passes/SimplifyLocals.cpp +++ b/src/passes/SimplifyLocals.cpp @@ -79,11 +79,13 @@ struct SimplifyLocals : public WalkerPass<FastExecutionWalker<SimplifyLocals>> { } void walk(Expression*& curr) override { + if (!curr) return; + FastExecutionWalker::walk(curr); // invalidations TODO: this is O(n^2) in sinkables EffectAnalyzer effects; - effects.walk(curr); // TODO: this, accumulated, is O(n * nesting) <= O(n^2) + effects.visit(curr); std::vector<Name> invalidated; for (auto& sinkable : sinkables) { if (effects.invalidates(sinkable.second.effects)) { diff --git a/test/emcc_hello_world.fromasm b/test/emcc_hello_world.fromasm index be7a45cec..6c877aa3b 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,20 +463,19 @@ ) (get_local $$6) ) - (set_local $$retval$0 - (set_local $$7 - (f64.load - (i32.load - (i32.const 24) - ) + ) + ) + (return + (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 fc4418930..343ab13a6 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,20 +461,19 @@ ) (get_local $$6) ) - (set_local $$retval$0 - (set_local $$7 - (f64.load - (i32.load - (i32.const 24) - ) + ) + ) + (return + (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) |