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 |
A region node that holds a basic block or a nested subregion. |
Types
Name |
Description |
Depth‐first flat iterator over BasicBlocks contained in a Region. |
Type Aliases
Name |
Description |
Basic block type used by this RegionNode specialization. |
|
Region type used by this RegionNode specialization. |
|
Mutable flat iterator over BasicBlocks in this Region. |
|
Range of mutable flat BasicBlock iterators. |
|
Const flat iterator over BasicBlocks in this Region. |
|
Range of const flat BasicBlock iterators. |
|
Const depth‐first iterator over direct child RegionNodes. |
|
Const iterator over the direct subregions of this Region. |
|
Depth‐first iterator over direct child RegionNodes. |
|
Mutable iterator over the direct subregions of this Region. |
Enums
Name |
Description |
Print style used when dumping a Region. |
Member Functions
Name |
Description |
|
Constructors |
|
Delete the Region and all its subregions. |
Assignment operators |
|
Add a new subregion to this Region. |
|
|
|
|
|
|
|
|
|
Clear the cache for BB RegionNodes. |
|
|
|
Print the region to stderr. |
|
|
|
|
|
|
|
|
|
Get the BasicBlock RegionNode for a BasicBlock |
|
Get the nesting level of this Region. |
|
Return the first block of this region's single entry edge, if existing. |
|
Get the entry BasicBlock of the Region. |
|
Get the exit BasicBlock of the Region. |
|
Return the first block of this region's single exit edge, if existing. |
|
Collect all blocks of this region's single exit edge, if existing. |
|
Return a new (non‐canonical) region, that is obtained by joining this region with its predecessors. |
|
Returns the name of the Region. |
|
|
|
Get the content of this RegionNode. |
|
Get the parent of the Region. |
|
Return the RegionInfo object, that belongs to this Region. |
|
Get the subregion that starts at a BasicBlock |
|
Is this a simple region? |
|
Is this RegionNode a subregion? |
|
Check if a Region is the TopLevel region. |
|
|
|
Print the region. |
|
Remove a subregion from this Region. |
|
Replace the entry basic block of the region with the new basic block. |
|
Recursively replace the entry basic block of the region. |
|
Replace the exit basic block of the region with the new basic block. |
|
Recursively replace the exit basic block of the region. |
|
Move all direct child nodes of this Region to another Region. |
|
Verify if the region is a correct region. |
Friends
Name |
Description |
Analysis that detects all canonical regions in a function. |
Derived Classes
Name |
Description |
Single‐entry single‐exit region in a MachineFunction CFG. |
|
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