18 #ifndef LLVM_ANALYSIS_DOMINANCEFRONTIERIMPL_H 19 #define LLVM_ANALYSIS_DOMINANCEFRONTIERIMPL_H 24 #include "llvm/Config/llvm-config.h" 35 template <
class BlockT>
50 template <
class BlockT,
bool IsPostDom>
52 assert(
find(BB) !=
end() &&
"Block is not in DominanceFrontier!");
58 template <
class BlockT,
bool IsPostDom>
61 assert(I !=
end() &&
"BB is not in DominanceFrontier!");
62 assert(I->second.count(Node) &&
"Node is not in DominanceFrontier of BB");
63 I->second.erase(Node);
66 template <
class BlockT,
bool IsPostDom>
69 assert(I !=
end() &&
"BB is not in DominanceFrontier!");
70 assert(I->second.count(Node) &&
"Node is not in DominanceFrontier of BB");
71 I->second.erase(Node);
74 template <
class BlockT,
bool IsPostDom>
77 std::set<BlockT *> tmpSet;
78 for (BlockT *BB : DS2)
81 for (
typename DomSetType::const_iterator
I = DS1.begin(),
E = DS1.end();
85 if (tmpSet.erase(Node) == 0)
90 if (!tmpSet.empty()) {
99 template <
class BlockT,
bool IsPostDom>
103 for (
typename DomSetMapType::const_iterator
I = Other.
begin(),
106 tmpFrontiers.insert(std::make_pair(
I->first,
I->second));
108 for (
typename DomSetMapType::iterator
I = tmpFrontiers.begin(),
109 E = tmpFrontiers.end();
111 BlockT *
Node =
I->first;
116 if (compareDomSet(
I->second, DFI->second))
120 tmpFrontiers.erase(Node);
123 if (!tmpFrontiers.empty())
129 template <
class BlockT,
bool IsPostDom>
132 OS <<
" DomFrontier for BB ";
134 I->first->printAsOperand(OS,
false);
136 OS <<
" <<exit node>>";
139 const std::set<BlockT *> &BBs =
I->second;
141 for (
const BlockT *BB : BBs) {
144 BB->printAsOperand(OS,
false);
146 OS <<
"<<exit node>>";
152 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 153 template <
class BlockT,
bool IsPostDom>
159 template <
class BlockT>
166 std::vector<DFCalculateWorkObject<BlockT>> workList;
172 assert(currentW &&
"Missing work object.");
178 assert(currentBB &&
"Invalid work object. Missing current Basic Block");
179 assert(currentNode &&
"Invalid work object. Missing current Node");
183 if (visited.
insert(currentBB).second) {
185 for (
const auto Succ : children<BlockT *>(currentBB)) {
187 if (DT[Succ]->getIDom() != currentNode)
195 bool visitChild =
false;
197 NE = currentNode->
end();
200 BlockT *childBB = IDominee->
getBlock();
201 if (visited.
count(childBB) == 0) {
203 childBB, currentBB, IDominee, currentNode));
216 typename DomSetType::const_iterator CDFI = S.begin(), CDFE = S.end();
218 for (; CDFI != CDFE; ++CDFI) {
220 parentSet.insert(*CDFI);
225 }
while (!workList.empty());
232 #endif // LLVM_ANALYSIS_DOMINANCEFRONTIERIMPL_H const_iterator end(StringRef path)
Get end iterator over path.
typename std::vector< DomTreeNodeBase *>::const_iterator const_iterator
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
This class represents lattice values for constants.
void addToFrontier(iterator I, BlockT *Node)
DominanceFrontierBase - Common base class for computing forward and inverse dominance frontiers for a...
bool properlyDominates(const DomTreeNodeBase< NodeT > *A, const DomTreeNodeBase< NodeT > *B) const
properlyDominates - Returns true iff A dominates B and A != B.
typename DomSetMapType::const_iterator const_iterator
typename DominanceFrontierBase< BlockT, false >::DomSetType DomSetType
void print(raw_ostream &OS) const
print - Convert to human readable form
std::map< BasicBlock *, DomSetType > DomSetMapType
void dump() const
dump - Dump the dominance frontier to dbgs().
const DomTreeNodeT * Node
Base class for the actual dominator tree node.
void removeFromFrontier(iterator I, BlockT *Node)
Core dominator tree base class.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
std::set< BasicBlock *> DomSetType
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
bool compare(DominanceFrontierBase &Other) const
compare - Return true if the other dominance frontier base matches this dominance frontier base...
auto find(R &&Range, const T &Val) -> decltype(adl_begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void removeBlock(BlockT *BB)
removeBlock - Remove basic block BB's frontier.
DFCalculateWorkObject(BlockT *B, BlockT *P, const DomTreeNodeT *N, const DomTreeNodeT *PN)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const DomSetType & calculate(const DomTreeT &DT, const DomTreeNodeT *Node)
This class implements an extremely fast bulk output stream that can only output to a stream...
This file defines a set of templates that efficiently compute a dominator tree over a generic graph...
const DomTreeNodeT * parentNode
bool compareDomSet(DomSetType &DS1, const DomSetType &DS2) const
compareDomSet - Return false if two domsets match.
typename DomSetMapType::iterator iterator