Index: llvm/trunk/include/llvm/Analysis/DominanceFrontier.h =================================================================== --- llvm/trunk/include/llvm/Analysis/DominanceFrontier.h +++ llvm/trunk/include/llvm/Analysis/DominanceFrontier.h @@ -47,7 +47,8 @@ using BlockTraits = GraphTraits; DomSetMapType Frontiers; - std::vector Roots; + // Postdominators can have multiple roots. + SmallVector Roots; static constexpr bool IsPostDominators = IsPostDom; public: @@ -56,9 +57,7 @@ /// getRoots - Return the root blocks of the current CFG. This may include /// multiple blocks if we are computing post dominators. For forward /// dominators, this will always be a single block (the entry node). - inline const std::vector &getRoots() const { - return Roots; - } + const SmallVectorImpl &getRoots() const { return Roots; } BlockT *getRoot() const { assert(Roots.size() == 1 && "Should always have entry node!"); @@ -131,9 +130,9 @@ using DomSetType = typename DominanceFrontierBase::DomSetType; void analyze(DomTreeT &DT) { - this->Roots = DT.getRoots(); - assert(this->Roots.size() == 1 && + assert(DT.getRoots().size() == 1 && "Only one entry block for forward domfronts!"); + this->Roots = {DT.getRoot()}; calculate(DT, DT[this->Roots[0]]); } Index: llvm/trunk/include/llvm/CodeGen/MachineDominanceFrontier.h =================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineDominanceFrontier.h +++ llvm/trunk/include/llvm/CodeGen/MachineDominanceFrontier.h @@ -39,7 +39,7 @@ DominanceFrontierBase &getBase() { return Base; } - inline const std::vector &getRoots() const { + const SmallVectorImpl &getRoots() const { return Base.getRoots(); } Index: llvm/trunk/include/llvm/CodeGen/MachineDominators.h =================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineDominators.h +++ llvm/trunk/include/llvm/CodeGen/MachineDominators.h @@ -93,7 +93,7 @@ /// multiple blocks if we are computing post dominators. For forward /// dominators, this will always be a single block (the entry node). /// - inline const std::vector &getRoots() const { + inline const SmallVectorImpl &getRoots() const { applySplitCriticalEdges(); return DT->getRoots(); } Index: llvm/trunk/include/llvm/CodeGen/MachinePostDominators.h =================================================================== --- llvm/trunk/include/llvm/CodeGen/MachinePostDominators.h +++ llvm/trunk/include/llvm/CodeGen/MachinePostDominators.h @@ -37,7 +37,7 @@ FunctionPass *createMachinePostDominatorTreePass(); - const std::vector &getRoots() const { + const SmallVectorImpl &getRoots() const { return DT->getRoots(); } Index: llvm/trunk/include/llvm/Support/GenericDomTree.h =================================================================== --- llvm/trunk/include/llvm/Support/GenericDomTree.h +++ llvm/trunk/include/llvm/Support/GenericDomTree.h @@ -220,7 +220,8 @@ static constexpr bool IsPostDominator = IsPostDom; protected: - std::vector Roots; + // Dominators always have a single root, postdominators can have more. + SmallVector Roots; using DomTreeNodeMapType = DenseMap>>; @@ -264,7 +265,7 @@ /// multiple blocks if we are computing post dominators. For forward /// dominators, this will always be a single block (the entry node). /// - const std::vector &getRoots() const { return Roots; } + const SmallVectorImpl &getRoots() const { return Roots; } /// isPostDominator - Returns true if analysis based of postdoms ///