A single‐entry single‐exit region in a control‐flow graph.

Synopsis

Declared in <llvm/Analysis/RegionInfo.h>

template<class RegionTr>
class RegionBase
    : public RegionNodeBase<Tr>

Description

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<regions>' 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.

Base Classes

Name

Description

RegionNodeBase<Tr>

A region node that holds a basic block or a nested subregion.

Types

Name

Description

block_iterator_wrapper

Depth‐first flat iterator over BasicBlocks contained in a Region.

Type Aliases

Name

Description

BlockT

Basic block type used by this RegionNode specialization.

RegionT

Region type used by this RegionNode specialization.

block_iterator

Mutable flat iterator over BasicBlocks in this Region.

block_range

Range of mutable flat BasicBlock iterators.

const_block_iterator

Const flat iterator over BasicBlocks in this Region.

const_block_range

Range of const flat BasicBlock iterators.

const_element_iterator

Const depth‐first iterator over direct child RegionNodes.

const_iterator

Const iterator over the direct subregions of this Region.

element_iterator

Depth‐first iterator over direct child RegionNodes.

iterator

Mutable iterator over the direct subregions of this Region.

Enums

Name

Description

PrintStyle

Print style used when dumping a Region.

Member Functions

Name

Description

RegionBase [constructor]

Constructors

~RegionBase [destructor]

Delete the Region and all its subregions.

operator=

Assignment operators

addSubRegion

Add a new subregion to this Region.

begin

begin overloads

block_begin

block_begin overloads

block_end

block_end overloads

blocks

blocks overloads

clearNodeCache

Clear the cache for BB RegionNodes.

contains

contains overloads

dump

Print the region to stderr.

element_begin

element_begin overloads

element_end

element_end overloads

elements

elements overloads

end

end overloads

getBBNode

Get the BasicBlock RegionNode for a BasicBlock

getDepth

Get the nesting level of this Region.

getEnteringBlock

Return the first block of this region's single entry edge, if existing.

getEntry

Get the entry BasicBlock of the Region.

getExit

Get the exit BasicBlock of the Region.

getExitingBlock

Return the first block of this region's single exit edge, if existing.

getExitingBlocks

Collect all blocks of this region's single exit edge, if existing.

getExpandedRegion

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

getNameStr

Returns the name of the Region.

getNode

getNode overloads

getNodeAs

Get the content of this RegionNode.

getParent

Get the parent of the Region.

getRegionInfo

Return the RegionInfo object, that belongs to this Region.

getSubRegionNode

Get the subregion that starts at a BasicBlock

isSimple

Is this a simple region?

isSubRegion

Is this RegionNode a subregion?

isTopLevelRegion

Check if a Region is the TopLevel region.

outermostLoopInRegion

outermostLoopInRegion overloads

print

Print the region.

removeSubRegion

Remove a subregion from this Region.

replaceEntry

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

replaceEntryRecursive

Recursively replace the entry basic block of the region.

replaceExit

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

replaceExitRecursive

Recursively replace the exit basic block of the region.

transferChildrenTo

Move all direct child nodes of this Region to another Region.

verifyRegion

Verify if the region is a correct region.

Friends

Name

Description

llvm::RegionInfoBase

Analysis that detects all canonical regions in a function.

Derived Classes

Name

Description

MachineRegion

Single‐entry single‐exit region in a MachineFunction CFG.

Region

A single entry single exit Region in an LLVM IR Function.

Template Parameters

Name

Description

Tr

RegionTraits specialization that supplies the IR types.

Created with MrDocs