33 #ifndef LLVM_SUPPORT_GENERICDOMTREECONSTRUCTION_H 34 #define LLVM_SUPPORT_GENERICDOMTREECONSTRUCTION_H 45 #define DEBUG_TYPE "dom-tree-builder" 48 namespace DomTreeBuilder {
50 template <
typename DomTreeT>
52 using NodePtr =
typename DomTreeT::NodePtr;
55 using RootsT = decltype(DomTreeT::Roots);
56 static constexpr
bool IsPostDom = DomTreeT::IsPostDominator;
73 using UpdateT =
typename DomTreeT::UpdateType;
89 bool IsRecalculated =
false;
99 NumToNode = {
nullptr};
105 template <
bool Inverse>
110 auto RChildren =
reverse(children<NodePtr>(N));
111 return ResultTy(RChildren.begin(), RChildren.end());
115 auto IChildren = inverse_children<NodePtr>(
N);
116 return ResultTy(IChildren.begin(), IChildren.end());
119 using Tag = std::integral_constant<bool, Inverse>;
128 if (!BUI)
return Res;
135 auto FCIt = FutureChildren.find(N);
136 if (FCIt == FutureChildren.end())
return Res;
138 for (
auto ChildAndKind : FCIt->second) {
139 const NodePtr Child = ChildAndKind.getPointer();
147 &&
"Expected child not found in the CFG");
155 "Unexpected child found in the CFG");
167 auto InfoIt = NodeToInfo.
find(BB);
168 if (InfoIt == NodeToInfo.
end())
return nullptr;
170 return InfoIt->second.IDom;
174 if (
TreeNodePtr Node = DT.getNode(BB))
return Node;
180 assert(IDom || DT.DomTreeNodes[
nullptr]);
185 return (DT.DomTreeNodes[BB] = IDomNode->
addChild(
202 BP.
N->printAsOperand(O,
false);
215 template <
bool IsReverse = false,
typename DescendCondition>
217 unsigned AttachToNum) {
220 if (NodeToInfo.
count(V) != 0) NodeToInfo[V].
Parent = AttachToNum;
222 while (!WorkList.
empty()) {
224 auto &BBInfo = NodeToInfo[BB];
227 if (BBInfo.DFSNum != 0)
continue;
228 BBInfo.DFSNum = BBInfo.Semi = ++LastNum;
230 NumToNode.push_back(BB);
232 constexpr
bool Direction = IsReverse !=
IsPostDom;
235 const auto SIT = NodeToInfo.
find(Succ);
238 if (SIT != NodeToInfo.
end() && SIT->second.DFSNum != 0) {
239 if (Succ != BB) SIT->second.ReverseChildren.push_back(BB);
243 if (!Condition(BB, Succ))
continue;
247 auto &SuccInfo = NodeToInfo[Succ];
249 SuccInfo.Parent = LastNum;
250 SuccInfo.ReverseChildren.push_back(BB);
258 auto &VInInfo = NodeToInfo[VIn];
259 if (VInInfo.DFSNum < LastLinked)
265 if (VInInfo.Parent >= LastLinked)
268 while (!Work.
empty()) {
270 auto &VInfo = NodeToInfo[V];
271 NodePtr VAncestor = NumToNode[VInfo.Parent];
274 if (Visited.
insert(VAncestor).second && VInfo.Parent >= LastLinked) {
281 if (VInfo.Parent < LastLinked)
284 auto &VAInfo = NodeToInfo[VAncestor];
285 NodePtr VAncestorLabel = VAInfo.Label;
287 if (NodeToInfo[VAncestorLabel].
Semi < NodeToInfo[VLabel].
Semi)
288 VInfo.Label = VAncestorLabel;
289 VInfo.Parent = VAInfo.Parent;
292 return VInInfo.Label;
297 const unsigned NextDFSNum(NumToNode.size());
299 for (
unsigned i = 1; i < NextDFSNum; ++i) {
300 const NodePtr V = NumToNode[i];
301 auto &VInfo = NodeToInfo[V];
302 VInfo.IDom = NumToNode[VInfo.Parent];
306 for (
unsigned i = NextDFSNum - 1; i >= 2; --i) {
308 auto &WInfo = NodeToInfo[
W];
311 WInfo.Semi = WInfo.Parent;
312 for (
const auto &
N : WInfo.ReverseChildren) {
313 if (NodeToInfo.
count(
N) == 0)
318 if (TN && TN->
getLevel() < MinLevel)
321 unsigned SemiU = NodeToInfo[
eval(
N, i + 1)].Semi;
322 if (SemiU < WInfo.Semi) WInfo.Semi = SemiU;
330 for (
unsigned i = 2; i < NextDFSNum; ++i) {
332 auto &WInfo = NodeToInfo[
W];
333 const unsigned SDomNum = NodeToInfo[NumToNode[WInfo.Semi]].DFSNum;
334 NodePtr WIDomCandidate = WInfo.IDom;
335 while (NodeToInfo[WIDomCandidate].
DFSNum > SDomNum)
336 WIDomCandidate = NodeToInfo[WIDomCandidate].IDom;
338 WInfo.IDom = WIDomCandidate;
348 assert(IsPostDom &&
"Only postdominators have a virtual root");
349 assert(NumToNode.size() == 1 &&
"SNCAInfo must be freshly constructed");
351 auto &BBInfo = NodeToInfo[
nullptr];
352 BBInfo.DFSNum = BBInfo.Semi = 1;
353 BBInfo.Label =
nullptr;
355 NumToNode.push_back(
nullptr);
362 assert(N &&
"N must be a valid node");
367 assert(DT.Parent &&
"Parent not set");
375 assert(DT.Parent &&
"Parent pointer is not set");
387 SNCA.addVirtualRoot();
419 bool HasNonTrivialRoots =
false;
422 if (Total + 1 != Num) {
423 HasNonTrivialRoots =
true;
433 if (SNCA.NodeToInfo.count(
I) == 0) {
448 const unsigned NewNum = SNCA.runDFS<
true>(
I, Num,
AlwaysDescend, Num);
449 const NodePtr FurthestAway = SNCA.NumToNode[NewNum];
451 <<
"(non-trivial root): " 453 ConnectToExitBlock.
insert(FurthestAway);
454 Roots.push_back(FurthestAway);
455 LLVM_DEBUG(
dbgs() <<
"\t\t\tPrev DFSNum: " << Num <<
", new DFSNum: " 456 << NewNum <<
"\n\t\t\tRemoving DFS info\n");
457 for (
unsigned i = NewNum; i > Num; --i) {
458 const NodePtr N = SNCA.NumToNode[i];
461 SNCA.NodeToInfo.erase(N);
462 SNCA.NumToNode.pop_back();
464 const unsigned PrevNum = Num;
466 Num = SNCA.runDFS(FurthestAway, Num, AlwaysDescend, 1);
467 for (
unsigned i = PrevNum + 1; i <= Num; ++i)
474 LLVM_DEBUG(
dbgs() <<
"Total: " << Total <<
", Num: " << Num <<
"\n");
479 assert((Total + 1 == Num) &&
"Everything should have been visited");
503 assert(IsPostDom &&
"This function is for postdominators only");
508 for (
unsigned i = 0; i < Roots.size(); ++i) {
509 auto &Root = Roots[i];
513 <<
" remains a root\n");
516 const unsigned Num = SNCA.runDFS<
true>(Root, 0,
AlwaysDescend, 0);
519 for (
unsigned x = 2; x <= Num; ++x) {
520 const NodePtr N = SNCA.NumToNode[x];
540 template <
typename DescendCondition>
543 assert(DT.Roots.size() == 1 &&
"Dominators should have a singe root");
544 runDFS(DT.Roots[0], 0, DC, 0);
550 for (
const NodePtr Root : DT.Roots) Num =
runDFS(Root, Num, DC, 0);
569 dbgs() <<
"DomTree recalculated, skipping future batch updates\n");
572 if (DT.Roots.empty())
return;
577 NodePtr Root = IsPostDom ? nullptr : DT.Roots[0];
579 DT.RootNode = (DT.DomTreeNodes[Root] =
580 llvm::make_unique<DomTreeNodeBase<NodeT>>(Root,
nullptr))
582 SNCA.attachNewSubtree(DT, DT.RootNode);
587 NodeToInfo[NumToNode[1]].IDom = AttachTo->
getBlock();
589 for (
size_t i = 1, e = NumToNode.size(); i != e; ++i) {
595 if (DT.DomTreeNodes[W])
continue;
610 NodeToInfo[NumToNode[1]].IDom = AttachTo->
getBlock();
611 for (
size_t i = 1, e = NumToNode.size(); i != e; ++i) {
626 return First.first > Second.first;
630 std::priority_queue<BucketElementTy, SmallVector<BucketElementTy, 8>,
641 assert((From || IsPostDom) &&
642 "From has to be a valid CFG node or a virtual root");
643 assert(To &&
"Cannot be a nullptr");
650 if (!IsPostDom)
return;
655 (DT.DomTreeNodes[From] = VirtualRoot->
addChild(
658 DT.Roots.push_back(From);
661 DT.DFSInfoValid =
false;
675 assert(IsPostDom &&
"This function is only for postdominators");
678 if (!DT.isVirtualRoot(To->
getIDom()))
return false;
681 if (RIt == DT.Roots.end())
685 <<
" is no longer a root\n\t\tRebuilding the tree!!!\n");
695 assert(IsPostDom &&
"This function is only for postdominators");
705 if (DT.Roots.size() != Roots.size() ||
706 !std::is_permutation(DT.Roots.begin(), DT.Roots.end(), Roots.begin())) {
713 <<
"The entire tree needs to be rebuilt\n");
734 assert(NCDBlock || DT.isPostDominator());
743 if (NCD == To || NCD == ToIDom)
return;
748 <<
" as affected\n");
750 const unsigned ToLevel = To->
getLevel();
752 <<
" into a Bucket\n");
753 II.
Bucket.push({ToLevel, To});
755 while (!II.
Bucket.empty()) {
757 const unsigned CurrentLevel = CurrentNode->
getLevel();
762 II.
Visited.insert({CurrentNode, CurrentLevel});
777 const unsigned NCDLevel = NCD->
getLevel();
779 << RootLevel <<
"\n");
793 assert(SuccTN &&
"Unreachable successor found at reachable insertion");
794 const unsigned SuccLevel = SuccTN->
getLevel();
797 <<
", level = " << SuccLevel <<
"\n");
800 if (Processed.count(Next) > 0)
805 if (SuccLevel > RootLevel) {
807 if (II.
Visited.count(SuccTN) != 0) {
809 << II.
Visited[SuccTN] <<
"\n\t\t\tcurrent level " 810 << RootLevel <<
")\n");
814 if (II.
Visited[SuccTN] >= RootLevel)
820 II.
Visited.insert({SuccTN, RootLevel});
823 }
else if ((SuccLevel > NCDLevel + 1) &&
828 II.
Bucket.push({SuccLevel, SuccTN});
832 Processed.insert(Next);
833 }
while (!Stack.
empty());
853 dbgs() <<
"Updating levels for visited but not affected nodes\n");
880 for (
const auto &Edge : DiscoveredEdgesToReachable) {
893 &DiscoveredConnectingEdges) {
894 assert(!DT.getNode(Root) &&
"Root must not be reachable");
897 auto UnreachableDescender = [&DT, &DiscoveredConnectingEdges](
NodePtr From,
900 if (!ToTN)
return true;
902 DiscoveredConnectingEdges.push_back({From, ToTN});
907 SNCA.runDFS(Root, 0, UnreachableDescender, 0);
909 SNCA.attachNewSubtree(DT, Incoming);
916 assert(From && To &&
"Cannot disconnect nullptrs");
924 auto IsSuccessor = [BUI](
const NodePtr SuccCandidate,
const NodePtr Of) {
926 return llvm::find(Successors, SuccCandidate) != Successors.end();
929 assert(!IsSuccessor(To, From) &&
"Deleted edge still exists in the CFG!");
940 <<
") already unreachable -- there is no edge to delete\n");
944 const NodePtr NCDBlock = DT.findNearestCommonDominator(From, To);
949 DT.DFSInfoValid =
false;
978 assert(ToIDom || DT.isPostDominator());
984 if (!PrevIDomSubTree) {
991 const unsigned Level = ToIDomTN->getLevel();
993 return DT.getNode(To)->getLevel() >
Level;
1000 SNCA.runDFS(ToIDom, 0, DescendBelow, 0);
1002 SNCA.runSemiNCA(DT, Level);
1003 SNCA.reattachExistingSubtree(DT, PrevIDomSubTree);
1015 if (!DT.getNode(Pred))
continue;
1018 DT.findNearestCommonDominator(TN->
getBlock(), Pred);
1022 <<
" is reachable from support " 1044 LLVM_DEBUG(
dbgs() <<
"\tDeletion made a region reverse-unreachable\n");
1047 DT.Roots.push_back(ToTN->
getBlock());
1057 auto DescendAndCollect = [
Level, &AffectedQueue, &DT](
NodePtr, NodePtr To) {
1061 if (
llvm::find(AffectedQueue, To) == AffectedQueue.end())
1062 AffectedQueue.push_back(To);
1068 unsigned LastDFSNum =
1069 SNCA.runDFS(ToTN->
getBlock(), 0, DescendAndCollect, 0);
1075 for (
const NodePtr
N : AffectedQueue) {
1077 const NodePtr NCDBlock =
1079 assert(NCDBlock || DT.isPostDominator());
1098 for (
unsigned i = LastDFSNum; i > 0; --i) {
1099 const NodePtr
N = SNCA.NumToNode[i];
1107 if (MinNode == ToTN)
return;
1109 LLVM_DEBUG(
dbgs() <<
"DeleteUnreachable: running DFS with MinNode = " 1111 const unsigned MinLevel = MinNode->
getLevel();
1117 auto DescendBelow = [MinLevel, &DT](
NodePtr, NodePtr To) {
1119 return ToTN && ToTN->
getLevel() > MinLevel;
1121 SNCA.runDFS(MinNode->
getBlock(), 0, DescendBelow, 0);
1127 SNCA.runSemiNCA(DT, MinLevel);
1128 SNCA.reattachExistingSubtree(DT, PrevIDom);
1140 assert(ChIt != IDom->Children.end());
1141 std::swap(*ChIt, IDom->Children.back());
1142 IDom->Children.pop_back();
1144 DT.DomTreeNodes.erase(TN->
getBlock());
1152 const size_t NumUpdates = Updates.
size();
1153 if (NumUpdates == 0)
1158 if (NumUpdates == 1) {
1183 LLVM_DEBUG(
dbgs() <<
"About to apply " << NumLegalized <<
" updates\n");
1184 LLVM_DEBUG(
if (NumLegalized < 32)
for (
const auto &U
1186 <<
'\t' << U <<
"\n");
1224 for (
const auto &U : AllUpdates) {
1233 Result.
reserve(Operations.size());
1234 for (
auto &
Op : Operations) {
1235 const int NumInsertions =
Op.second;
1236 assert(
std::abs(NumInsertions) <= 1 &&
"Unbalanced operations!");
1237 if (NumInsertions == 0)
continue;
1247 for (
size_t i = 0, e = AllUpdates.size(); i != e; ++i) {
1248 const auto &U = AllUpdates[i];
1250 Operations[{U.getFrom(), U.getTo()}] = int(i);
1252 Operations[{U.getTo(), U.getFrom()}] = int(i);
1257 return Operations[{A.getFrom(), A.getTo()}] >
1258 Operations[{
B.getFrom(),
B.getTo()}];
1265 LLVM_DEBUG(
dbgs() <<
"Applying update: " << CurrentUpdate <<
"\n");
1271 assert(FS.back().getPointer() == CurrentUpdate.getTo() &&
1272 FS.back().getInt() == CurrentUpdate.getKind());
1277 assert(FP.back().getPointer() == CurrentUpdate.getFrom() &&
1278 FP.back().getInt() == CurrentUpdate.getKind());
1283 InsertEdge(DT, &BUI, CurrentUpdate.getFrom(), CurrentUpdate.getTo());
1285 DeleteEdge(DT, &BUI, CurrentUpdate.getFrom(), CurrentUpdate.getTo());
1298 if (!DT.Parent && !DT.Roots.empty()) {
1299 errs() <<
"Tree has no parent but has roots!\n";
1305 if (DT.Roots.empty()) {
1306 errs() <<
"Tree doesn't have a root!\n";
1312 errs() <<
"Tree's root is not its parent's entry node!\n";
1319 if (DT.Roots.size() != ComputedRoots.size() ||
1320 !std::is_permutation(DT.Roots.begin(), DT.Roots.end(),
1321 ComputedRoots.begin())) {
1322 errs() <<
"Tree has different roots than freshly computed ones!\n";
1323 errs() <<
"\tPDT roots: ";
1325 errs() <<
"\n\tComputed roots: ";
1326 for (
const NodePtr N : ComputedRoots)
1342 for (
auto &NodeToTN : DT.DomTreeNodes) {
1347 if (DT.isVirtualRoot(TN))
continue;
1349 if (NodeToInfo.
count(BB) == 0) {
1351 <<
" not found by DFS walk!\n";
1358 for (
const NodePtr N : NumToNode) {
1359 if (
N && !DT.getNode(
N)) {
1361 <<
" not found in the DomTree!\n";
1375 for (
auto &NodeToTN : DT.DomTreeNodes) {
1381 if (!IDom && TN->
getLevel() != 0) {
1383 <<
" has a nonzero level " << TN->
getLevel() <<
"!\n";
1391 << TN->
getLevel() <<
" while its IDom " 1407 if (!DT.DFSInfoValid || !DT.Parent)
1410 const NodePtr RootBB = IsPostDom ? nullptr : DT.getRoots()[0];
1413 auto PrintNodeAndDFSNums = [](
const TreeNodePtr TN) {
1415 << TN->getDFSNumOut() <<
'}';
1421 errs() <<
"DFSIn number for the tree root is not:\n\t";
1422 PrintNodeAndDFSNums(Root);
1430 for (
const auto &NodeToTN : DT.DomTreeNodes) {
1436 errs() <<
"Tree leaf should have DFSOut = DFSIn + 1:\n\t";
1437 PrintNodeAndDFSNums(Node);
1454 auto PrintChildrenError = [Node, &Children, PrintNodeAndDFSNums](
1458 errs() <<
"Incorrect DFS numbers for:\n\tParent ";
1459 PrintNodeAndDFSNums(Node);
1461 errs() <<
"\n\tChild ";
1462 PrintNodeAndDFSNums(FirstCh);
1465 errs() <<
"\n\tSecond child ";
1466 PrintNodeAndDFSNums(SecondCh);
1469 errs() <<
"\nAll children: ";
1471 PrintNodeAndDFSNums(Ch);
1479 if (Children.front()->getDFSNumIn() != Node->
getDFSNumIn() + 1) {
1480 PrintChildrenError(Children.front(),
nullptr);
1484 if (Children.back()->getDFSNumOut() + 1 != Node->
getDFSNumOut()) {
1485 PrintChildrenError(Children.back(),
nullptr);
1489 for (
size_t i = 0, e = Children.size() - 1; i != e; ++i) {
1490 if (Children[i]->getDFSNumOut() + 1 != Children[i + 1]->getDFSNumIn()) {
1491 PrintChildrenError(Children[i], Children[i + 1]);
1544 for (
auto &NodeToTN : DT.DomTreeNodes) {
1553 return From != BB && To != BB;
1557 if (NodeToInfo.
count(Child->getBlock()) != 0) {
1560 <<
" is removed!\n";
1577 for (
auto &NodeToTN : DT.DomTreeNodes) {
1587 return From != BBN && To != BBN;
1591 if (S ==
N)
continue;
1593 if (NodeToInfo.
count(S->getBlock()) == 0) {
1596 <<
" is removed!\n";
1617 FreshTree.recalculate(*DT.Parent);
1618 const bool Different = DT.compare(FreshTree);
1621 errs() << (DT.isPostDominator() ?
"Post" :
"")
1622 <<
"DominatorTree is different than a freshly computed one!\n" 1625 errs() <<
"\n\tFreshly computed tree:\n";
1626 FreshTree.print(
errs());
1634 template <
class DomTreeT>
1639 template <
class DomTreeT>
1641 typename DomTreeT::NodePtr To) {
1642 if (DT.isPostDominator())
std::swap(From, To);
1646 template <
class DomTreeT>
1648 typename DomTreeT::NodePtr To) {
1649 if (DT.isPostDominator())
std::swap(From, To);
1653 template <
class DomTreeT>
1659 template <
class DomTreeT>
1660 bool Verify(
const DomTreeT &DT,
typename DomTreeT::VerificationLevel VL) {
1665 if (!SNCA.IsSameAsFreshTree(DT))
1669 if (!SNCA.verifyRoots(DT) || !SNCA.verifyReachability(DT) ||
1670 !SNCA.VerifyLevels(DT) || !SNCA.VerifyDFSNumbers(DT))
1676 if (!SNCA.verifyParentProperty(DT))
1679 if (!SNCA.verifySiblingProperty(DT))
SmallDenseSet< TreeNodePtr, 8 > Affected
const T & front() const
front - Get the first element.
NodePtr getIDom(NodePtr BB) const
UpdateKind getKind() const
void push_back(const T &Elt)
static void UpdateInsertion(DomTreeT &DT, const BatchUpdatePtr BUI, const TreeNodePtr NCD, InsertionInfo &II)
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
DenseMap< NodePtr, InfoRec > NodeToInfo
static void EraseNode(DomTreeT &DT, const TreeNodePtr TN)
Compute iterated dominance frontiers using a linear time algorithm.
bool verifyReachability(const DomTreeT &DT)
std::error_code remove(const Twine &path, bool IgnoreNonExisting=true)
Remove path.
static void UpdateRootsAfterUpdate(DomTreeT &DT, const BatchUpdatePtr BUI)
void doFullDFSWalk(const DomTreeT &DT, DescendCondition DC)
SmallDenseMap< TreeNodePtr, unsigned, 8 > Visited
std::integral_constant< bool, Inverse > Tag
std::enable_if<!std::is_array< T >::value, std::unique_ptr< T > >::type make_unique(Args &&... args)
Constructs a new T() with the given args and returns a unique_ptr<T> which owns the object...
std::pair< unsigned, TreeNodePtr > BucketElementTy
void reserve(size_type N)
SmallVector< UpdateT, 4 > Updates
std::priority_queue< BucketElementTy, SmallVector< BucketElementTy, 8 >, DecreasingLevel > Bucket
static bool VerifyLevels(const DomTreeT &DT)
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
static void ApplyNextUpdate(DomTreeT &DT, BatchUpdateInfo &BUI)
decltype(DomTreeT::Roots) RootsT
NodePtr eval(NodePtr VIn, unsigned LastLinked)
void runSemiNCA(DomTreeT &DT, const unsigned MinLevel=0)
static ManagedStatic< DebugCounter > DC
static void RemoveRedundantRoots(const DomTreeT &DT, BatchUpdatePtr BUI, RootsT &Roots)
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly...
auto reverse(ContainerTy &&C, typename std::enable_if< has_rbegin< ContainerTy >::value >::type *=nullptr) -> decltype(make_range(C.rbegin(), C.rend()))
static bool IsSameAsFreshTree(const DomTreeT &DT)
bool operator()(const BucketElementTy &First, const BucketElementTy &Second) const
static void DeleteEdge(DomTreeT &DT, const BatchUpdatePtr BUI, const NodePtr From, const NodePtr To)
Base class for the actual dominator tree node.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
const std::vector< DomTreeNodeBase * > & getChildren() const
static bool HasForwardSuccessors(const NodePtr N, BatchUpdatePtr BUI)
bool verifySiblingProperty(const DomTreeT &DT)
typename DomTreeT::NodePtr NodePtr
unsigned runDFS(NodePtr V, unsigned LastNum, DescendCondition Condition, unsigned AttachToNum)
iterator find(const_arg_type_t< KeyT > Val)
unsigned getDFSNumIn() const
getDFSNumIn/getDFSNumOut - These return the DFS visitation order for nodes in the dominator tree...
static ResultTy Get(NodePtr N, std::integral_constant< bool, true >)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
typename DomTreeT::UpdateType UpdateT
PointerIntPair - This class implements a pair of a pointer and small integer.
size_t size() const
size - Get the array size.
DomTreeNodeBase * getIDom() const
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
static ResultTy Get(NodePtr N, BatchUpdatePtr BUI)
static void UpdateLevelsAfterInsertion(InsertionInfo &II)
BlockNamePrinter(NodePtr Block)
static RootsT FindRoots(const DomTreeT &DT, BatchUpdatePtr BUI)
static void LegalizeUpdates(ArrayRef< UpdateT > AllUpdates, SmallVectorImpl< UpdateT > &Result)
unsigned getDFSNumOut() const
void reserve(size_type NumEntries)
Grow the densemap so that it can contain at least NumEntries items before resizing again...
iterator erase(const_iterator CI)
SmallVector< NodePtr, 2 > ReverseChildren
static void DeleteReachable(DomTreeT &DT, const BatchUpdatePtr BUI, const TreeNodePtr FromTN, const TreeNodePtr ToTN)
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...
static bool UpdateRootsBeforeInsertion(DomTreeT &DT, const BatchUpdatePtr BUI, const TreeNodePtr From, const TreeNodePtr To)
void sort(IteratorTy Start, IteratorTy End)
static void ApplyUpdates(DomTreeT &DT, ArrayRef< UpdateT > Updates)
SmallVector< TreeNodePtr, 8 > AffectedQueue
bool verifyRoots(const DomTreeT &DT)
typename DomTreeT::NodeType NodeT
bool verifyParentProperty(const DomTreeT &DT)
static void VisitInsertion(DomTreeT &DT, const BatchUpdatePtr BUI, const TreeNodePtr TN, const unsigned RootLevel, const TreeNodePtr NCD, InsertionInfo &II)
static void CalculateFromScratch(DomTreeT &DT, BatchUpdatePtr BUI)
static constexpr bool IsPostDom
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
BlockNamePrinter(TreeNodePtr TN)
size_t getNumChildren() const
static bool HasProperSupport(DomTreeT &DT, const BatchUpdatePtr BUI, const TreeNodePtr TN)
LLVM_NODISCARD T pop_back_val()
static bool VerifyDFSNumbers(const DomTreeT &DT)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Implements a dense probed hash-table based set with some number of buckets stored inline...
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
static void DeleteUnreachable(DomTreeT &DT, const BatchUpdatePtr BUI, const TreeNodePtr ToTN)
bool Verify(const DomTreeT &DT, typename DomTreeT::VerificationLevel VL)
static bool AlwaysDescend(NodePtr, NodePtr)
friend raw_ostream & operator<<(raw_ostream &O, const BlockNamePrinter &BP)
std::unique_ptr< DomTreeNodeBase > addChild(std::unique_ptr< DomTreeNodeBase > C)
SemiNCAInfo(BatchUpdatePtr BUI)
SmallVector< TreeNodePtr, 8 > VisitedNotAffectedQueue
void Calculate(DomTreeT &DT)
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
iterator_range< typename GraphTraits< GraphType >::nodes_iterator > nodes(const GraphType &G)
void attachNewSubtree(DomTreeT &DT, const TreeNodePtr AttachTo)
LLVM_NODISCARD bool empty() const
void reattachExistingSubtree(DomTreeT &DT, const TreeNodePtr AttachTo)
APFloat abs(APFloat X)
Returns the absolute value of the argument.
static NodePtr GetEntryNode(const DomTreeT &DT)
static void InsertEdge(DomTreeT &DT, const BatchUpdatePtr BUI, const NodePtr From, const NodePtr To)
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
static void InsertReachable(DomTreeT &DT, const BatchUpdatePtr BUI, const TreeNodePtr From, const TreeNodePtr To)
static void ComputeUnreachableDominators(DomTreeT &DT, const BatchUpdatePtr BUI, const NodePtr Root, const TreeNodePtr Incoming, SmallVectorImpl< std::pair< NodePtr, TreeNodePtr >> &DiscoveredConnectingEdges)
std::vector< NodePtr > NumToNode
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This class implements an extremely fast bulk output stream that can only output to a stream...
unsigned getLevel() const
This file defines a set of templates that efficiently compute a dominator tree over a generic graph...
static void InsertUnreachable(DomTreeT &DT, const BatchUpdatePtr BUI, const TreeNodePtr From, const NodePtr To)
TreeNodePtr getNodeForBlock(NodePtr BB, DomTreeT &DT)
DenseMap< NodePtr, SmallVector< NodePtrAndKind, 4 > > FutureSuccessors
DenseMap< NodePtr, SmallVector< NodePtrAndKind, 4 > > FuturePredecessors
static ResultTy Get(NodePtr N, std::integral_constant< bool, false >)
BatchUpdateInfo * BatchUpdates
void setIDom(DomTreeNodeBase *NewIDom)