LLVM  15.0.0git
Public Member Functions | Public Attributes | List of all members
llvm::OutlinableRegion Struct Reference

The OutlinableRegion holds all the information for a specific region, or sequence of instructions. More...

#include "llvm/Transforms/IPO/IROutliner.h"

Collaboration diagram for llvm::OutlinableRegion:
Collaboration graph
[legend]

Public Member Functions

 OutlinableRegion (IRSimilarityCandidate &C, OutlinableGroup &Group)
 
void splitCandidate ()
 For the contained region, split the parent BasicBlock at the starting and ending instructions of the contained IRSimilarityCandidate. More...
 
void reattachCandidate ()
 For the contained region, reattach the BasicBlock at the starting and ending instructions of the contained IRSimilarityCandidate, or if the function has been extracted, the start and end of the BasicBlock containing the called function. More...
 
ValuefindCorrespondingValueIn (const OutlinableRegion &Other, Value *V)
 Find a corresponding value for V in similar OutlinableRegion Other. More...
 
BasicBlockfindCorrespondingBlockIn (const OutlinableRegion &Other, BasicBlock *BB)
 Find a corresponding BasicBlock for BB in similar OutlinableRegion Other. More...
 
InstructionCost getBenefit (TargetTransformInfo &TTI)
 Get the size of the code removed from the region. More...
 

Public Attributes

IRSimilarityCandidateCandidate = nullptr
 Describes the region of code. More...
 
IRInstructionDataNewFront = nullptr
 If this region is outlined, the front and back IRInstructionData could potentially become invalidated if the only new instruction is a call. More...
 
IRInstructionDataNewBack = nullptr
 
unsigned NumExtractedInputs = 0
 The number of extracted inputs from the CodeExtractor. More...
 
unsigned OutputBlockNum = -1
 The corresponding BasicBlock with the appropriate stores for this OutlinableRegion in the overall function. More...
 
DenseMap< unsigned, unsigned > ExtractedArgToAgg
 Mapping the extracted argument number to the argument number in the overall function. More...
 
DenseMap< unsigned, unsigned > AggArgToExtracted
 
DenseMap< Value *, Value * > RemappedArguments
 Values in the outlined functions will often be replaced by arguments. More...
 
bool ChangedArgOrder = false
 Marks whether we need to change the order of the arguments when mapping the old extracted function call to the new aggregate outlined function call. More...
 
bool EndsInBranch = false
 Marks whether this region ends in a branch, there is special handling required for the following basic blocks in this case. More...
 
DenseMap< Value *, BasicBlock * > PHIBlocks
 The PHIBlocks with their corresponding return block based on the return value as the key. More...
 
DenseMap< unsigned, Constant * > AggArgToConstant
 Mapping of the argument number in the deduplicated function to a given constant, which is used when creating the arguments to the call to the newly created deduplicated function. More...
 
SmallVector< unsigned, 4 > GVNStores
 The global value numbers that are used as outputs for this section. More...
 
CodeExtractorCE = nullptr
 Used to create an outlined function. More...
 
CallInstCall = nullptr
 The call site of the extracted region. More...
 
FunctionExtractedFunction = nullptr
 The function for the extracted region. More...
 
bool CandidateSplit = false
 Flag for whether we have split out the IRSimilarityCanidate. More...
 
bool IgnoreRegion = false
 Flag for whether we should not consider this region for extraction. More...
 
BasicBlockPrevBB = nullptr
 The BasicBlock that is before the start of the region BasicBlock, only defined when the region has been split. More...
 
BasicBlockStartBB = nullptr
 The BasicBlock that contains the starting instruction of the region. More...
 
BasicBlockEndBB = nullptr
 The BasicBlock that contains the ending instruction of the region. More...
 
BasicBlockFollowBB = nullptr
 The BasicBlock that is after the start of the region BasicBlock, only defined when the region has been split. More...
 
OutlinableGroupParent = nullptr
 The Outlinable Group that contains this region and structurally similar regions to this region. More...
 

Detailed Description

The OutlinableRegion holds all the information for a specific region, or sequence of instructions.

This includes what values need to be hoisted to arguments from the extracted function, inputs and outputs to the region, and mapping from the extracted function arguments to overall function arguments.

Definition at line 63 of file IROutliner.h.

Constructor & Destructor Documentation

◆ OutlinableRegion()

llvm::OutlinableRegion::OutlinableRegion ( IRSimilarityCandidate C,
OutlinableGroup Group 
)
inline

Definition at line 153 of file IROutliner.h.

Member Function Documentation

◆ findCorrespondingBlockIn()

BasicBlock * OutlinableRegion::findCorrespondingBlockIn ( const OutlinableRegion Other,
BasicBlock BB 
)

Find a corresponding BasicBlock for BB in similar OutlinableRegion Other.

Parameters
Other[in] - The OutlinableRegion to find the corresponding BasicBlock in.
BB[in] - The BasicBlock to look for in the other region.
Returns
The corresponding Value to V if it exists, otherwise nullptr.

Definition at line 193 of file IROutliner.cpp.

References assert(), BB, llvm::BasicBlock::getParent(), and Other.

◆ findCorrespondingValueIn()

Value * OutlinableRegion::findCorrespondingValueIn ( const OutlinableRegion Other,
Value V 
)

Find a corresponding value for V in similar OutlinableRegion Other.

Parameters
Other[in] - The OutlinableRegion to find the corresponding Value in.
V[in] - The Value to look for in the other region.
Returns
The corresponding Value to V if it exists, otherwise nullptr.

Definition at line 182 of file IROutliner.cpp.

References assert(), Other, and llvm::Optional< T >::value_or().

◆ getBenefit()

InstructionCost OutlinableRegion::getBenefit ( TargetTransformInfo TTI)

Get the size of the code removed from the region.

Parameters
[in]TTI- The TargetTransformInfo for the parent function.
Returns
the code size of the region

Definition at line 481 of file IROutliner.cpp.

References llvm::TargetTransformInfo::getInstructionCost(), I, and llvm::TargetTransformInfo::TCK_CodeSize.

◆ reattachCandidate()

void OutlinableRegion::reattachCandidate ( )

For the contained region, reattach the BasicBlock at the starting and ending instructions of the contained IRSimilarityCandidate, or if the function has been extracted, the start and end of the BasicBlock containing the called function.

Definition at line 370 of file IROutliner.cpp.

References assert(), llvm::Instruction::eraseFromParent(), llvm::BasicBlock::getSinglePredecessor(), llvm::BasicBlock::getTerminator(), llvm::BasicBlock::getUniqueSuccessor(), moveBBContents(), llvm::BasicBlock::replaceSuccessorsPhiUsesWith(), and replaceTargetsFromPHINode().

◆ splitCandidate()

void OutlinableRegion::splitCandidate ( )

Member Data Documentation

◆ AggArgToConstant

DenseMap<unsigned, Constant *> llvm::OutlinableRegion::AggArgToConstant

Mapping of the argument number in the deduplicated function to a given constant, which is used when creating the arguments to the call to the newly created deduplicated function.

This is handled separately since the CodeExtractor does not recognize constants.

Definition at line 112 of file IROutliner.h.

◆ AggArgToExtracted

DenseMap<unsigned, unsigned> llvm::OutlinableRegion::AggArgToExtracted

Definition at line 86 of file IROutliner.h.

◆ Call

CallInst* llvm::OutlinableRegion::Call = nullptr

The call site of the extracted region.

Definition at line 123 of file IROutliner.h.

Referenced by fillOverallFunction(), and getSubprogramOrNull().

◆ Candidate

IRSimilarityCandidate* llvm::OutlinableRegion::Candidate = nullptr

Describes the region of code.

Definition at line 65 of file IROutliner.h.

◆ CandidateSplit

bool llvm::OutlinableRegion::CandidateSplit = false

Flag for whether we have split out the IRSimilarityCanidate.

That is, make the region contained the IRSimilarityCandidate its own BasicBlock.

Definition at line 130 of file IROutliner.h.

◆ CE

CodeExtractor* llvm::OutlinableRegion::CE = nullptr

Used to create an outlined function.

Definition at line 120 of file IROutliner.h.

◆ ChangedArgOrder

bool llvm::OutlinableRegion::ChangedArgOrder = false

Marks whether we need to change the order of the arguments when mapping the old extracted function call to the new aggregate outlined function call.

Definition at line 98 of file IROutliner.h.

◆ EndBB

BasicBlock* llvm::OutlinableRegion::EndBB = nullptr

The BasicBlock that contains the ending instruction of the region.

Definition at line 143 of file IROutliner.h.

◆ EndsInBranch

bool llvm::OutlinableRegion::EndsInBranch = false

Marks whether this region ends in a branch, there is special handling required for the following basic blocks in this case.

Definition at line 102 of file IROutliner.h.

◆ ExtractedArgToAgg

DenseMap<unsigned, unsigned> llvm::OutlinableRegion::ExtractedArgToAgg

Mapping the extracted argument number to the argument number in the overall function.

Since there will be inputs, such as elevated constants that are not the same in each region in a SimilarityGroup, or values that cannot be sunk into the extracted section in every region, we must keep track of which extracted argument maps to which overall argument.

Definition at line 85 of file IROutliner.h.

◆ ExtractedFunction

Function* llvm::OutlinableRegion::ExtractedFunction = nullptr

The function for the extracted region.

Definition at line 126 of file IROutliner.h.

Referenced by fillOverallFunction().

◆ FollowBB

BasicBlock* llvm::OutlinableRegion::FollowBB = nullptr

The BasicBlock that is after the start of the region BasicBlock, only defined when the region has been split.

Definition at line 147 of file IROutliner.h.

◆ GVNStores

SmallVector<unsigned, 4> llvm::OutlinableRegion::GVNStores

The global value numbers that are used as outputs for this section.

Once extracted, each output will be stored to an output register. This documents the global value numbers that are used in this pattern.

Definition at line 117 of file IROutliner.h.

◆ IgnoreRegion

bool llvm::OutlinableRegion::IgnoreRegion = false

Flag for whether we should not consider this region for extraction.

Definition at line 133 of file IROutliner.h.

◆ NewBack

IRInstructionData* llvm::OutlinableRegion::NewBack = nullptr

Definition at line 71 of file IROutliner.h.

◆ NewFront

IRInstructionData* llvm::OutlinableRegion::NewFront = nullptr

If this region is outlined, the front and back IRInstructionData could potentially become invalidated if the only new instruction is a call.

This ensures that we replace in the instruction in the IRInstructionData.

Definition at line 70 of file IROutliner.h.

◆ NumExtractedInputs

unsigned llvm::OutlinableRegion::NumExtractedInputs = 0

The number of extracted inputs from the CodeExtractor.

Definition at line 74 of file IROutliner.h.

◆ OutputBlockNum

unsigned llvm::OutlinableRegion::OutputBlockNum = -1

The corresponding BasicBlock with the appropriate stores for this OutlinableRegion in the overall function.

Definition at line 78 of file IROutliner.h.

Referenced by fillOverallFunction().

◆ Parent

OutlinableGroup* llvm::OutlinableRegion::Parent = nullptr

The Outlinable Group that contains this region and structurally similar regions to this region.

Definition at line 151 of file IROutliner.h.

◆ PHIBlocks

DenseMap<Value *, BasicBlock *> llvm::OutlinableRegion::PHIBlocks

The PHIBlocks with their corresponding return block based on the return value as the key.

Definition at line 106 of file IROutliner.h.

◆ PrevBB

BasicBlock* llvm::OutlinableRegion::PrevBB = nullptr

The BasicBlock that is before the start of the region BasicBlock, only defined when the region has been split.

Definition at line 137 of file IROutliner.h.

◆ RemappedArguments

DenseMap<Value *, Value *> llvm::OutlinableRegion::RemappedArguments

Values in the outlined functions will often be replaced by arguments.

When finding corresponding values from one region to another, the found value will be the value the argument previously replaced. This structure maps any replaced values for the region to the aggregate aggregate argument in the overall function.

Definition at line 93 of file IROutliner.h.

Referenced by findOrCreatePHIInBlock().

◆ StartBB

BasicBlock* llvm::OutlinableRegion::StartBB = nullptr

The BasicBlock that contains the starting instruction of the region.

Definition at line 140 of file IROutliner.h.


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