15 #ifndef LLVM_ANALYSIS_CFG_H 16 #define LLVM_ANALYSIS_CFG_H 36 SmallVectorImpl<std::pair<const BasicBlock *, const BasicBlock *> > &
49 bool AllowIdenticalEdges =
false);
67 const DominatorTree *DT =
nullptr,
68 const LoopInfo *LI =
nullptr);
77 const DominatorTree *DT =
nullptr,
78 const LoopInfo *LI =
nullptr);
89 const DominatorTree *DT =
nullptr,
90 const LoopInfo *LI =
nullptr);
127 template <
class NodeT,
class RPOTraversalT,
class LoopInfoT,
128 class GT = GraphTraits<NodeT>>
133 auto isProperBackedge = [&](NodeT Src, NodeT Dst) {
134 for (
const auto *Lp = LI.getLoopFor(Src); Lp; Lp = Lp->getParentLoop()) {
135 if (Lp->getHeader() == Dst)
142 for (NodeT Node : RPOTraversal) {
144 for (NodeT Succ :
make_range(GT::child_begin(Node), GT::child_end(Node))) {
146 if (!Visited.
count(Succ))
151 if (!isProperBackedge(Node, Succ))
This class represents lattice values for constants.
bool containsIrreducibleCFG(RPOTraversalT &RPOTraversal, const LoopInfoT &LI)
Return true if the control flow in RPOTraversal is irreducible.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
bool isPotentiallyReachable(const Instruction *From, const Instruction *To, const DominatorTree *DT=nullptr, const LoopInfo *LI=nullptr)
Determine whether instruction 'To' is reachable from 'From', returning true if uncertain.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
bool isCriticalEdge(const Instruction *TI, unsigned SuccNum, bool AllowIdenticalEdges=false)
Return true if the specified edge is a critical edge.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
BlockVerifier::State From
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
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...
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 isPotentiallyReachableFromMany(SmallVectorImpl< BasicBlock *> &Worklist, BasicBlock *StopBB, const DominatorTree *DT=nullptr, const LoopInfo *LI=nullptr)
Determine whether there is at least one path from a block in 'Worklist' to 'StopBB', returning true if uncertain.