LLVM: llvm::RegionBase< Tr > Class Template Reference (original) (raw)

A single entry single exit Region. More...

#include "[llvm/Analysis/RegionInfo.h](RegionInfo%5F8h%5Fsource.html)"

Public Types
enum PrintStyle { PrintNone, PrintBB, PrintRN }
PrintStyle - Print region in difference ways. More...
Public Types inherited from llvm::RegionNodeBase< Tr >
using BlockT = typename Tr::BlockT
using RegionT = typename Tr::RegionT
Public Member Functions
RegionBase (BlockT *Entry, BlockT *Exit, RegionInfoT *RI, DomTreeT *DT, RegionT *Parent=nullptr)
Create a new region.
RegionBase (const RegionBase &)=delete
RegionBase & operator= (const RegionBase &)=delete
~RegionBase ()
Delete the Region and all its subregions.
BlockT * getEntry () const
Get the entry BasicBlock of the Region.
void replaceEntry (BlockT *BB)
Replace the entry basic block of the region with the new basic block.
void replaceExit (BlockT *BB)
Replace the exit basic block of the region with the new basic block.
void replaceEntryRecursive (BlockT *NewEntry)
Recursively replace the entry basic block of the region.
void replaceExitRecursive (BlockT *NewExit)
Recursively replace the exit basic block of the region.
BlockT * getExit () const
Get the exit BasicBlock of the Region.
RegionT * getParent () const
Get the parent of the Region.
RegionNodeT * getNode () const
Get the RegionNode representing the current Region.
unsigned getDepth () const
Get the nesting level of this Region.
bool isTopLevelRegion () const
Check if a Region is the TopLevel region.
RegionT * getExpandedRegion () const
Return a new (non-canonical) region, that is obtained by joining this region with its predecessors.
BlockT * getEnteringBlock () const
Return the first block of this region's single entry edge, if existing.
BlockT * getExitingBlock () const
Return the first block of this region's single exit edge, if existing.
bool getExitingBlocks (SmallVectorImpl< BlockT * > &Exitings) const
Collect all blocks of this region's single exit edge, if existing.
bool isSimple () const
Is this a simple region?
std::string getNameStr () const
Returns the name of the Region.
RegionInfoT * getRegionInfo () const
Return the RegionInfo object, that belongs to this Region.
void print (raw_ostream &OS, bool printTree=true, unsigned level=0, PrintStyle Style=PrintNone) const
Print the region.
void dump () const
Print the region to stderr.
bool contains (const BlockT *BB) const
Check if the region contains a BasicBlock.
bool contains (const RegionT *SubRegion) const
Check if the region contains another region.
bool contains (const InstT *Inst) const
Check if the region contains an Instruction.
bool contains (const LoopT *L) const
Check if the region contains a loop.
LoopT * outermostLoopInRegion (LoopT *L) const
Get the outermost loop in the region that contains a loop.
LoopT * outermostLoopInRegion (LoopInfoT *LI, BlockT *BB) const
Get the outermost loop in the region that contains a basic block.
RegionT * getSubRegionNode (BlockT *BB) const
Get the subregion that starts at a BasicBlock.
RegionNodeT * getNode (BlockT *BB) const
Get the RegionNode for a BasicBlock.
RegionNodeT * getBBNode (BlockT *BB) const
Get the BasicBlock RegionNode for a BasicBlock.
void addSubRegion (RegionT *SubRegion, bool moveChildren=false)
Add a new subregion to this Region.
RegionT * removeSubRegion (RegionT *SubRegion)
Remove a subregion from this Region.
void transferChildrenTo (RegionT *To)
Move all direct child nodes of this Region to another Region.
void verifyRegion () const
Verify if the region is a correct region.
void clearNodeCache ()
Clear the cache for BB RegionNodes.
Public Member Functions inherited from llvm::RegionNodeBase< Tr >
RegionNodeBase (const RegionNodeBase &)=delete
RegionNodeBase & operator= (const RegionNodeBase &)=delete
RegionT * getParent () const
Get the parent Region of this RegionNode.
BlockT * getEntry () const
Get the entry BasicBlock of this RegionNode.
template<class T>
T * getNodeAs () const
Get the content of this RegionNode.
bool isSubRegion () const
Is this RegionNode a subregion?
BasicBlock * getNodeAs () const
Region * getNodeAs () const
MachineBasicBlock * getNodeAs () const
MachineRegion * getNodeAs () const
Friends
class RegionInfoBase< Tr >
Subregion Iterators
These iterators iterator over all subregions of this Region.
using iterator = typename RegionSet::iterator
using const_iterator = typename RegionSet::const_iterator
iterator begin ()
iterator end ()
const_iterator begin () const
const_iterator end () const
BasicBlock Iterators
These iterators iterate over all BasicBlocks that are contained in this Region. The iterator also iterates over BasicBlocks that are elements of a subregion of this Region. It is therefore called a flat iterator.
using block_iterator = block_iterator_wrapper
using const_block_iterator = block_iterator_wrapper
using block_range = iterator_range<block_iterator>
using const_block_range = iterator_range<const_block_iterator>
block_iterator block_begin ()
block_iterator block_end ()
const_block_iterator block_begin () const
const_block_iterator block_end () const
block_range blocks ()
Returns a range view of the basic blocks in the region.
const_block_range blocks () const
Returns a range view of the basic blocks in the region.
Element Iterators
These iterators iterate over all BasicBlock and subregion RegionNodes that are direct children of this Region. It does not iterate over any RegionNodes that are also element of a subregion of this Region.
using element_iterator
using const_element_iterator
element_iterator element_begin ()
element_iterator element_end ()
iterator_range< element_iterator > elements ()
const_element_iterator element_begin () const
const_element_iterator element_end () const
iterator_range< const_element_iterator > elements () const

template
class llvm::RegionBase< Tr >

A single entry single exit Region.

A Region is a connected subgraph of a control flow graph that has exactly two connections to the remaining graph. It can be used to analyze or optimize parts of the control flow graph.

A simple Region is connected to the remaining graph by just two edges. One edge entering the Region and another one leaving the Region.

An extended Region (or just Region) is a subgraph that can be transform into a simple Region. The transformation is done by adding BasicBlocks that merge several entry or exit edges so that after the merge just one entry and one exit edge exists.

The Entry of a Region is the first BasicBlock that is passed after entering the Region. It is an element of the Region. The entry BasicBlock dominates all BasicBlocks in the Region.

The Exit of a Region is the first BasicBlock that is passed after leaving the Region. It is not an element of the Region. The exit BasicBlock, postdominates all BasicBlocks in the Region.

A canonical Region cannot be constructed by combining smaller Regions.

Region A is the parent of Region B, if B is completely contained in A.

Two canonical Regions either do not intersect at all or one is the parent of the other.

The Program Structure Tree is a graph (V, E) where V is the set of Regions in the control flow graph and E is the parent relation of these Regions.

Example:

/// A simple control flow graph, that contains two regions. /// /// 1 /// / | /// 2 | /// / \ 3 /// 4 5 | /// | | | /// 6 7 8 /// \ | / /// \ |/ Region A: 1 -> 9 {1,2,3,4,5,6,7,8} /// 9 Region B: 2 -> 9 {2,4,5,6,7} ///

You can obtain more examples by either calling

"opt -passes='print' anyprogram.ll" or "opt -view-regions-only anyprogram.ll"

on any LLVM file you are interested in.

The first call returns a textual representation of the program structure tree, the second one creates a graphical representation using graphviz.

Definition at line 252 of file RegionInfo.h.

block_iterator

block_range

const_block_iterator

const_block_range

const_element_iterator

const_iterator

element_iterator

iterator

PrintStyle

PrintStyle - Print region in difference ways.

Enumerator
PrintNone
PrintBB
PrintRN

Definition at line 427 of file RegionInfo.h.

Create a new region.

RegionBase Implementation.

Parameters

Entry The entry basic block of the region.
Exit The exit basic block of the region.
RI The region info object that is managing this region.
DT The dominator tree of the current function.
Parent The surrounding region or NULL if this is a top level region.

Definition at line 42 of file RegionInfoImpl.h.

References llvm::RegionNodeBase< Tr >::RegionNodeBase().

Referenced by operator=(), and RegionBase().

RegionBase() [2/2]

~RegionBase()

addSubRegion()

Add a new subregion to this Region.

Parameters

SubRegion The new subregion that will be added.
moveChildren Move the children of this region, that are also contained in SubRegion into SubRegion.

Definition at line 369 of file RegionInfoImpl.h.

References assert(), and llvm::none_of().

begin() [1/2]

begin() [2/2]

block_begin() [1/2]

block_begin() [2/2]

block_end() [1/2]

block_end() [2/2]

blocks() [1/2]

blocks() [2/2]

clearNodeCache()

Clear the cache for BB RegionNodes.

After calling this function the BasicBlock RegionNodes will be stored at different memory locations. RegionNodes obtained before this function is called are therefore not comparable to RegionNodes abtained afterwords.

Definition at line 506 of file RegionInfoImpl.h.

contains() [1/4]

contains() [2/4]

contains() [3/4]

Check if the region contains a loop.

Parameters

L The loop that might be contained in this region.

Returns

True if the loop is contained in the region otherwise false. In case a NULL pointer is passed to this function the result is false, except for the region that describes the whole function. In that case true is returned.

Definition at line 119 of file RegionInfoImpl.h.

References contains(), and getExit().

contains() [4/4]

Check if the region contains another region.

Parameters

SubRegion The region that might be contained in this Region.

Returns

True if SubRegion is contained in the region otherwise false.

Definition at line 452 of file RegionInfo.h.

References contains(), and getExit().

dump()

element_begin() [1/2]

element_begin() [2/2]

element_end() [1/2]

element_end() [2/2]

elements() [1/2]

elements() [2/2]

end() [1/2]

end() [2/2]

getBBNode()

getDepth()

getEnteringBlock()

getEntry()

getExit()

getExitingBlock()

getExitingBlocks()

getExpandedRegion()

template

Tr::RegionT * llvm::RegionBase< Tr >::getExpandedRegion ( ) const

Return a new (non-canonical) region, that is obtained by joining this region with its predecessors.

Returns

A region also starting at getEntry(), but reaching to the next basic block that forms with getEntry() a (non-canonical) region. NULL if such a basic block does not exist.

Definition at line 435 of file RegionInfoImpl.h.

getNameStr()

getNode() [1/2]

getNode() [2/2]

getParent()

getRegionInfo()

getSubRegionNode()

isSimple()

isTopLevelRegion()

operator=()

outermostLoopInRegion() [1/2]

Get the outermost loop in the region that contains a basic block.

Find for a basic block BB the outermost loop L that contains BB and is itself contained in the region.

Parameters

LI A pointer to a LoopInfo analysis.
BB The basic block surrounded by the loop.

Returns

The outermost loop in the region, NULL if such a loop does not exist or if the region describes the whole function.

Definition at line 153 of file RegionInfoImpl.h.

References assert(), and outermostLoopInRegion().

outermostLoopInRegion() [2/2]

template

Tr::LoopT * llvm::RegionBase< Tr >::outermostLoopInRegion ( LoopT * L ) const

Get the outermost loop in the region that contains a loop.

Find for a Loop L the outermost loop OuterL that is a parent loop of L and is itself contained in the region.

Parameters

L The loop the lookup is started.

Returns

The outermost loop in the region, NULL if such a loop does not exist or if the region describes the whole function.

Definition at line 141 of file RegionInfoImpl.h.

References contains().

Referenced by outermostLoopInRegion().

print()

removeSubRegion()

Remove a subregion from this Region.

The subregion is not deleted, as it will probably be inserted into another region.

Parameters

SubRegion The SubRegion that will be removed.

Definition at line 412 of file RegionInfoImpl.h.

References assert(), llvm::find_if(), and I.

replaceEntry()

Replace the entry basic block of the region with the new basic block.

Parameters

BB The new entry basic block of the region.

Definition at line 55 of file RegionInfoImpl.h.

replaceEntryRecursive()

Recursively replace the entry basic block of the region.

This function replaces the entry basic block with a new basic block. It also updates all child regions that have the same entry basic block as this region.

Parameters

NewEntry The new entry basic block.

Definition at line 66 of file RegionInfoImpl.h.

References getEntry().

replaceExit()

Replace the exit basic block of the region with the new basic block.

Parameters

BB The new exit basic block of the region.

Definition at line 60 of file RegionInfoImpl.h.

References assert().

replaceExitRecursive()

Recursively replace the exit basic block of the region.

This function replaces the exit basic block with a new basic block. It also updates all child regions that have the same exit basic block as this region.

Parameters

NewExit The new exit basic block.

Definition at line 84 of file RegionInfoImpl.h.

References getExit().

transferChildrenTo()

verifyRegion()

RegionInfoBase< Tr >


The documentation for this class was generated from the following files: