summaryrefslogtreecommitdiff
path: root/src/cfg/liveness-traversal.h
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2019-05-01 14:48:41 -0700
committerGitHub <noreply@github.com>2019-05-01 14:48:41 -0700
commit2bd3758a22131cfd6925b3fd995657b211095c90 (patch)
tree2a38a48ab68c00ed1b55e885f86014bbdda92ff2 /src/cfg/liveness-traversal.h
parent73709b4da08d285c2237c8c23a54ba53274c0c7f (diff)
downloadbinaryen-2bd3758a22131cfd6925b3fd995657b211095c90.tar.gz
binaryen-2bd3758a22131cfd6925b3fd995657b211095c90.tar.bz2
binaryen-2bd3758a22131cfd6925b3fd995657b211095c90.zip
clang-tidy braces changes (#2075)
Applies the changes in #2065, and temprarily disables the hook since it's too slow to run on a change this large. We should re-enable it in a later commit.
Diffstat (limited to 'src/cfg/liveness-traversal.h')
-rw-r--r--src/cfg/liveness-traversal.h27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/cfg/liveness-traversal.h b/src/cfg/liveness-traversal.h
index b26898460..a0ce214bc 100644
--- a/src/cfg/liveness-traversal.h
+++ b/src/cfg/liveness-traversal.h
@@ -50,10 +50,12 @@ struct LivenessAction {
LivenessAction(What what, Index index, Expression** origin)
: what(what), index(index), origin(origin), effective(false) {
assert(what != Other);
- if (what == Get)
+ if (what == Get) {
assert((*origin)->is<GetLocal>());
- if (what == Set)
+ }
+ if (what == Set) {
assert((*origin)->is<SetLocal>());
+ }
}
LivenessAction(Expression** origin) : what(Other), origin(origin) {}
@@ -153,14 +155,17 @@ struct LivenessWalker : public CFGWalker<SubType, VisitorType, Liveness> {
// need to count to see if worth it.
// TODO: an if can have two copies
GetLocal* getCopy(SetLocal* set) {
- if (auto* get = set->value->dynCast<GetLocal>())
+ if (auto* get = set->value->dynCast<GetLocal>()) {
return get;
+ }
if (auto* iff = set->value->dynCast<If>()) {
- if (auto* get = iff->ifTrue->dynCast<GetLocal>())
+ if (auto* get = iff->ifTrue->dynCast<GetLocal>()) {
return get;
+ }
if (iff->ifFalse) {
- if (auto* get = iff->ifFalse->dynCast<GetLocal>())
+ if (auto* get = iff->ifFalse->dynCast<GetLocal>()) {
return get;
+ }
}
}
return nullptr;
@@ -188,8 +193,9 @@ struct LivenessWalker : public CFGWalker<SubType, VisitorType, Liveness> {
// keep working while stuff is flowing
std::unordered_set<BasicBlock*> queue;
for (auto& curr : CFGWalker<SubType, VisitorType, Liveness>::basicBlocks) {
- if (liveBlocks.count(curr.get()) == 0)
+ if (liveBlocks.count(curr.get()) == 0) {
continue; // ignore dead blocks
+ }
queue.insert(curr.get());
// do the first scan through the block, starting with nothing live at the
// end, and updating the liveness at the start
@@ -203,15 +209,17 @@ struct LivenessWalker : public CFGWalker<SubType, VisitorType, Liveness> {
auto* curr = *iter;
queue.erase(iter);
LocalSet live;
- if (!mergeStartsAndCheckChange(curr->out, curr->contents.end, live))
+ if (!mergeStartsAndCheckChange(curr->out, curr->contents.end, live)) {
continue;
+ }
assert(curr->contents.end.size() < live.size());
curr->contents.end = live;
scanLivenessThroughActions(curr->contents.actions, live);
// liveness is now calculated at the start. if something
// changed, all predecessor blocks need recomputation
- if (curr->contents.start == live)
+ if (curr->contents.start == live) {
continue;
+ }
assert(curr->contents.start.size() < live.size());
curr->contents.start = live;
for (auto* in : curr->in) {
@@ -226,8 +234,9 @@ struct LivenessWalker : public CFGWalker<SubType, VisitorType, Liveness> {
bool mergeStartsAndCheckChange(std::vector<BasicBlock*>& blocks,
LocalSet& old,
LocalSet& ret) {
- if (blocks.size() == 0)
+ if (blocks.size() == 0) {
return false;
+ }
ret = blocks[0]->contents.start;
if (blocks.size() > 1) {
// more than one, so we must merge