Index: include/llvm/Analysis/LoopInfo.h =================================================================== --- include/llvm/Analysis/LoopInfo.h +++ include/llvm/Analysis/LoopInfo.h @@ -622,7 +622,7 @@ } /// Create the loop forest using a stable algorithm. - void Analyze(DominatorTreeBase &DomTree); + void analyze(const DominatorTreeBase &DomTree); // Debugging void print(raw_ostream &OS) const; Index: include/llvm/Analysis/LoopInfoImpl.h =================================================================== --- include/llvm/Analysis/LoopInfoImpl.h +++ include/llvm/Analysis/LoopInfoImpl.h @@ -345,7 +345,7 @@ template static void discoverAndMapSubloop(LoopT *L, ArrayRef Backedges, LoopInfoBase *LI, - DominatorTreeBase &DomTree) { + const DominatorTreeBase &DomTree) { typedef GraphTraits > InvBlockTraits; unsigned NumBlocks = 0; @@ -468,10 +468,10 @@ /// insertions per block. template void LoopInfoBase:: -Analyze(DominatorTreeBase &DomTree) { +analyze(const DominatorTreeBase &DomTree) { // Postorder traversal of the dominator tree. - DomTreeNodeBase* DomRoot = DomTree.getRootNode(); + const DomTreeNodeBase* DomRoot = DomTree.getRootNode(); for (auto DomNode : post_order(DomRoot)) { BlockT *Header = DomNode->getBlock(); Index: include/llvm/CodeGen/MachineDominators.h =================================================================== --- include/llvm/CodeGen/MachineDominators.h +++ include/llvm/CodeGen/MachineDominators.h @@ -263,6 +263,21 @@ } }; +template <> struct GraphTraits { + typedef const MachineDomTreeNode NodeType; + typedef NodeType::const_iterator ChildIteratorType; + + static NodeType *getEntryNode(NodeType *N) { + return N; + } + static inline ChildIteratorType child_begin(NodeType* N) { + return N->begin(); + } + static inline ChildIteratorType child_end(NodeType* N) { + return N->end(); + } +}; + template <> struct GraphTraits : public GraphTraits { static NodeType *getEntryNode(MachineDominatorTree *DT) { Index: include/llvm/IR/Dominators.h =================================================================== --- include/llvm/IR/Dominators.h +++ include/llvm/IR/Dominators.h @@ -147,6 +147,31 @@ } }; +template <> struct GraphTraits { + typedef const DomTreeNode NodeType; + typedef NodeType::const_iterator ChildIteratorType; + + static NodeType *getEntryNode(NodeType *N) { + return N; + } + static inline ChildIteratorType child_begin(NodeType *N) { + return N->begin(); + } + static inline ChildIteratorType child_end(NodeType *N) { + return N->end(); + } + + typedef df_iterator nodes_iterator; + + static nodes_iterator nodes_begin(const DomTreeNode *N) { + return df_begin(getEntryNode(N)); + } + + static nodes_iterator nodes_end(const DomTreeNode *N) { + return df_end(getEntryNode(N)); + } +}; + template <> struct GraphTraits : public GraphTraits { static NodeType *getEntryNode(DominatorTree *DT) { Index: lib/Analysis/LoopInfo.cpp =================================================================== --- lib/Analysis/LoopInfo.cpp +++ lib/Analysis/LoopInfo.cpp @@ -675,7 +675,7 @@ // objects. I don't want to add that kind of complexity until the scope of // the problem is better understood. LoopInfo LI; - LI.Analyze(AM->getResult(F)); + LI.analyze(AM->getResult(F)); return LI; } @@ -698,7 +698,7 @@ bool LoopInfoWrapperPass::runOnFunction(Function &) { releaseMemory(); - LI.Analyze(getAnalysis().getDomTree()); + LI.analyze(getAnalysis().getDomTree()); return false; } Index: lib/CodeGen/MachineLoopInfo.cpp =================================================================== --- lib/CodeGen/MachineLoopInfo.cpp +++ lib/CodeGen/MachineLoopInfo.cpp @@ -37,7 +37,7 @@ bool MachineLoopInfo::runOnMachineFunction(MachineFunction &) { releaseMemory(); - LI.Analyze(getAnalysis().getBase()); + LI.analyze(getAnalysis().getBase()); return false; }