diff options
Diffstat (limited to 'src/cfg/liveness-traversal.h')
-rw-r--r-- | src/cfg/liveness-traversal.h | 27 |
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 |