Index: llvm/trunk/include/llvm/IR/Dominators.h =================================================================== --- llvm/trunk/include/llvm/IR/Dominators.h +++ llvm/trunk/include/llvm/IR/Dominators.h @@ -37,19 +37,11 @@ extern template class DominatorTreeBase; namespace DomTreeBuilder { -extern template void Calculate( - DominatorTreeBaseByGraphTraits> &DT, Function &F); +using BBDomTree = DominatorTreeBase; -extern template void Calculate>( - DominatorTreeBaseByGraphTraits>> &DT, - Function &F); - -extern template bool Verify( - const DominatorTreeBaseByGraphTraits> &DT); - -extern template bool Verify>( - const DominatorTreeBaseByGraphTraits>> - &DT); +extern template void Calculate(BBDomTree &DT, Function &F); + +extern template bool Verify(const BBDomTree &DT); } // namespace DomTreeBuilder using DomTreeNode = DomTreeNodeBase; Index: llvm/trunk/include/llvm/Support/GenericDomTree.h =================================================================== --- llvm/trunk/include/llvm/Support/GenericDomTree.h +++ llvm/trunk/include/llvm/Support/GenericDomTree.h @@ -43,25 +43,10 @@ template class DominatorTreeBase; -namespace detail { - -template struct DominatorTreeBaseTraits { - static_assert(std::is_pointer::value, - "Currently NodeRef must be a pointer type."); - using type = DominatorTreeBase< - typename std::remove_pointer::type>; -}; - -} // end namespace detail - -template -using DominatorTreeBaseByGraphTraits = - typename detail::DominatorTreeBaseTraits::type; - /// \brief Base class for the actual dominator tree node. template class DomTreeNodeBase { friend struct PostDominatorTree; - template friend class DominatorTreeBase; + friend class DominatorTreeBase; NodeT *TheBB; DomTreeNodeBase *IDom; @@ -192,16 +177,16 @@ } namespace DomTreeBuilder { -template +template struct SemiNCAInfo; // The calculate routine is provided in a separate header but referenced here. -template -void Calculate(DominatorTreeBaseByGraphTraits> &DT, FuncT &F); +template +void Calculate(DomTreeT &DT, FuncT &F); // The verify function is provided in a separate header but referenced here. -template -bool Verify(const DominatorTreeBaseByGraphTraits> &DT); +template +bool Verify(const DomTreeT &DT); } // namespace DomTreeBuilder /// \brief Core dominator tree base class. @@ -221,10 +206,13 @@ mutable bool DFSInfoValid = false; mutable unsigned int SlowQueries = 0; - friend struct DomTreeBuilder::SemiNCAInfo; - using SNCAInfoTy = DomTreeBuilder::SemiNCAInfo; + friend struct DomTreeBuilder::SemiNCAInfo; public: + static_assert(std::is_pointer::NodeRef>::value, + "Currently DominatorTreeBase supports only pointer nodes"); + using NodeType = NodeT; + using NodePtr = NodeT *; explicit DominatorTreeBase(bool isPostDom) : IsPostDominators(isPostDom) {} DominatorTreeBase(DominatorTreeBase &&Arg) @@ -612,35 +600,29 @@ using TraitsTy = GraphTraits; reset(); - if (!this->IsPostDominators) { + if (!IsPostDominators) { // Initialize root NodeT *entry = TraitsTy::getEntryNode(&F); addRoot(entry); - - DomTreeBuilder::Calculate(*this, F); } else { // Initialize the roots list for (auto *Node : nodes(&F)) if (TraitsTy::child_begin(Node) == TraitsTy::child_end(Node)) addRoot(Node); - - DomTreeBuilder::Calculate>(*this, F); } + + DomTreeBuilder::Calculate(*this, F); } /// verify - check parent and sibling property - bool verify() const { - return this->isPostDominator() - ? DomTreeBuilder::Verify>(*this) - : DomTreeBuilder::Verify(*this); - } + bool verify() const { return DomTreeBuilder::Verify(*this); } protected: void addRoot(NodeT *BB) { this->Roots.push_back(BB); } void reset() { DomTreeNodes.clear(); - this->Roots.clear(); + Roots.clear(); RootNode = nullptr; DFSInfoValid = false; SlowQueries = 0; Index: llvm/trunk/include/llvm/Support/GenericDomTreeConstruction.h =================================================================== --- llvm/trunk/include/llvm/Support/GenericDomTreeConstruction.h +++ llvm/trunk/include/llvm/Support/GenericDomTreeConstruction.h @@ -49,13 +49,13 @@ } }; -// Information record used by Semi-NCA during tree construction. -template +template struct SemiNCAInfo { - using NodePtr = NodeT *; - using DomTreeT = DominatorTreeBase; + using NodePtr = typename DomTreeT::NodePtr; + using NodeT = typename DomTreeT::NodeType; using TreeNodePtr = DomTreeNodeBase *; + // Information record used by Semi-NCA during tree construction. struct InfoRec { unsigned DFSNum = 0; unsigned Parent = 0; @@ -524,23 +524,16 @@ } }; -template -void Calculate(DominatorTreeBaseByGraphTraits> &DT, - FuncT &F) { - using NodePtr = typename GraphTraits::NodeRef; - static_assert(std::is_pointer::value, - "NodePtr should be a pointer type"); - SemiNCAInfo::type> SNCA; + +template +void Calculate(DomTreeT &DT, FuncT &F) { + SemiNCAInfo SNCA; SNCA.calculateFromScratch(DT, GraphTraits::size(&F)); } -template -bool Verify(const DominatorTreeBaseByGraphTraits> &DT) { - using NodePtr = typename GraphTraits::NodeRef; - static_assert(std::is_pointer::value, - "NodePtr should be a pointer type"); - SemiNCAInfo::type> SNCA; - +template +bool Verify(const DomTreeT &DT) { + SemiNCAInfo SNCA; return SNCA.verifyReachability(DT) && SNCA.VerifyLevels(DT) && SNCA.verifyNCD(DT) && SNCA.verifyParentProperty(DT) && SNCA.verifySiblingProperty(DT); Index: llvm/trunk/lib/IR/Dominators.cpp =================================================================== --- llvm/trunk/lib/IR/Dominators.cpp +++ llvm/trunk/lib/IR/Dominators.cpp @@ -63,22 +63,12 @@ template class llvm::DomTreeNodeBase; template class llvm::DominatorTreeBase; -template void llvm::DomTreeBuilder::Calculate( - DominatorTreeBase< - typename std::remove_pointer::NodeRef>::type> - &DT, - Function &F); -template void llvm::DomTreeBuilder::Calculate>( - DominatorTreeBase>::NodeRef>::type> &DT, - Function &F); -template bool llvm::DomTreeBuilder::Verify( - const DominatorTreeBase< - typename std::remove_pointer::NodeRef>::type> - &DT); -template bool llvm::DomTreeBuilder::Verify>( - const DominatorTreeBase>::NodeRef>::type> &DT); +template void +llvm::DomTreeBuilder::Calculate( + DomTreeBuilder::BBDomTree &DT, Function &F); + +template bool llvm::DomTreeBuilder::Verify( + const DomTreeBuilder::BBDomTree &DT); bool DominatorTree::invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &) {