41#ifndef LLVM_TRANSFORMS_IPO_IROUTLINER_H
42#define LLVM_TRANSFORMS_IPO_IROUTLINER_H
205 : getTTI(GTTI), getIRSI(GIRSI), getORE(GORE) {
209 static_cast<unsigned>(-1));
219 unsigned doOutline(
Module &M);
240 pruneIncompatibleRegions(std::vector<IRSimilarityCandidate> &CandidateVec,
252 unsigned FunctionNameSuffix);
311 std::vector<Function *> &FuncsToRemove,
312 unsigned &OutlinedFunctionNum);
325 void fillOverallFunction(
328 std::vector<Function *> &FuncsToRemove);
332 bool OutlineFromLinkODRs =
false;
337 bool CostModel =
true;
369 struct InstructionAllowed :
public InstVisitor<InstructionAllowed, bool> {
370 InstructionAllowed() =
default;
372 bool visitUncondBrInst(
UncondBrInst &BI) {
return EnableBranches; }
373 bool visitCondBrInst(CondBrInst &BI) {
return EnableBranches; }
374 bool visitPHINode(PHINode &PN) {
return EnableBranches; }
376 bool visitAllocaInst(AllocaInst &AI) {
return false; }
380 bool visitVAArgInst(VAArgInst &VI) {
return false; }
383 bool visitLandingPadInst(LandingPadInst &LPI) {
return false; }
384 bool visitFuncletPadInst(FuncletPadInst &FPI) {
return false; }
388 bool visitDbgInfoIntrinsic(DbgInfoIntrinsic &DII) {
return true; }
391 bool IntrinsicInst(IntrinsicInst &
II) {
return EnableIntrinsics; }
394 bool visitCallInst(CallInst &CI) {
404 if (CI.canReturnTwice())
413 if (CI.hasFnAttr(Attribute::NoMerge))
424 if (IsTailCC && !EnableMustTailCalls)
426 if (CI.isMustTailCall() && !EnableMustTailCalls)
430 if (CI.isMustTailCall() && !IsTailCC)
437 bool visitFreezeInst(FreezeInst &CI) {
return false; }
439 bool visitInvokeInst(InvokeInst &
II) {
return false; }
441 bool visitCallBrInst(CallBrInst &CBI) {
return false; }
443 bool visitTerminator(Instruction &
I) {
return false; }
444 bool visitInstruction(Instruction &
I) {
return true; }
448 bool EnableBranches =
false;
452 bool EnableIndirectCalls =
true;
456 bool EnableIntrinsics =
false;
459 bool EnableMustTailCalls =
false;
463 InstructionAllowed InstructionClassifier;
static bool IsIndirectCall(const MachineInstr *MI)
This header defines various interfaces for pass management in LLVM.
This file defines an InstructionCost class that is used when calculating the cost of an instruction,...
uint64_t IntrinsicInst * II
Represent a constant reference to an array (0 or more elements consecutively in memory),...
LLVM Basic Block Representation.
This class represents a function call, abstracting a target machine's calling convention.
Implements a dense probed hash-table based set.
Pass to outline similar regions.
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
IROutliner(function_ref< TargetTransformInfo &(Function &)> GTTI, function_ref< IRSimilarityIdentifier &(Module &)> GIRSI, function_ref< OptimizationRemarkEmitter &(Function &)> GORE)
LLVM_ABI bool run(Module &M)
This is a class that wraps a range of IRInstructionData from one point to another in the vector of IR...
This class puts all the pieces of the IRInstructionData, IRInstructionMapper, IRSimilarityCandidate t...
Base class for instruction visitors.
An instruction for reading from memory.
A Module instance is used to store all the information related to an LLVM module.
A set of analyses that are preserved following a run of a transformation pass.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
A BumpPtrAllocator that allows only elements of a specific type to be allocated.
Unconditional Branch instruction.
LLVM Value Representation.
An efficient, type-erasing, non-owning reference to a callable.
CallingConv Namespace - This namespace contains an enum with a value for the well-known calling conve...
@ Tail
Attemps to make calls as fast as possible while guaranteeing that tail call optimization can always b...
@ SwiftTail
This follows the Swift calling convention in how arguments are passed but guarantees tail calls will ...
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
The OutlinableGroup holds all the overarching information for outlining a set of regions that are str...
An information struct used to provide DenseMap with the various necessary components for a given valu...
This provides the utilities for hashing an Instruction to an unsigned integer.
A CRTP mix-in for passes that can be skipped.
The OutlinableRegion holds all the information for a specific region, or sequence of instructions.
CallInst * Call
The call site of the extracted region.
CodeExtractor * CE
Used to create an outlined function.
LLVM_ABI InstructionCost getBenefit(TargetTransformInfo &TTI)
Get the size of the code removed from the region.
DenseMap< unsigned, Constant * > AggArgToConstant
Mapping of the argument number in the deduplicated function to a given constant, which is used when c...
DenseMap< unsigned, unsigned > AggArgToExtracted
BasicBlock * FollowBB
The BasicBlock that is after the start of the region BasicBlock, only defined when the region has bee...
unsigned OutputBlockNum
The corresponding BasicBlock with the appropriate stores for this OutlinableRegion in the overall fun...
IRInstructionData * NewFront
If this region is outlined, the front and back IRInstructionData could potentially become invalidated...
SmallVector< unsigned, 4 > GVNStores
The global value numbers that are used as outputs for this section.
bool CandidateSplit
Flag for whether we have split out the IRSimilarityCanidate.
bool IgnoreRegion
Flag for whether we should not consider this region for extraction.
bool ChangedArgOrder
Marks whether we need to change the order of the arguments when mapping the old extracted function ca...
LLVM_ABI void splitCandidate()
For the contained region, split the parent BasicBlock at the starting and ending instructions of the ...
LLVM_ABI Value * findCorrespondingValueIn(const OutlinableRegion &Other, Value *V)
Find a corresponding value for V in similar OutlinableRegion Other.
DenseMap< unsigned, unsigned > ExtractedArgToAgg
Mapping the extracted argument number to the argument number in the overall function.
LLVM_ABI BasicBlock * findCorrespondingBlockIn(const OutlinableRegion &Other, BasicBlock *BB)
Find a corresponding BasicBlock for BB in similar OutlinableRegion Other.
BasicBlock * PrevBB
The BasicBlock that is before the start of the region BasicBlock, only defined when the region has be...
BasicBlock * EndBB
The BasicBlock that contains the ending instruction of the region.
IRSimilarityCandidate * Candidate
Describes the region of code.
unsigned NumExtractedInputs
The number of extracted inputs from the CodeExtractor.
DenseMap< Value *, BasicBlock * > PHIBlocks
The PHIBlocks with their corresponding return block based on the return value as the key.
DenseMap< Value *, Value * > RemappedArguments
Values in the outlined functions will often be replaced by arguments.
OutlinableGroup * Parent
The Outlinable Group that contains this region and structurally similar regions to this region.
OutlinableRegion(IRSimilarityCandidate &C, OutlinableGroup &Group)
Function * ExtractedFunction
The function for the extracted region.
bool EndsInBranch
Marks whether this region ends in a branch, there is special handling required for the following basi...
BasicBlock * StartBB
The BasicBlock that contains the starting instruction of the region.
IRInstructionData * NewBack
LLVM_ABI void reattachCandidate()
For the contained region, reattach the BasicBlock at the starting and ending instructions of the cont...