23#ifndef LLVM_SUPPORT_GENERICITERATEDDOMINANCEFRONTIER_H
24#define LLVM_SUPPORT_GENERICITERATEDDOMINANCEFRONTIER_H
61 std::conditional_t<IsPostDom, Inverse<NodeTy *>, NodeTy *>;
69 : DT(DT), ChildrenGetter(
C) {}
86 LiveInBlocks = &Blocks;
93 LiveInBlocks =
nullptr;
108 bool useLiveIn =
false;
119template <
class NodeTy,
bool IsPostDom>
122 using OrderedNodeTy =
130template <
class NodeTy,
bool IsPostDom>
137 using DomTreeNodePair =
138 std::pair<DomTreeNodeBase<NodeTy> *, std::pair<unsigned, unsigned>>;
139 using IDFPriorityQueue =
140 std::priority_queue<DomTreeNodePair, SmallVector<DomTreeNodePair, 32>,
145 DT.updateDFSNumbers();
151 unsigned NumNodes = RootNode ? RootNode->
getDFSNumOut() : 0;
157 for (NodeTy *BB : *DefBlocks)
159 PQ.push({
Node, std::make_pair(
Node->getLevel(),
Node->getDFSNumIn())});
160 VisitedWorklist[
Node->getDFSNumIn()] =
true;
163 while (!PQ.empty()) {
164 DomTreeNodePair RootPair = PQ.top();
167 unsigned RootLevel = RootPair.second.first;
177 while (!Worklist.
empty()) {
179 NodeTy *BB =
Node->getBlock();
182 auto DoWork = [&](NodeTy *Succ) {
185 const unsigned SuccLevel = SuccNode->
getLevel();
186 if (SuccLevel > RootLevel)
189 if (std::exchange(VisitedPQ[SuccNode->
getDFSNumIn()],
true))
192 NodeTy *SuccBB = SuccNode->
getBlock();
193 if (useLiveIn && !LiveInBlocks->count(SuccBB))
197 if (!DefBlocks->count(SuccBB))
198 PQ.push(std::make_pair(
199 SuccNode, std::make_pair(SuccLevel, SuccNode->
getDFSNumIn())));
202 for (
auto *Succ : ChildrenGetter.get(BB))
205 for (
auto DomChild : *
Node) {
206 if (!std::exchange(VisitedWorklist[DomChild->getDFSNumIn()],
true))
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
This file defines a set of templates that efficiently compute a dominator tree over a generic graph.
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
Base class for the actual dominator tree node.
unsigned getDFSNumIn() const
getDFSNumIn/getDFSNumOut - These return the DFS visitation order for nodes in the dominator tree.
unsigned getLevel() const
unsigned getDFSNumOut() const
Core dominator tree base class.
IDFCalculatorBase(DominatorTreeBase< NodeTy, IsPostDom > &DT)
void resetLiveInBlocks()
Reset the live-in block set to be empty, and tell the IDF calculator to not use liveness anymore.
void calculate(SmallVectorImpl< NodeTy * > &IDFBlocks)
Calculate iterated dominance frontiers.
void setLiveInBlocks(const SmallPtrSetImpl< NodeTy * > &Blocks)
Give the IDF calculator the set of blocks in which the value is live on entry to the block.
void setDefiningBlocks(const SmallPtrSetImpl< NodeTy * > &Blocks)
Give the IDF calculator the set of blocks in which the value is defined.
IDFCalculatorBase(DominatorTreeBase< NodeTy, IsPostDom > &DT, const ChildrenGetterTy &C)
std::conditional_t< IsPostDom, Inverse< NodeTy * >, NodeTy * > OrderedNodeTy
IDFCalculatorDetail::ChildrenGetterTy< NodeTy, IsPostDom > ChildrenGetterTy
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
reference emplace_back(ArgTypes &&... Args)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
A range adaptor for a pair of iterators.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< typename GraphTraits< GraphType >::ChildIteratorType > children(const typename GraphTraits< GraphType >::NodeRef &G)
typename GraphType::UnknownGraphTypeError NodeRef
Generic utility class used for getting the children of a basic block.
iterator_range< ChildIteratorType > range
typename GraphTraits< NodeTy * >::ChildIteratorType ChildIteratorType
typename GraphTraits< NodeTy * >::NodeRef NodeRef
range get(const NodeRef &N)
Function object to check whether the second component of a container supported by std::get (like std:...