14#ifndef LLVM_ANALYSIS_CFG_H
15#define LLVM_ANALYSIS_CFG_H
28template <
typename T>
class SmallVectorImpl;
37 SmallVectorImpl<std::pair<const BasicBlock *, const BasicBlock *> > &
50 bool AllowIdenticalEdges =
false);
52 bool AllowIdenticalEdges =
false);
70 const Instruction *
From,
const Instruction *To,
71 const SmallPtrSetImpl<BasicBlock *> *ExclusionSet =
nullptr,
72 const DominatorTree *DT =
nullptr,
const LoopInfo *LI =
nullptr);
81 const BasicBlock *
From,
const BasicBlock *To,
82 const SmallPtrSetImpl<BasicBlock *> *ExclusionSet =
nullptr,
83 const DominatorTree *DT =
nullptr,
const LoopInfo *LI =
nullptr);
95 SmallVectorImpl<BasicBlock *> &Worklist,
const BasicBlock *StopBB,
96 const SmallPtrSetImpl<BasicBlock *> *ExclusionSet,
97 const DominatorTree *DT =
nullptr,
const LoopInfo *LI =
nullptr);
106 SmallVectorImpl<BasicBlock *> &Worklist,
107 const SmallPtrSetImpl<const BasicBlock *> &StopSet,
108 const SmallPtrSetImpl<BasicBlock *> *ExclusionSet,
109 const DominatorTree *DT =
nullptr,
const LoopInfo *LI =
nullptr);
146template <
class NodeT,
class RPOTraversalT,
class LoopInfoT,
147 class GT = GraphTraits<NodeT>>
152 auto isProperBackedge = [&](NodeT Src, NodeT Dst) {
153 for (
const auto *Lp = LI.getLoopFor(Src); Lp; Lp = Lp->getParentLoop()) {
154 if (Lp->getHeader() == Dst)
161 for (NodeT
Node : RPOTraversal) {
165 if (!Visited.
count(Succ))
170 if (!isProperBackedge(
Node, Succ))
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.
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...
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.
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...
bool isCriticalEdge(const Instruction *TI, unsigned SuccNum, bool AllowIdenticalEdges=false)
Return true if the specified edge is a critical edge.
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.
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...