17#ifndef LLVM_ANALYSIS_DOMINANCEFRONTIERIMPL_H
18#define LLVM_ANALYSIS_DOMINANCEFRONTIERIMPL_H
22#include "llvm/Config/llvm-config.h"
31template <
class BlockT>
46template <
class BlockT,
bool IsPostDom>
49 OS <<
" DomFrontier for BB ";
51 I->first->printAsOperand(OS,
false);
53 OS <<
" <<exit node>>";
58 for (
const BlockT *BB : BBs) {
61 BB->printAsOperand(OS,
false);
63 OS <<
"<<exit node>>";
69#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
70template <
class BlockT,
bool IsPostDom>
76template <
class BlockT,
bool IsPostDom>
82 "Multiple roots for forward dominators?");
85 std::vector<DFCalculateWorkObject<BlockT>> workList;
92 assert(currentW &&
"Missing work object.");
95 BlockT *parentBB = currentW->
parentBB;
98 assert(currentNode &&
"Invalid work object. Missing current Node");
100 "Invalid work object. Missing current Basic Block");
107 if (currentBB && visited.
insert(currentBB).second) {
112 if (DT[Child]->getIDom() != currentNode)
120 bool visitChild =
false;
121 for (
typename DomTreeNodeT::const_iterator NI = currentNode->
begin(),
122 NE = currentNode->
end();
124 DomTreeNodeT *IDominee = *NI;
125 BlockT *childBB = IDominee->getBlock();
126 if (visited.
count(childBB) == 0) {
127 workList.push_back(DFCalculateWorkObject<BlockT>(
128 childBB, currentBB, IDominee, currentNode));
136 if (RootNode == currentNode) {
142 assert(IsPostDom &&
"For forward frontiers only root node (processed "
143 "above) might not have a parent.");
149 DomSetType &S = this->Frontiers[currentBB];
150 typename DomSetType::const_iterator CDFI = S.
begin(), CDFE = S.end();
151 DomSetType &parentSet = this->Frontiers[parentBB];
152 for (; CDFI != CDFE; ++CDFI) {
154 parentSet.insert(*CDFI);
158 }
while (!workList.empty());
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file defines a set of templates that efficiently compute a dominator tree over a generic graph.
This file defines the SmallPtrSet class.
DFCalculateWorkObject(BlockT *B, BlockT *P, const DomTreeNodeT *N, const DomTreeNodeT *PN)
const DomTreeNodeT * parentNode
DomTreeNodeBase< BlockT > DomTreeNodeT
const DomTreeNodeT * Node
Base class for the actual dominator tree node.
void analyze(const DomTreeT &DT)
DominatorTreeBase< BlockT, IsPostDom > DomTreeT
void print(raw_ostream &OS) const
print - Convert to human readable form
void dump() const
dump - Dump the dominance frontier to dbgs().
DomTreeNodeBase< BlockT > DomTreeNodeT
SetVector< BasicBlock * > DomSetType
typename DomSetMapType::const_iterator const_iterator
DomTreeNodeBase< NodeT > * getRootNode()
getRootNode - This returns the entry node for the CFG of the function.
root_iterator root_begin()
bool properlyDominates(const DomTreeNodeBase< NodeT > *A, const DomTreeNodeBase< NodeT > *B) const
properlyDominates - Returns true iff A dominates B and A != B.
bool isVirtualRoot(const DomTreeNodeBase< NodeT > *A) const
A vector that has set insertion semantics.
iterator begin()
Get an iterator to the beginning of the SetVector.
bool insert(const value_type &X)
Insert a new element into the SetVector.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This class implements an extremely fast bulk output stream that can only output to a stream.
This is an optimization pass for GlobalISel generic memory operations.
Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr, unsigned DynamicVGPRBlockSize=0)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
iterator_range< typename GraphTraits< GraphType >::ChildIteratorType > children(const typename GraphTraits< GraphType >::NodeRef &G)