LLVM 20.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"

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.
 
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.
 
ValuefindCorrespondingValueIn (const OutlinableRegion &Other, Value *V)
 Find a corresponding value for V in similar OutlinableRegion Other.
 
BasicBlockfindCorrespondingBlockIn (const OutlinableRegion &Other, BasicBlock *BB)
 Find a corresponding BasicBlock for BB in similar OutlinableRegion Other.
 
InstructionCost getBenefit (TargetTransformInfo &TTI)
 Get the size of the code removed from the region.
 

Public Attributes

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

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.

References llvm::CallingConv::C, EndBB, and StartBB.

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 198 of file IROutliner.cpp.

References assert(), findCorrespondingValueIn(), llvm::BasicBlock::getFirstNonPHIOrDbg(), llvm::BasicBlock::getParent(), and llvm::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 186 of file IROutliner.cpp.

References assert(), Candidate, llvm::IRSimilarity::IRSimilarityCandidate::getCanonicalNum(), llvm::IRSimilarity::IRSimilarityCandidate::getGVN(), and llvm::Other.

Referenced by findCorrespondingBlockIn().

◆ 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 486 of file IROutliner.cpp.

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

◆ reattachCandidate()

void OutlinableRegion::reattachCandidate ( )

◆ 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().

◆ Candidate

IRSimilarityCandidate* llvm::OutlinableRegion::Candidate = nullptr

Describes the region of code.

Definition at line 65 of file IROutliner.h.

Referenced by findCorrespondingValueIn(), getBenefit(), reattachCandidate(), and splitCandidate().

◆ 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.

Referenced by reattachCandidate(), and splitCandidate().

◆ 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.

Referenced by OutlinableRegion(), reattachCandidate(), and splitCandidate().

◆ 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.

Referenced by reattachCandidate(), and splitCandidate().

◆ 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(), and reattachCandidate().

◆ 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.

Referenced by reattachCandidate(), and splitCandidate().

◆ 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.

Referenced by reattachCandidate(), and splitCandidate().

◆ 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.

Referenced by OutlinableRegion(), reattachCandidate(), and splitCandidate().


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