summaryrefslogtreecommitdiff
path: root/src/passes/RedundantSetElimination.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2019-04-26 16:59:41 -0700
committerGitHub <noreply@github.com>2019-04-26 16:59:41 -0700
commitdb9124f1de0478dcac525009b6f1589b44a7edd8 (patch)
treefa26395a0f6cca53cf5cb6e10189f989c5bfa847 /src/passes/RedundantSetElimination.cpp
parent87636dccd404a340d75acb1d96301581343f29ca (diff)
downloadbinaryen-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/RedundantSetElimination.cpp')
-rw-r--r--src/passes/RedundantSetElimination.cpp43
1 files changed, 28 insertions, 15 deletions
diff --git a/src/passes/RedundantSetElimination.cpp b/src/passes/RedundantSetElimination.cpp
index 6f39fce9f..e03020da0 100644
--- a/src/passes/RedundantSetElimination.cpp
+++ b/src/passes/RedundantSetElimination.cpp
@@ -33,13 +33,13 @@
// here).
//
-#include <wasm.h>
-#include <pass.h>
-#include <wasm-builder.h>
#include <cfg/cfg-traversal.h>
#include <ir/literal-utils.h>
#include <ir/utils.h>
+#include <pass.h>
#include <support/unique_deferring_queue.h>
+#include <wasm-builder.h>
+#include <wasm.h>
namespace wasm {
@@ -57,7 +57,10 @@ struct Info {
std::vector<Expression**> setps;
};
-struct RedundantSetElimination : public WalkerPass<CFGWalker<RedundantSetElimination, Visitor<RedundantSetElimination>, Info>> {
+struct RedundantSetElimination
+ : public WalkerPass<CFGWalker<RedundantSetElimination,
+ Visitor<RedundantSetElimination>,
+ Info>> {
bool isFunctionParallel() override { return true; }
Pass* create() override { return new RedundantSetElimination(); }
@@ -66,7 +69,8 @@ struct RedundantSetElimination : public WalkerPass<CFGWalker<RedundantSetElimina
// cfg traversal work
- static void doVisitSetLocal(RedundantSetElimination* self, Expression** currp) {
+ static void doVisitSetLocal(RedundantSetElimination* self,
+ Expression** currp) {
if (self->currBasicBlock) {
self->currBasicBlock->contents.setps.push_back(currp);
}
@@ -77,7 +81,8 @@ struct RedundantSetElimination : public WalkerPass<CFGWalker<RedundantSetElimina
void doWalkFunction(Function* func) {
numLocals = func->getNumLocals();
// create the CFG by walking the IR
- CFGWalker<RedundantSetElimination, Visitor<RedundantSetElimination>, Info>::doWalkFunction(func);
+ CFGWalker<RedundantSetElimination, Visitor<RedundantSetElimination>, Info>::
+ doWalkFunction(func);
// flow values across blocks
flowValues(func);
// remove redundant sets
@@ -88,8 +93,10 @@ struct RedundantSetElimination : public WalkerPass<CFGWalker<RedundantSetElimina
Index nextValue = 1; // 0 is reserved for the "unseen value"
std::unordered_map<Literal, Index> literalValues; // each constant has a value
- std::unordered_map<Expression*, Index> expressionValues; // each value can have a value
- std::unordered_map<BasicBlock*, std::unordered_map<Index, Index>> blockMergeValues; // each block has values for each merge
+ std::unordered_map<Expression*, Index>
+ expressionValues; // each value can have a value
+ std::unordered_map<BasicBlock*, std::unordered_map<Index, Index>>
+ blockMergeValues; // each block has values for each merge
Index getUnseenValue() { // we haven't seen this location yet
return 0;
@@ -130,17 +137,20 @@ struct RedundantSetElimination : public WalkerPass<CFGWalker<RedundantSetElimina
return iter->second;
}
#ifdef RSE_DEBUG
- std::cout << "new block-merge value for " << block << " : " << index << '\n';
+ std::cout << "new block-merge value for " << block << " : " << index
+ << '\n';
#endif
return mergeValues[index] = getUniqueValue();
}
bool isBlockMergeValue(BasicBlock* block, Index index, Index value) {
auto iter = blockMergeValues.find(block);
- if (iter == blockMergeValues.end()) return false;
+ if (iter == blockMergeValues.end())
+ return false;
auto& mergeValues = iter->second;
auto iter2 = mergeValues.find(index);
- if (iter2 == mergeValues.end()) return false;
+ if (iter2 == mergeValues.end())
+ return false;
return value == iter2->second;
}
@@ -172,7 +182,8 @@ struct RedundantSetElimination : public WalkerPass<CFGWalker<RedundantSetElimina
#endif
start[i] = getUniqueValue();
} else {
- start[i] = getLiteralValue(Literal::makeZero(func->getLocalType(i)));
+ start[i] =
+ getLiteralValue(Literal::makeZero(func->getLocalType(i)));
}
}
} else {
@@ -274,7 +285,8 @@ struct RedundantSetElimination : public WalkerPass<CFGWalker<RedundantSetElimina
#ifdef RSE_DEBUG
dump("start", curr->contents.start);
#endif
- // flow values through it, then add those we can reach if they need an update.
+ // flow values through it, then add those we can reach if they need an
+ // update.
auto currValues = curr->contents.start; // we'll modify this as we go
auto& setps = curr->contents.setps;
for (auto** setp : setps) {
@@ -351,7 +363,8 @@ struct RedundantSetElimination : public WalkerPass<CFGWalker<RedundantSetElimina
}
}
for (Index i = 0; i < block->contents.start.size(); i++) {
- std::cout << " start[" << i << "] = " << block->contents.start[i] << '\n';
+ std::cout << " start[" << i << "] = " << block->contents.start[i]
+ << '\n';
}
for (auto** setp : block->contents.setps) {
std::cout << " " << *setp << '\n';
@@ -370,7 +383,7 @@ struct RedundantSetElimination : public WalkerPass<CFGWalker<RedundantSetElimina
} // namespace
-Pass *createRedundantSetEliminationPass() {
+Pass* createRedundantSetEliminationPass() {
return new RedundantSetElimination();
}