28#ifndef LLVM_ADT_GENERICCYCLEINFO_H
29#define LLVM_ADT_GENERICCYCLEINFO_H
40template <
typename ContextT>
class GenericCycleInfo;
41template <
typename ContextT>
class GenericCycleInfoCompute;
46 using BlockT =
typename ContextT::BlockT;
62 std::vector<std::unique_ptr<GenericCycle>> Children;
82 ParentCycle =
nullptr;
205 for (
auto *Entry : Entries) {
209 Out << Ctx.print(Entry);
222 Out <<
' ' << Ctx.print(
Block);
231 using BlockT =
typename ContextT::BlockT;
250 std::vector<std::unique_ptr<CycleT>> TopLevelCycles;
256 void moveTopLevelCycleToNewParent(
CycleT *NewParent,
CycleT *Child);
296 const_toplevel_iterator_base> {
332 return Ref->child_begin();
357template <
typename BlockT>
361template <
typename BlockT>
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static void clear(coro::Shape &Shape)
This file defines the DenseSet and SmallDenseSet classes.
DenseMap< Block *, BlockRelaxAux > Blocks
This file defines the little GenericSSAContext<X> template class that can be used to implement IR ana...
This file defines the little GraphTraits<X> template class that should be specialized by classes that...
This file implements a set that has insertion order iteration characteristics.
Implements a dense probed hash-table based set.
Helper class for computing cycle information.
Cycle information for a function.
typename ContextT::FunctionT FunctionT
GenericCycleInfo()=default
void verify() const
Verify that the entire cycle tree well-formed.
typename std::vector< std::unique_ptr< CycleT > >::const_iterator const_toplevel_iterator_base
Iteration over top-level cycles.
iterator_range< const_toplevel_iterator > toplevel_cycles() const
const_toplevel_iterator toplevel_end() const
const FunctionT * getFunction() const
void print(raw_ostream &Out) const
Print the cycle info.
CycleT * getSmallestCommonCycle(CycleT *A, CycleT *B) const
Find the innermost cycle containing both given cycles.
GenericCycleInfo & operator=(GenericCycleInfo &&)=default
void clear()
Reset the object to its initial state.
GenericCycle< ContextT > CycleT
void compute(FunctionT &F)
Compute the cycle info for a function.
void splitCriticalEdge(BlockT *Pred, BlockT *Succ, BlockT *New)
const ContextT & getSSAContext() const
GenericCycleInfo(GenericCycleInfo &&)=default
Printable print(const CycleT *Cycle)
unsigned getCycleDepth(const BlockT *Block) const
get the depth for the cycle which containing a given block.
void verifyCycleNest(bool VerifyFull=false) const
Methods for debug and self-test.
typename ContextT::BlockT BlockT
CycleT * getTopLevelParentCycle(BlockT *Block)
const_toplevel_iterator toplevel_begin() const
CycleT * getCycle(const BlockT *Block) const
Find the innermost cycle containing a given block.
A possibly irreducible generalization of a Loop.
BlockT * getHeader() const
bool isReducible() const
Whether the cycle is a natural loop.
typename ContextT::FunctionT FunctionT
void getExitingBlocks(SmallVectorImpl< BlockT * > &TmpStorage) const
Return all blocks of this cycle that have successor outside of this cycle.
void verifyCycle() const
Verify that this is actually a well-formed cycle in the CFG.
typename SmallVectorImpl< BlockT * >::const_iterator const_entry_iterator
Iteration over entry blocks.
const_child_iterator child_begin() const
iterator_range< const_entry_iterator > entries() const
void verifyCycleNest() const
Verify the parent-child relations of this cycle.
Printable print(const ContextT &Ctx) const
iterator_range< const_block_iterator > blocks() const
const SmallVectorImpl< BlockT * > & getEntries() const
BlockT * getCyclePreheader() const
Return the preheader block for this cycle.
typename BlockSetVectorT::const_iterator const_block_iterator
Iteration over blocks in the cycle (including entry blocks).
bool isEntry(const BlockT *Block) const
Return whether Block is an entry block of the cycle.
const_block_iterator block_begin() const
void getExitBlocks(SmallVectorImpl< BlockT * > &TmpStorage) const
Return all of the successor blocks of this cycle.
BlockT * getCyclePredecessor() const
If the cycle has exactly one entry with exactly one predecessor, return it, otherwise return nullptr.
bool contains(const BlockT *Block) const
Return whether Block is contained in the cycle.
Printable printEntries(const ContextT &Ctx) const
size_t getNumEntries() const
const_child_iterator child_end() const
typename std::vector< std::unique_ptr< GenericCycle > >::const_iterator const_child_iterator_base
Iteration over child cycles.
size_t getNumChildren() const
typename ContextT::BlockT BlockT
const GenericCycle * getParentCycle() const
GenericCycle * getParentCycle()
unsigned getDepth() const
const_block_iterator block_end() const
size_t getNumBlocks() const
iterator_range< const_child_iterator > children() const
Simple wrapper around std::function<void(raw_ostream&)>.
typename vector_type::const_iterator const_iterator
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
typename SuperClass::const_iterator const_iterator
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
CRTP base class for adapting an iterator to a different type.
const const_child_iterator_base & wrapped() const
const_child_iterator_base I
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
@ Ref
The access may reference the value stored in memory.
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
GraphTraits for iterating over a sub-tree of the CycleT tree.
static ChildIteratorType child_begin(NodeRef Ref)
nodes_iterator ChildIteratorType
ChildIteratorT nodes_iterator
static NodeRef getEntryNode(NodeRef Graph)
static ChildIteratorType child_end(NodeRef Ref)
const_toplevel_iterator()=default
const const_toplevel_iterator_base & wrapped()
const_toplevel_iterator(const_toplevel_iterator_base I)
CycleT * operator*() const
const_child_iterator()=default
const_child_iterator(const_child_iterator_base I)
GenericCycle * operator*() const
const const_child_iterator_base & wrapped()