diff options
author | Alon Zakai <azakai@google.com> | 2019-04-26 16:59:41 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-26 16:59:41 -0700 |
commit | db9124f1de0478dcac525009b6f1589b44a7edd8 (patch) | |
tree | fa26395a0f6cca53cf5cb6e10189f989c5bfa847 /src/passes/LoopInvariantCodeMotion.cpp | |
parent | 87636dccd404a340d75acb1d96301581343f29ca (diff) | |
download | binaryen-db9124f1de0478dcac525009b6f1589b44a7edd8.tar.gz binaryen-db9124f1de0478dcac525009b6f1589b44a7edd8.tar.bz2 binaryen-db9124f1de0478dcac525009b6f1589b44a7edd8.zip |
Apply format changes from #2048 (#2059)
Mass change to apply clang-format to everything. We are applying this in a PR by me so the (git) blame is all mine ;) but @aheejin did all the work to get clang-format set up and all the manual work to tidy up some things to make the output nicer in #2048
Diffstat (limited to 'src/passes/LoopInvariantCodeMotion.cpp')
-rw-r--r-- | src/passes/LoopInvariantCodeMotion.cpp | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/src/passes/LoopInvariantCodeMotion.cpp b/src/passes/LoopInvariantCodeMotion.cpp index aec2f7ce5..e9f376bd3 100644 --- a/src/passes/LoopInvariantCodeMotion.cpp +++ b/src/passes/LoopInvariantCodeMotion.cpp @@ -24,16 +24,17 @@ #include <unordered_map> -#include "wasm.h" -#include "pass.h" -#include "wasm-builder.h" -#include "ir/local-graph.h" #include "ir/effects.h" #include "ir/find_all.h" +#include "ir/local-graph.h" +#include "pass.h" +#include "wasm-builder.h" +#include "wasm.h" namespace wasm { -struct LoopInvariantCodeMotion : public WalkerPass<ExpressionStackWalker<LoopInvariantCodeMotion>> { +struct LoopInvariantCodeMotion + : public WalkerPass<ExpressionStackWalker<LoopInvariantCodeMotion>> { bool isFunctionParallel() override { return true; } Pass* create() override { return new LoopInvariantCodeMotion; } @@ -128,11 +129,12 @@ struct LoopInvariantCodeMotion : public WalkerPass<ExpressionStackWalker<LoopInv // outside of the loop, in which case everything is good - // either they are before the loop and constant for us, or // they are after and don't matter. - if (effects.localsRead.empty() || !hasGetDependingOnLoopSet(curr, loopSets)) { - // We have checked if our gets are influenced by sets in the loop, and - // must also check if our sets interfere with them. To do so, assume - // temporarily that we are moving curr out; see if any sets remain for - // its indexes. + if (effects.localsRead.empty() || + !hasGetDependingOnLoopSet(curr, loopSets)) { + // We have checked if our gets are influenced by sets in the loop, + // and must also check if our sets interfere with them. To do so, + // assume temporarily that we are moving curr out; see if any sets + // remain for its indexes. FindAll<SetLocal> currSets(curr); for (auto* set : currSets.list) { assert(numSetsForIndex[set->index] > 0); @@ -187,8 +189,8 @@ struct LoopInvariantCodeMotion : public WalkerPass<ExpressionStackWalker<LoopInv bool interestingToMove(Expression* curr) { // In theory we could consider blocks, but then heavy nesting of // switch patterns would be heavy, and almost always pointless. - if (curr->type != none || curr->is<Nop>() || curr->is<Block>() - || curr->is<Loop>()) { + if (curr->type != none || curr->is<Nop>() || curr->is<Block>() || + curr->is<Loop>()) { return false; } // Don't move copies (set of a get, or set of a tee of a get, etc.), @@ -206,7 +208,8 @@ struct LoopInvariantCodeMotion : public WalkerPass<ExpressionStackWalker<LoopInv if (auto* set = curr->dynCast<SetLocal>()) { while (1) { auto* next = set->value->dynCast<SetLocal>(); - if (!next) break; + if (!next) + break; set = next; } if (set->value->is<GetLocal>() || set->value->is<Const>()) { @@ -223,7 +226,8 @@ struct LoopInvariantCodeMotion : public WalkerPass<ExpressionStackWalker<LoopInv for (auto* set : sets) { // nullptr means a parameter or zero-init value; // no danger to us. - if (!set) continue; + if (!set) + continue; // Check if the set is in the loop. If not, it's either before, // which is fine, or after, which is also fine - moving curr // to just outside the loop will preserve those relationships. @@ -238,9 +242,8 @@ struct LoopInvariantCodeMotion : public WalkerPass<ExpressionStackWalker<LoopInv } }; -Pass *createLoopInvariantCodeMotionPass() { +Pass* createLoopInvariantCodeMotionPass() { return new LoopInvariantCodeMotion(); } } // namespace wasm - |