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>
79 BlockT *BB =
Node->getBlock();
81 std::vector<DFCalculateWorkObject<BlockT>> workList;
87 assert(currentW &&
"Missing work object.");
90 BlockT *parentBB = currentW->
parentBB;
91 const DomTreeNodeT *currentNode = currentW->
Node;
92 const DomTreeNodeT *parentNode = currentW->
parentNode;
93 assert(currentBB &&
"Invalid work object. Missing current Basic Block");
94 assert(currentNode &&
"Invalid work object. Missing current Node");
98 if (visited.
insert(currentBB).second) {
102 if (DT[Succ]->getIDom() != currentNode)
110 bool visitChild =
false;
111 for (
typename DomTreeNodeT::const_iterator NI = currentNode->begin(),
112 NE = currentNode->end();
114 DomTreeNodeT *IDominee = *NI;
115 BlockT *childBB = IDominee->getBlock();
116 if (visited.
count(childBB) == 0) {
117 workList.push_back(DFCalculateWorkObject<BlockT>(
118 childBB, currentBB, IDominee, currentNode));
130 typename DomSetType::const_iterator CDFI = S.
begin(), CDFE = S.
end();
131 DomSetType &parentSet = this->Frontiers[parentBB];
132 for (; CDFI != CDFE; ++CDFI) {
134 parentSet.insert(*CDFI);
139 }
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 print(raw_ostream &OS) const
print - Convert to human readable form
void dump() const
dump - Dump the dominance frontier to dbgs().
SetVector< BasicBlock * > DomSetType
typename DomSetMapType::const_iterator const_iterator
bool properlyDominates(const DomTreeNodeBase< NodeT > *A, const DomTreeNodeBase< NodeT > *B) const
properlyDominates - Returns true iff A dominates B and A != B.
void calculate(const DomTreeT &DT, const DomTreeNodeT *Node)
DomTreeBase< BlockT > DomTreeT
DomTreeNodeBase< BlockT > DomTreeNodeT
A vector that has set insertion semantics.
iterator end()
Get an iterator to the end of the SetVector.
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)