14#ifndef LLVM_ANALYSIS_CFG_H
15#define LLVM_ANALYSIS_CFG_H
29template <
typename T>
class SmallVectorImpl;
38 SmallVectorImpl<std::pair<const BasicBlock *, const BasicBlock *>> &Result);
44 const BasicBlock *Succ);
51 bool AllowIdenticalEdges =
false);
53 bool AllowIdenticalEdges =
false);
71 const Instruction *
From,
const Instruction *To,
72 const SmallPtrSetImpl<BasicBlock *> *ExclusionSet =
nullptr,
73 const DominatorTree *DT =
nullptr,
const LoopInfo *LI =
nullptr);
82 const BasicBlock *
From,
const BasicBlock *To,
83 const SmallPtrSetImpl<BasicBlock *> *ExclusionSet =
nullptr,
84 const DominatorTree *DT =
nullptr,
const LoopInfo *LI =
nullptr);
96 SmallVectorImpl<BasicBlock *> &Worklist,
const BasicBlock *StopBB,
97 const SmallPtrSetImpl<BasicBlock *> *ExclusionSet,
98 const DominatorTree *DT =
nullptr,
const LoopInfo *LI =
nullptr);
107 SmallVectorImpl<BasicBlock *> &Worklist,
108 const SmallPtrSetImpl<const BasicBlock *> &StopSet,
109 const SmallPtrSetImpl<BasicBlock *> *ExclusionSet,
110 const DominatorTree *DT =
nullptr,
const LoopInfo *LI =
nullptr);
147template <
class NodeT,
class RPOTraversalT,
class LoopInfoT,
148 class GT = GraphTraits<NodeT>>
153 auto isProperBackedge = [&](NodeT Src, NodeT Dst) {
154 for (
const auto *Lp = LI.getLoopFor(Src); Lp; Lp = Lp->getParentLoop()) {
155 if (Lp->getHeader() == Dst)
162 for (NodeT
Node : RPOTraversal) {
166 if (!Visited.
count(Succ))
171 if (!isProperBackedge(
Node, Succ))
196 const BasicBlock &Dest);
BlockVerifier::State From
This file defines the little GraphTraits<X> template class that should be specialized by classes that...
This file defines the SmallPtrSet class.
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.
@ BasicBlock
Various leaf nodes.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI unsigned GetSuccessorNumber(const BasicBlock *BB, const BasicBlock *Succ)
Search for the specified successor of basic block BB and return its position in the terminator instru...
LLVM_ABI bool isPotentiallyReachableFromMany(SmallVectorImpl< BasicBlock * > &Worklist, const BasicBlock *StopBB, const SmallPtrSetImpl< BasicBlock * > *ExclusionSet, const DominatorTree *DT=nullptr, const LoopInfo *LI=nullptr)
Determine whether there is at least one path from a block in 'Worklist' to 'StopBB' without passing t...
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
bool containsIrreducibleCFG(RPOTraversalT &RPOTraversal, const LoopInfoT &LI)
Return true if the control flow in RPOTraversal is irreducible.
LLVM_ABI bool isManyPotentiallyReachableFromMany(SmallVectorImpl< BasicBlock * > &Worklist, const SmallPtrSetImpl< const BasicBlock * > &StopSet, const SmallPtrSetImpl< BasicBlock * > *ExclusionSet, const DominatorTree *DT=nullptr, const LoopInfo *LI=nullptr)
Determine whether there is a potentially a path from at least one block in 'Worklist' to at least one...
LLVM_ABI bool isCriticalEdge(const Instruction *TI, unsigned SuccNum, bool AllowIdenticalEdges=false)
Return true if the specified edge is a critical edge.
LLVM_ABI bool isPresplitCoroSuspendExitEdge(const BasicBlock &Src, const BasicBlock &Dest)
LLVM_ABI void FindFunctionBackedges(const Function &F, SmallVectorImpl< std::pair< const BasicBlock *, const BasicBlock * > > &Result)
Analyze the specified function to find all of the loop backedges in the function and return them.
LLVM_ABI bool canReturn(const Function &F)
Return true if there is at least a path through which F can return, false if there is no such path.
LLVM_ABI bool isPotentiallyReachable(const Instruction *From, const Instruction *To, const SmallPtrSetImpl< BasicBlock * > *ExclusionSet=nullptr, const DominatorTree *DT=nullptr, const LoopInfo *LI=nullptr)
Determine whether instruction 'To' is reachable from 'From', without passing through any blocks in Ex...