using BlockTraits = GraphTraits<BlockT *>;
DomSetMapType Frontiers;
- std::vector<BlockT *> Roots;
+ // Postdominators can have multiple roots.
+ SmallVector<BlockT *, IsPostDom ? 4 : 1> Roots;
static constexpr bool IsPostDominators = IsPostDom;
public:
/// 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<BlockT *> &getRoots() const {
- return Roots;
- }
+ const SmallVectorImpl<BlockT *> &getRoots() const { return Roots; }
BlockT *getRoot() const {
assert(Roots.size() == 1 && "Should always have entry node!");
using DomSetType = typename DominanceFrontierBase<BlockT, false>::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]]);
}
/// 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<MachineBasicBlock*> &getRoots() const {
+ inline const SmallVectorImpl<MachineBasicBlock*> &getRoots() const {
applySplitCriticalEdges();
return DT->getRoots();
}
static constexpr bool IsPostDominator = IsPostDom;
protected:
- std::vector<NodeT *> Roots;
+ // Dominators always have a single root, postdominators can have more.
+ SmallVector<NodeT *, IsPostDom ? 4 : 1> Roots;
using DomTreeNodeMapType =
DenseMap<NodeT *, std::unique_ptr<DomTreeNodeBase<NodeT>>>;
/// multiple blocks if we are computing post dominators. For forward
/// dominators, this will always be a single block (the entry node).
///
- const std::vector<NodeT *> &getRoots() const { return Roots; }
+ const SmallVectorImpl<NodeT *> &getRoots() const { return Roots; }
/// isPostDominator - Returns true if analysis based of postdoms
///