LLVM  5.0.0
Public Types | Public Member Functions | Static Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Friends | List of all members
llvm::DominatorTreeBase< N, IsPostDom > Class Template Reference

Core dominator tree base class. More...

#include "llvm/Analysis/LoopInfo.h"

Inheritance diagram for llvm::DominatorTreeBase< N, IsPostDom >:
[legend]
Collaboration diagram for llvm::DominatorTreeBase< N, IsPostDom >:
[legend]

Public Types

using NodeType = NodeT
 
using NodePtr = NodeT *
 

Public Member Functions

 DominatorTreeBase ()
 
 DominatorTreeBase (DominatorTreeBase &&Arg)
 
DominatorTreeBase & operator= (DominatorTreeBase &&RHS)
 
 DominatorTreeBase (const DominatorTreeBase &)=delete
 
DominatorTreeBase & operator= (const DominatorTreeBase &)=delete
 
const std::vector< NodeT * > & getRoots () const
 getRoots - Return the root blocks of the current CFG. More...
 
bool isPostDominator () const
 isPostDominator - Returns true if analysis based of postdoms More...
 
bool compare (const DominatorTreeBase &Other) const
 compare - Return false if the other dominator tree base matches this dominator tree base. More...
 
void releaseMemory ()
 
DomTreeNodeBase< NodeT > * getNode (NodeT *BB) const
 getNode - return the (Post)DominatorTree node for the specified basic block. More...
 
DomTreeNodeBase< NodeT > * operator[] (NodeT *BB) const
 See getNode. More...
 
DomTreeNodeBase< NodeT > * getRootNode ()
 getRootNode - This returns the entry node for the CFG of the function. More...
 
const DomTreeNodeBase< NodeT > * getRootNode () const
 
void getDescendants (NodeT *R, SmallVectorImpl< NodeT * > &Result) const
 Get all nodes dominated by R, including R itself. More...
 
bool properlyDominates (const DomTreeNodeBase< NodeT > *A, const DomTreeNodeBase< NodeT > *B) const
 properlyDominates - Returns true iff A dominates B and A != B. More...
 
bool properlyDominates (const NodeT *A, const NodeT *B) const
 
bool isReachableFromEntry (const NodeT *A) const
 isReachableFromEntry - Return true if A is dominated by the entry block of the function containing it. More...
 
bool isReachableFromEntry (const DomTreeNodeBase< NodeT > *A) const
 
bool dominates (const DomTreeNodeBase< NodeT > *A, const DomTreeNodeBase< NodeT > *B) const
 dominates - Returns true iff A dominates B. More...
 
bool dominates (const NodeT *A, const NodeT *B) const
 
NodeT * getRoot () const
 
NodeT * findNearestCommonDominator (NodeT *A, NodeT *B) const
 findNearestCommonDominator - Find nearest common dominator basic block for basic block A and B. More...
 
const NodeT * findNearestCommonDominator (const NodeT *A, const NodeT *B) const
 
bool isVirtualRoot (const DomTreeNodeBase< NodeT > *A) const
 
void insertEdge (NodeT *From, NodeT *To)
 Inform the dominator tree about a CFG edge insertion and update the tree. More...
 
void deleteEdge (NodeT *From, NodeT *To)
 Inform the dominator tree about a CFG edge deletion and update the tree. More...
 
DomTreeNodeBase< NodeT > * addNewBlock (NodeT *BB, NodeT *DomBB)
 Add a new node to the dominator tree information. More...
 
DomTreeNodeBase< NodeT > * setNewRoot (NodeT *BB)
 Add a new node to the forward dominator tree and make it a new root. More...
 
void changeImmediateDominator (DomTreeNodeBase< NodeT > *N, DomTreeNodeBase< NodeT > *NewIDom)
 changeImmediateDominator - This method is used to update the dominator tree information when a node's immediate dominator changes. More...
 
void changeImmediateDominator (NodeT *BB, NodeT *NewBB)
 
void eraseNode (NodeT *BB)
 eraseNode - Removes a node from the dominator tree. More...
 
void splitBlock (NodeT *NewBB)
 splitBlock - BB is split and now it has one successor. More...
 
void print (raw_ostream &O) const
 print - Convert to human readable form More...
 
void updateDFSNumbers () const
 updateDFSNumbers - Assign In and Out numbers to the nodes while walking dominator tree in dfs order. More...
 
template<class FT >
void recalculate (FT &F)
 recalculate - compute a dominator tree for the given function More...
 
bool verify () const
 verify - check parent and sibling property More...
 

Static Public Attributes

static constexpr bool IsPostDominator = IsPostDom
 

Protected Types

using DomTreeNodeMapType = DenseMap< NodeT *, std::unique_ptr< DomTreeNodeBase< NodeT >>>
 
using ParentPtr = decltype(std::declval< NodeT * >() ->getParent())
 

Protected Member Functions

void addRoot (NodeT *BB)
 
void reset ()
 
template<class N >
void Split (typename GraphTraits< N >::NodeRef NewBB)
 
template<>
void addRoot (MachineBasicBlock *MBB)
 

Protected Attributes

std::vector< NodeT * > Roots
 
DomTreeNodeMapType DomTreeNodes
 
DomTreeNodeBase< NodeT > * RootNode
 
ParentPtr Parent = nullptr
 
bool DFSInfoValid = false
 
unsigned int SlowQueries = 0
 

Friends

struct DomTreeBuilder::SemiNCAInfo< DominatorTreeBase >
 

Detailed Description

template<class N, bool IsPostDom>
class llvm::DominatorTreeBase< N, IsPostDom >

Core dominator tree base class.

This class is a generic template over graph nodes. It is instantiated for various graphs in the LLVM IR or in the code generator.

Definition at line 60 of file LoopInfo.h.

Member Typedef Documentation

template<class N, bool IsPostDom>
using llvm::DominatorTreeBase< N, IsPostDom >::DomTreeNodeMapType = DenseMap<NodeT *, std::unique_ptr<DomTreeNodeBase<NodeT>>>
protected

Definition at line 215 of file GenericDomTree.h.

template<class N, bool IsPostDom>
using llvm::DominatorTreeBase< N, IsPostDom >::NodePtr = NodeT *

Definition at line 230 of file GenericDomTree.h.

template<class N, bool IsPostDom>
using llvm::DominatorTreeBase< N, IsPostDom >::NodeType = NodeT

Definition at line 229 of file GenericDomTree.h.

template<class N, bool IsPostDom>
using llvm::DominatorTreeBase< N, IsPostDom >::ParentPtr = decltype(std::declval<NodeT *>()->getParent())
protected

Definition at line 218 of file GenericDomTree.h.

Constructor & Destructor Documentation

template<class N, bool IsPostDom>
llvm::DominatorTreeBase< N, IsPostDom >::DominatorTreeBase ( )
inline

Definition at line 233 of file GenericDomTree.h.

template<class N, bool IsPostDom>
llvm::DominatorTreeBase< N, IsPostDom >::DominatorTreeBase ( DominatorTreeBase< N, IsPostDom > &&  Arg)
inline

Definition at line 235 of file GenericDomTree.h.

template<class N, bool IsPostDom>
llvm::DominatorTreeBase< N, IsPostDom >::DominatorTreeBase ( const DominatorTreeBase< N, IsPostDom > &  )
delete

Member Function Documentation

template<class N, bool IsPostDom>
DomTreeNodeBase<NodeT>* llvm::DominatorTreeBase< N, IsPostDom >::addNewBlock ( NodeT *  BB,
NodeT *  DomBB 
)
inline

Add a new node to the dominator tree information.

This creates a new node as a child of DomBB dominator node, linking it into the children list of the immediate dominator.

Parameters
BBNew node in CFG.
DomBBCFG node that is dominator for BB.
Returns
New dominator tree node that represents new CFG node.

Definition at line 505 of file GenericDomTree.h.

Referenced by cloneLoopBlocks(), CloneLoopBlocks(), llvm::cloneLoopWithPreheader(), llvm::DominatorTreeBase< BasicBlock, false >::Split(), llvm::SplitBlock(), llvm::SplitBlockAndInsertIfThen(), llvm::UnrollLoop(), and unswitchTrivialSwitch().

template<>
void llvm::DominatorTreeBase< MachineBasicBlock, false >::addRoot ( MachineBasicBlock *  MBB)
inlineprotected

Definition at line 32 of file MachineDominators.h.

template<class N, bool IsPostDom>
void llvm::DominatorTreeBase< N, IsPostDom >::addRoot ( NodeT *  BB)
inlineprotected
template<class N, bool IsPostDom>
void llvm::DominatorTreeBase< N, IsPostDom >::changeImmediateDominator ( DomTreeNodeBase< NodeT > *  N,
DomTreeNodeBase< NodeT > *  NewIDom 
)
inline
template<class N, bool IsPostDom>
void llvm::DominatorTreeBase< N, IsPostDom >::changeImmediateDominator ( NodeT *  BB,
NodeT *  NewBB 
)
inline

Definition at line 550 of file GenericDomTree.h.

template<class N, bool IsPostDom>
bool llvm::DominatorTreeBase< N, IsPostDom >::compare ( const DominatorTreeBase< N, IsPostDom > &  Other) const
inline

compare - Return false if the other dominator tree base matches this dominator tree base.

Otherwise return true.

Definition at line 271 of file GenericDomTree.h.

template<class N, bool IsPostDom>
void llvm::DominatorTreeBase< N, IsPostDom >::deleteEdge ( NodeT *  From,
NodeT *  To 
)
inline

Inform the dominator tree about a CFG edge deletion and update the tree.

This function has to be called just after making the update on the actual CFG. There cannot be any other updates that the dominator tree doesn't know about. The only exception is when the deletion that the tree is informed about makes some (domominator) subtree unreachable – in this case, it is fine to perform deletions within this subtree.

Note that for postdominators it automatically takes care of deleting a reverse edge internally (so there's no need to swap the parameters).

Definition at line 488 of file GenericDomTree.h.

template<class N, bool IsPostDom>
bool llvm::DominatorTreeBase< N, IsPostDom >::dominates ( const DomTreeNodeBase< NodeT > *  A,
const DomTreeNodeBase< NodeT > *  B 
) const
inline

dominates - Returns true iff A dominates B.

Note that this is not a constant time operation!

Definition at line 364 of file GenericDomTree.h.

Referenced by llvm::LoopInfoBase< N, M >::analyze(), isFullPostDominator(), llvm::DominatorTreeBase< BasicBlock, false >::properlyDominates(), and llvm::DominatorTreeBase< BasicBlock, false >::Split().

template<typename NodeT , bool IsPostDom>
bool llvm::DominatorTreeBase< NodeT, IsPostDom >::dominates ( const NodeT *  A,
const NodeT *  B 
) const

Definition at line 777 of file GenericDomTree.h.

template<class N, bool IsPostDom>
void llvm::DominatorTreeBase< N, IsPostDom >::eraseNode ( NodeT *  BB)
inline

eraseNode - Removes a node from the dominator tree.

Block must not dominate any other blocks. Removes node from its immediate dominator's children list. Deletes dominator node associated with basic block BB.

Definition at line 557 of file GenericDomTree.h.

Referenced by deleteDeadLoop(), foldBlockIntoPredecessor(), llvm::MergeBasicBlockIntoOnlyPred(), llvm::MergeBlockIntoPredecessor(), and simplifyOneLoop().

template<class N, bool IsPostDom>
NodeT* llvm::DominatorTreeBase< N, IsPostDom >::findNearestCommonDominator ( NodeT *  A,
NodeT *  B 
) const
inline

findNearestCommonDominator - Find nearest common dominator basic block for basic block A and B.

If there is no such block then return NULL.

Definition at line 416 of file GenericDomTree.h.

Referenced by llvm::DominatorTreeBase< BasicBlock, false >::findNearestCommonDominator(), getInsertPointForUses(), nearest_common_dominator(), llvm::DominatorTreeBase< BasicBlock, false >::Split(), llvm::UnrollLoop(), and updateLoopExitIDom().

template<class N, bool IsPostDom>
const NodeT* llvm::DominatorTreeBase< N, IsPostDom >::findNearestCommonDominator ( const NodeT *  A,
const NodeT *  B 
) const
inline

Definition at line 444 of file GenericDomTree.h.

template<class N, bool IsPostDom>
void llvm::DominatorTreeBase< N, IsPostDom >::getDescendants ( NodeT *  R,
SmallVectorImpl< NodeT * > &  Result 
) const
inline

Get all nodes dominated by R, including R itself.

Definition at line 322 of file GenericDomTree.h.

template<class N, bool IsPostDom>
DomTreeNodeBase<NodeT>* llvm::DominatorTreeBase< N, IsPostDom >::getNode ( NodeT *  BB) const
inline
template<class N, bool IsPostDom>
NodeT* llvm::DominatorTreeBase< N, IsPostDom >::getRoot ( ) const
inline

Definition at line 409 of file GenericDomTree.h.

Referenced by nearest_common_dominatee().

template<class N, bool IsPostDom>
DomTreeNodeBase<NodeT>* llvm::DominatorTreeBase< N, IsPostDom >::getRootNode ( )
inline

getRootNode - This returns the entry node for the CFG of the function.

If this tree represents the post-dominance relations for a function, however, this root may be a node with the block == NULL. This is the case when there are multiple exit nodes from a particular function. Consumers of post-dominance information must be capable of dealing with this possibility.

Definition at line 318 of file GenericDomTree.h.

Referenced by llvm::LoopInfoBase< N, M >::analyze(), llvm::DominatorTree::compare(), llvm::GraphTraits< PostDominatorTree * >::getEntryNode(), llvm::GraphTraits< DominatorTree * >::getEntryNode(), llvm::DOTGraphTraits< DominatorTree * >::getNodeLabel(), llvm::DOTGraphTraits< PostDominatorTree * >::getNodeLabel(), llvm::MemorySSA::OptimizeUses::optimizeUses(), llvm::DominatorTreeBase< BasicBlock, false >::print(), llvm::DominatorTreeBase< BasicBlock, false >::updateDFSNumbers(), and llvm::MachineDominatorTree::verifyDomTree().

template<class N, bool IsPostDom>
const DomTreeNodeBase<NodeT>* llvm::DominatorTreeBase< N, IsPostDom >::getRootNode ( ) const
inline

Definition at line 319 of file GenericDomTree.h.

template<class N, bool IsPostDom>
const std::vector<NodeT *>& llvm::DominatorTreeBase< N, IsPostDom >::getRoots ( ) const
inline

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).

Definition at line 263 of file GenericDomTree.h.

Referenced by llvm::ForwardDominanceFrontierBase< BasicBlock >::analyze().

template<class N, bool IsPostDom>
void llvm::DominatorTreeBase< N, IsPostDom >::insertEdge ( NodeT *  From,
NodeT *  To 
)
inline

Inform the dominator tree about a CFG edge insertion and update the tree.

This function has to be called just before or just after making the update on the actual CFG. There cannot be any other updates that the dominator tree doesn't know about.

Note that for postdominators it automatically takes care of inserting a reverse edge internally (so there's no need to swap the parameters).

Definition at line 469 of file GenericDomTree.h.

template<class N, bool IsPostDom>
bool llvm::DominatorTreeBase< N, IsPostDom >::isPostDominator ( ) const
inline
template<class N, bool IsPostDom>
bool llvm::DominatorTreeBase< N, IsPostDom >::isReachableFromEntry ( const NodeT *  A) const
inline
template<class N, bool IsPostDom>
bool llvm::DominatorTreeBase< N, IsPostDom >::isReachableFromEntry ( const DomTreeNodeBase< NodeT > *  A) const
inline

Definition at line 359 of file GenericDomTree.h.

template<class N, bool IsPostDom>
bool llvm::DominatorTreeBase< N, IsPostDom >::isVirtualRoot ( const DomTreeNodeBase< NodeT > *  A) const
inline

Definition at line 452 of file GenericDomTree.h.

template<class N, bool IsPostDom>
DominatorTreeBase& llvm::DominatorTreeBase< N, IsPostDom >::operator= ( DominatorTreeBase< N, IsPostDom > &&  RHS)
inline

Definition at line 245 of file GenericDomTree.h.

template<class N, bool IsPostDom>
DominatorTreeBase& llvm::DominatorTreeBase< N, IsPostDom >::operator= ( const DominatorTreeBase< N, IsPostDom > &  )
delete
template<class N, bool IsPostDom>
DomTreeNodeBase<NodeT>* llvm::DominatorTreeBase< N, IsPostDom >::operator[] ( NodeT *  BB) const
inline

See getNode.

Definition at line 309 of file GenericDomTree.h.

template<class N, bool IsPostDom>
void llvm::DominatorTreeBase< N, IsPostDom >::print ( raw_ostream &  O) const
inline
template<class N, bool IsPostDom>
bool llvm::DominatorTreeBase< N, IsPostDom >::properlyDominates ( const DomTreeNodeBase< NodeT > *  A,
const DomTreeNodeBase< NodeT > *  B 
) const
inline

properlyDominates - Returns true iff A dominates B and A != B.

Note that this is not a constant time operation!

Definition at line 340 of file GenericDomTree.h.

Referenced by llvm::ForwardDominanceFrontierBase< BlockT >::calculate(), ConstructSSAForLoadSet(), isLoadInvariantInLoop(), isLoopInvariant(), llvm::slpvectorizer::BoUpSLP::optimizeGatherSequence(), and llvm::replaceDominatedUsesWith().

template<typename NodeT , bool IsPostDom>
bool llvm::DominatorTreeBase< NodeT, IsPostDom >::properlyDominates ( const NodeT *  A,
const NodeT *  B 
) const

Definition at line 789 of file GenericDomTree.h.

template<class N, bool IsPostDom>
template<class FT >
void llvm::DominatorTreeBase< N, IsPostDom >::recalculate ( FT &  F)
inline
template<class N, bool IsPostDom>
void llvm::DominatorTreeBase< N, IsPostDom >::releaseMemory ( )
inline
template<class N, bool IsPostDom>
void llvm::DominatorTreeBase< N, IsPostDom >::reset ( )
inlineprotected
template<class N, bool IsPostDom>
DomTreeNodeBase<NodeT>* llvm::DominatorTreeBase< N, IsPostDom >::setNewRoot ( NodeT *  BB)
inline

Add a new node to the forward dominator tree and make it a new root.

Parameters
BBNew node in CFG.
Returns
New dominator tree node that represents new CFG node.

Definition at line 519 of file GenericDomTree.h.

template<class N, bool IsPostDom>
template<class N >
void llvm::DominatorTreeBase< N, IsPostDom >::Split ( typename GraphTraits< N >::NodeRef  NewBB)
inlineprotected

Definition at line 690 of file GenericDomTree.h.

template<class N, bool IsPostDom>
void llvm::DominatorTreeBase< N, IsPostDom >::splitBlock ( NodeT *  NewBB)
inline

splitBlock - BB is split and now it has one successor.

Update dominator tree to reflect this change.

Definition at line 578 of file GenericDomTree.h.

Referenced by insertUniqueBackedgeBlock(), and UpdateAnalysisInformation().

template<class N, bool IsPostDom>
void llvm::DominatorTreeBase< N, IsPostDom >::updateDFSNumbers ( ) const
inline

updateDFSNumbers - Assign In and Out numbers to the nodes while walking dominator tree in dfs order.

Definition at line 604 of file GenericDomTree.h.

Referenced by llvm::DominatorTreeBase< BasicBlock, false >::dominates().

template<class N, bool IsPostDom>
bool llvm::DominatorTreeBase< N, IsPostDom >::verify ( ) const
inline

verify - check parent and sibling property

Definition at line 673 of file GenericDomTree.h.

Friends And Related Function Documentation

template<class N, bool IsPostDom>
friend struct DomTreeBuilder::SemiNCAInfo< DominatorTreeBase >
friend

Definition at line 224 of file GenericDomTree.h.

Member Data Documentation

template<class N, bool IsPostDom>
bool llvm::DominatorTreeBase< N, IsPostDom >::DFSInfoValid = false
mutableprotected
template<class N, bool IsPostDom>
DomTreeNodeMapType llvm::DominatorTreeBase< N, IsPostDom >::DomTreeNodes
protected
template<class N, bool IsPostDom>
constexpr bool llvm::DominatorTreeBase< N, IsPostDom >::IsPostDominator = IsPostDom
static
template<class N, bool IsPostDom>
ParentPtr llvm::DominatorTreeBase< N, IsPostDom >::Parent = nullptr
protected
template<class N, bool IsPostDom>
DomTreeNodeBase<NodeT>* llvm::DominatorTreeBase< N, IsPostDom >::RootNode
protected
template<class N, bool IsPostDom>
std::vector<NodeT *> llvm::DominatorTreeBase< N, IsPostDom >::Roots
protected
template<class N, bool IsPostDom>
unsigned int llvm::DominatorTreeBase< N, IsPostDom >::SlowQueries = 0
mutableprotected

The documentation for this class was generated from the following files: