Mercurial > hg > Members > tobaru > cbc > CbC_llvm
diff lib/Analysis/IteratedDominanceFrontier.cpp @ 120:1172e4bd9c6f
update 4.0.0
author | mir3636 |
---|---|
date | Fri, 25 Nov 2016 19:14:25 +0900 |
parents | afa8332a0e37 |
children | 803732b1fca8 |
line wrap: on
line diff
--- a/lib/Analysis/IteratedDominanceFrontier.cpp Tue Jan 26 22:56:36 2016 +0900 +++ b/lib/Analysis/IteratedDominanceFrontier.cpp Fri Nov 25 19:14:25 2016 +0900 @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -/// \brief Compute iterated dominance frontiers using a linear time algorithm. +// Compute iterated dominance frontiers using a linear time algorithm. // //===----------------------------------------------------------------------===// @@ -16,9 +16,10 @@ #include "llvm/IR/Dominators.h" #include <queue> -using namespace llvm; - -void IDFCalculator::calculate(SmallVectorImpl<BasicBlock *> &PHIBlocks) { +namespace llvm { +template <class NodeTy> +void IDFCalculator<NodeTy>::calculate( + SmallVectorImpl<BasicBlock *> &PHIBlocks) { // If we haven't computed dominator tree levels, do so now. if (DomLevels.empty()) { for (auto DFI = df_begin(DT.getRootNode()), DFE = df_end(DT.getRootNode()); @@ -61,8 +62,12 @@ while (!Worklist.empty()) { DomTreeNode *Node = Worklist.pop_back_val(); BasicBlock *BB = Node->getBlock(); - - for (auto Succ : successors(BB)) { + // Succ is the successor in the direction we are calculating IDF, so it is + // successor for IDF, and predecessor for Reverse IDF. + for (auto SuccIter = GraphTraits<NodeTy>::child_begin(BB), + End = GraphTraits<NodeTy>::child_end(BB); + SuccIter != End; ++SuccIter) { + BasicBlock *Succ = *SuccIter; DomTreeNode *SuccNode = DT.getNode(Succ); // Quickly skip all CFG edges that are also dominator tree edges instead @@ -93,3 +98,7 @@ } } } + +template class IDFCalculator<BasicBlock *>; +template class IDFCalculator<Inverse<BasicBlock *>>; +}