18 #ifndef LLVM_ANALYSIS_DOMINANCEFRONTIERIMPL_H
19 #define LLVM_ANALYSIS_DOMINANCEFRONTIERIMPL_H
28 template <
class BlockT>
42 template <
class BlockT>
44 assert(
find(BB) !=
end() &&
"Block is not in DominanceFrontier!");
50 template <
class BlockT>
53 assert(I !=
end() &&
"BB is not in DominanceFrontier!");
54 assert(I->second.count(Node) &&
"Node is not in DominanceFrontier of BB");
55 I->second.erase(Node);
58 template <
class BlockT>
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>
69 std::set<BlockT *> tmpSet;
70 for (BlockT *BB : DS2)
73 for (
typename DomSetType::const_iterator
I = DS1.begin(),
E = DS1.end();
77 if (tmpSet.erase(Node) == 0)
82 if (!tmpSet.empty()) {
91 template <
class BlockT>
95 for (
typename DomSetMapType::const_iterator
I = Other.
begin(),
98 tmpFrontiers.insert(std::make_pair(
I->first,
I->second));
100 for (
typename DomSetMapType::iterator
I = tmpFrontiers.begin(),
101 E = tmpFrontiers.end();
103 BlockT *Node =
I->first;
108 if (compareDomSet(
I->second, DFI->second))
112 tmpFrontiers.erase(Node);
115 if (!tmpFrontiers.empty())
121 template <
class BlockT>
124 OS <<
" DomFrontier for BB ";
126 I->first->printAsOperand(OS,
false);
128 OS <<
" <<exit node>>";
131 const std::set<BlockT *> &BBs =
I->second;
133 for (
const BlockT *BB : BBs) {
136 BB->printAsOperand(OS,
false);
138 OS <<
"<<exit node>>";
144 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
145 template <
class BlockT>
151 template <
class BlockT>
158 std::vector<DFCalculateWorkObject<BlockT>> workList;
164 assert(currentW &&
"Missing work object.");
167 BlockT *parentBB = currentW->
parentBB;
170 assert(currentBB &&
"Invalid work object. Missing current Basic Block");
171 assert(currentNode &&
"Invalid work object. Missing current Node");
175 if (visited.
insert(currentBB).second) {
177 for (
auto SI = BlockTraits::child_begin(currentBB),
178 SE = BlockTraits::child_end(currentBB);
181 if (DT[*
SI]->getIDom() != currentNode)
189 bool visitChild =
false;
191 NE = currentNode->
end();
194 BlockT *childBB = IDominee->
getBlock();
195 if (visited.
count(childBB) == 0) {
197 childBB, currentBB, IDominee, currentNode));
210 typename DomSetType::const_iterator CDFI = S.begin(), CDFE = S.end();
211 DomSetType &parentSet = this->Frontiers[parentBB];
212 for (; CDFI != CDFE; ++CDFI) {
214 parentSet.insert(*CDFI);
219 }
while (!workList.empty());
const_iterator end(StringRef path)
Get end iterator over path.
bool properlyDominates(const DomTreeNodeBase< NodeT > *A, const DomTreeNodeBase< NodeT > *B) const
properlyDominates - Returns true iff A dominates B and A != B.
std::set< BlockT * > DomSetType
size_type count(PtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
DominanceFrontierBase - Common base class for computing forward and inverse dominance frontiers for a...
const_iterator begin(StringRef path)
Get begin iterator over path.
bool compareDomSet(DomSetType &DS1, const DomSetType &DS2) const
compareDomSet - Return false if two domsets match.
const DomTreeNodeT * Node
Base class for the actual dominator tree node.
static GCRegistry::Add< OcamlGC > B("ocaml","ocaml 3.10-compatible GC")
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
Core dominator tree base class.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
void removeFromFrontier(iterator I, BlockT *Node)
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
auto find(R &&Range, const T &Val) -> decltype(std::begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
std::map< BlockT *, DomSetType > DomSetMapType
std::vector< DomTreeNodeBase< NodeT > * >::const_iterator const_iterator
void dump() const
dump - Dump the dominance frontier to dbgs().
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
DomSetMapType::iterator iterator
DominanceFrontierBase< BlockT >::DomSetType DomSetType
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())
void print(raw_ostream &OS) const
print - Convert to human readable form
void addToFrontier(iterator I, BlockT *Node)
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...
DomSetMapType::const_iterator const_iterator
This file defines a set of templates that efficiently compute a dominator tree over a generic graph...
DomTreeNodeBase< BlockT > DomTreeNodeT
bool compare(DominanceFrontierBase< BlockT > &Other) const
compare - Return true if the other dominance frontier base matches this dominance frontier base...
const DomTreeNodeT * parentNode