diff --git a/llvm/include/llvm/CodeGen/MachineBasicBlock.h b/llvm/include/llvm/CodeGen/MachineBasicBlock.h --- a/llvm/include/llvm/CodeGen/MachineBasicBlock.h +++ b/llvm/include/llvm/CodeGen/MachineBasicBlock.h @@ -105,6 +105,7 @@ RegisterMaskPair(MCPhysReg PhysReg, LaneBitmask LaneMask) : PhysReg(PhysReg), LaneMask(LaneMask) {} }; + using ParentPtrTy = MachineFunction *; private: using Instructions = ilist>; diff --git a/llvm/include/llvm/IR/BasicBlock.h b/llvm/include/llvm/IR/BasicBlock.h --- a/llvm/include/llvm/IR/BasicBlock.h +++ b/llvm/include/llvm/IR/BasicBlock.h @@ -89,6 +89,8 @@ using reverse_iterator = InstListType::reverse_iterator; using const_reverse_iterator = InstListType::const_reverse_iterator; + using ParentPtrTy = Function *; + // These functions and classes need access to the instruction list. friend void Instruction::removeFromParent(); friend iplist::iterator Instruction::eraseFromParent(); diff --git a/llvm/include/llvm/Support/GenericDomTree.h b/llvm/include/llvm/Support/GenericDomTree.h --- a/llvm/include/llvm/Support/GenericDomTree.h +++ b/llvm/include/llvm/Support/GenericDomTree.h @@ -14,7 +14,9 @@ /// /// Unlike ADT/* graph algorithms, generic dominator tree has more requirements /// on the graph's NodeRef. The NodeRef should be a pointer and, -/// NodeRef->getParent() must return the parent node that is also a pointer. +/// either NodeRef->getParent() must return the parent node that is also a +/// pointer or DomTreeBase::getParent needs to be specialized to return the +/// parent for NodeRef. /// /// FIXME: Maybe GenericDomTree needs a TreeTraits, instead of GraphTraits. /// @@ -231,7 +233,7 @@ "Currently DominatorTreeBase supports only pointer nodes"); using NodeType = NodeT; using NodePtr = NodeT *; - using ParentPtr = decltype(std::declval()->getParent()); + using ParentPtr = typename NodeT::ParentPtrTy; static_assert(std::is_pointer::value, "Currently NodeT's parent must be a pointer type"); using ParentType = std::remove_pointer_t; @@ -463,17 +465,19 @@ return this->Roots[0]; } + ParentPtr getParent(NodeT *B) const { return B->getParent(); } + /// Find nearest common dominator basic block for basic block A and B. A and B /// must have tree nodes. NodeT *findNearestCommonDominator(NodeT *A, NodeT *B) const { assert(A && B && "Pointers are not valid"); - assert(A->getParent() == B->getParent() && + assert(getParent(A) == getParent(B) && "Two blocks are not in same function"); // If either A or B is a entry block then it is nearest common dominator // (for forward-dominators). if (!isPostDominator()) { - NodeT &Entry = A->getParent()->front(); + NodeT &Entry = getParent(A)->front(); if (A == &Entry || B == &Entry) return &Entry; } @@ -584,8 +588,8 @@ void insertEdge(NodeT *From, NodeT *To) { assert(From); assert(To); - assert(From->getParent() == Parent); - assert(To->getParent() == Parent); + assert(getParent(From) == Parent); + assert(getParent(To) == Parent); DomTreeBuilder::InsertEdge(*this, From, To); } @@ -602,8 +606,8 @@ void deleteEdge(NodeT *From, NodeT *To) { assert(From); assert(To); - assert(From->getParent() == Parent); - assert(To->getParent() == Parent); + assert(getParent(From) == Parent); + assert(getParent(To) == Parent); DomTreeBuilder::DeleteEdge(*this, From, To); } diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h --- a/llvm/lib/Transforms/Vectorize/VPlan.h +++ b/llvm/lib/Transforms/Vectorize/VPlan.h @@ -448,6 +448,8 @@ using VPBlocksTy = SmallVectorImpl; + using ParentPtrTy = VPRegionBlock *; + virtual ~VPBlockBase() = default; const std::string &getName() const { return Name; }