LLVM 20.0.0git
|
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. | |
Value * | findCorrespondingValueIn (const OutlinableRegion &Other, Value *V) |
Find a corresponding value for V in similar OutlinableRegion Other . | |
BasicBlock * | findCorrespondingBlockIn (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 | |
IRSimilarityCandidate * | Candidate = nullptr |
Describes the region of code. | |
IRInstructionData * | NewFront = nullptr |
If this region is outlined, the front and back IRInstructionData could potentially become invalidated if the only new instruction is a call. | |
IRInstructionData * | NewBack = 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, unsigned > | ExtractedArgToAgg |
Mapping the extracted argument number to the argument number in the overall function. | |
DenseMap< unsigned, unsigned > | AggArgToExtracted |
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. | |
CodeExtractor * | CE = nullptr |
Used to create an outlined function. | |
CallInst * | Call = nullptr |
The call site of the extracted region. | |
Function * | ExtractedFunction = 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. | |
BasicBlock * | PrevBB = nullptr |
The BasicBlock that is before the start of the region BasicBlock, only defined when the region has been split. | |
BasicBlock * | StartBB = nullptr |
The BasicBlock that contains the starting instruction of the region. | |
BasicBlock * | EndBB = nullptr |
The BasicBlock that contains the ending instruction of the region. | |
BasicBlock * | FollowBB = nullptr |
The BasicBlock that is after the start of the region BasicBlock, only defined when the region has been split. | |
OutlinableGroup * | Parent = nullptr |
The Outlinable Group that contains this region and structurally similar regions to this region. | |
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.
|
inline |
Definition at line 153 of file IROutliner.h.
References llvm::CallingConv::C, EndBB, and StartBB.
BasicBlock * OutlinableRegion::findCorrespondingBlockIn | ( | const OutlinableRegion & | Other, |
BasicBlock * | BB | ||
) |
Find a corresponding BasicBlock for BB
in similar OutlinableRegion Other
.
Other | [in] - The OutlinableRegion to find the corresponding BasicBlock in. |
BB | [in] - The BasicBlock to look for in the other region. |
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.
Value * OutlinableRegion::findCorrespondingValueIn | ( | const OutlinableRegion & | Other, |
Value * | V | ||
) |
Find a corresponding value for V
in similar OutlinableRegion Other
.
Other | [in] - The OutlinableRegion to find the corresponding Value in. |
V | [in] - The Value to look for in the other region. |
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().
InstructionCost OutlinableRegion::getBenefit | ( | TargetTransformInfo & | TTI | ) |
Get the size of the code removed from the region.
[in] | TTI | - The TargetTransformInfo for the parent function. |
Definition at line 486 of file IROutliner.cpp.
References Candidate, llvm::TargetTransformInfo::getInstructionCost(), I, and llvm::TargetTransformInfo::TCK_CodeSize.
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 375 of file IROutliner.cpp.
References assert(), llvm::IRSimilarity::IRSimilarityCandidate::begin(), Candidate, CandidateSplit, EndBB, EndsInBranch, llvm::BasicBlock::eraseFromParent(), llvm::Instruction::eraseFromParent(), ExtractedFunction, FollowBB, llvm::IRSimilarity::IRSimilarityCandidate::getBasicBlocks(), llvm::BasicBlock::getSinglePredecessor(), llvm::BasicBlock::getTerminator(), llvm::BasicBlock::getUniqueSuccessor(), llvm::BasicBlock::hasNPredecessors(), llvm::BasicBlock::hasNPredecessorsOrMore(), moveBBContents(), PrevBB, llvm::BasicBlock::replaceSuccessorsPhiUsesWith(), replaceTargetsFromPHINode(), and StartBB.
void OutlinableRegion::splitCandidate | ( | ) |
For the contained region, split the parent BasicBlock at the starting and ending instructions of the contained IRSimilarityCandidate.
Definition at line 248 of file IROutliner.cpp.
References assert(), llvm::Function::back(), llvm::IRSimilarity::IRSimilarityCandidate::backInstruction(), llvm::BasicBlock::begin(), llvm::IRSimilarity::IRSimilarityCandidate::begin(), Candidate, CandidateSplit, llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::clear(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::contains(), llvm::IRSimilarity::IRSimilarityCandidate::end(), EndBB, EndsInBranch, FollowBB, llvm::IRSimilarity::IRSimilarityCandidate::getBasicBlocks(), llvm::BasicBlock::getFirstInsertionPt(), llvm::Instruction::getFunction(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::Value::getName(), llvm::Instruction::getNextNonDebugInstruction(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::BasicBlock::getTerminator(), llvm::Instruction::isTerminator(), PrevBB, llvm::BasicBlock::replaceSuccessorsPhiUsesWith(), replaceTargetsFromPHINode(), llvm::BasicBlock::splitBasicBlock(), StartBB, and llvm::StringRef::str().
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.
Definition at line 86 of file IROutliner.h.
CallInst* llvm::OutlinableRegion::Call = nullptr |
The call site of the extracted region.
Definition at line 123 of file IROutliner.h.
Referenced by fillOverallFunction().
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().
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().
CodeExtractor* llvm::OutlinableRegion::CE = nullptr |
Used to create an outlined function.
Definition at line 120 of file IROutliner.h.
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.
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().
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().
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.
Function* llvm::OutlinableRegion::ExtractedFunction = nullptr |
The function for the extracted region.
Definition at line 126 of file IROutliner.h.
Referenced by fillOverallFunction(), and reattachCandidate().
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().
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.
bool llvm::OutlinableRegion::IgnoreRegion = false |
Flag for whether we should not consider this region for extraction.
Definition at line 133 of file IROutliner.h.
IRInstructionData* llvm::OutlinableRegion::NewBack = nullptr |
Definition at line 71 of file IROutliner.h.
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.
unsigned llvm::OutlinableRegion::NumExtractedInputs = 0 |
The number of extracted inputs from the CodeExtractor.
Definition at line 74 of file IROutliner.h.
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().
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.
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.
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().
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().
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().