17#ifndef LLVM_ANALYSIS_DOMINANCEFRONTIERIMPL_H
18#define LLVM_ANALYSIS_DOMINANCEFRONTIERIMPL_H
22#include "llvm/Config/llvm-config.h"
33template <
class BlockT>
48template <
class BlockT,
bool IsPostDom>
50 assert(
find(BB) != end() &&
"Block is not in DominanceFrontier!");
56template <
class BlockT,
bool IsPostDom>
59 assert(
I != end() &&
"BB is not in DominanceFrontier!");
60 I->second.insert(
Node);
63template <
class BlockT,
bool IsPostDom>
66 assert(
I != end() &&
"BB is not in DominanceFrontier!");
67 assert(
I->second.count(
Node) &&
"Node is not in DominanceFrontier of BB");
68 I->second.remove(
Node);
71template <
class BlockT,
bool IsPostDom>
74 std::set<BlockT *> tmpSet;
75 for (BlockT *BB : DS2)
82 if (tmpSet.erase(
Node) == 0)
87 if (!tmpSet.empty()) {
96template <
class BlockT,
bool IsPostDom>
103 tmpFrontiers.
insert(std::make_pair(
I->first,
I->second));
108 BlockT *
Node =
I->first;
113 if (compareDomSet(
I->second, DFI->second))
120 if (!tmpFrontiers.
empty())
126template <
class BlockT,
bool IsPostDom>
129 OS <<
" DomFrontier for BB ";
131 I->first->printAsOperand(
OS,
false);
133 OS <<
" <<exit node>>";
138 for (
const BlockT *BB : BBs) {
141 BB->printAsOperand(
OS,
false);
143 OS <<
"<<exit node>>";
149#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
150template <
class BlockT,
bool IsPostDom>
156template <
class BlockT>
160 BlockT *BB =
Node->getBlock();
163 std::vector<DFCalculateWorkObject<BlockT>> workList;
169 assert(currentW &&
"Missing work object.");
172 BlockT *parentBB = currentW->
parentBB;
175 assert(currentBB &&
"Invalid work object. Missing current Basic Block");
176 assert(currentNode &&
"Invalid work object. Missing current Node");
180 if (visited.
insert(currentBB).second) {
182 for (
const auto Succ : children<BlockT *>(currentBB)) {
184 if (DT[Succ]->getIDom() != currentNode)
192 bool visitChild =
false;
194 NE = currentNode->
end();
197 BlockT *childBB = IDominee->
getBlock();
198 if (visited.
count(childBB) == 0) {
200 childBB, currentBB, IDominee, currentNode));
213 typename DomSetType::const_iterator CDFI = S.begin(), CDFE = S.end();
214 DomSetType &parentSet = this->Frontiers[parentBB];
215 for (; CDFI != CDFE; ++CDFI) {
217 parentSet.insert(*CDFI);
222 }
while (!workList.empty());
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines a set of templates that efficiently compute a dominator tree over a generic graph.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallPtrSet class.
DFCalculateWorkObject(BlockT *B, BlockT *P, const DomTreeNodeT *N, const DomTreeNodeT *PN)
const DomTreeNodeT * parentNode
const DomTreeNodeT * Node
bool erase(const KeyT &Val)
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Base class for the actual dominator tree node.
typename SmallVector< DomTreeNodeBase *, 4 >::const_iterator const_iterator
DominanceFrontierBase - Common base class for computing forward and inverse dominance frontiers for a...
bool compare(DominanceFrontierBase &Other) const
compare - Return false if the other dominance frontier base matches this dominance frontier base.
void print(raw_ostream &OS) const
print - Convert to human readable form
typename DomSetMapType::iterator iterator
bool compareDomSet(DomSetType &DS1, const DomSetType &DS2) const
compareDomSet - Return false if two domsets match.
void removeFromFrontier(iterator I, BlockT *Node)
void dump() const
dump - Dump the dominance frontier to dbgs().
typename DomSetMapType::const_iterator const_iterator
void addToFrontier(iterator I, BlockT *Node)
void removeBlock(BlockT *BB)
removeBlock - Remove basic block BB's frontier.
Core dominator tree base class.
bool properlyDominates(const DomTreeNodeBase< NodeT > *A, const DomTreeNodeBase< NodeT > *B) const
properlyDominates - Returns true iff A dominates B and A != B.
const DomSetType & calculate(const DomTreeT &DT, const DomTreeNodeT *Node)
typename DominanceFrontierBase< BlockT, false >::DomSetType DomSetType
A vector that has set insertion semantics.
iterator end()
Get an iterator to the end of the SetVector.
typename vector_type::const_iterator const_iterator
iterator begin()
Get an iterator to the beginning of 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.
auto find(R &&Range, const T &Val)
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly.
Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.