82 #define DEBUG_TYPE "machine-outliner" 88 STATISTIC(NumOutlined,
"Number of candidates outlined");
89 STATISTIC(FunctionsCreated,
"Number of functions created");
97 "enable-linkonceodr-outlining",
99 cl::desc(
"Enable the machine outliner on linkonceodr functions"),
105 const unsigned EmptyIdx = -1;
122 struct SuffixTreeNode {
132 bool IsInTree =
true;
135 unsigned StartIdx = EmptyIdx;
143 unsigned *EndIdx =
nullptr;
148 unsigned SuffixIdx = EmptyIdx;
168 SuffixTreeNode *
Link =
nullptr;
171 SuffixTreeNode *Parent =
nullptr;
177 unsigned OccurrenceCount = 0;
181 unsigned ConcatLen = 0;
184 bool isLeaf()
const {
return SuffixIdx != EmptyIdx; }
187 bool isRoot()
const {
return StartIdx == EmptyIdx; }
190 size_t size()
const {
196 assert(*EndIdx != EmptyIdx &&
"EndIdx is undefined!");
200 return *EndIdx - StartIdx + 1;
203 SuffixTreeNode(
unsigned StartIdx,
unsigned *EndIdx, SuffixTreeNode *Link,
204 SuffixTreeNode *Parent)
205 : StartIdx(StartIdx), EndIdx(EndIdx), Link(Link), Parent(Parent) {}
237 std::vector<SuffixTreeNode *> LeafVector;
250 SuffixTreeNode *Root =
nullptr;
262 unsigned LeafEndIdx = -1;
268 SuffixTreeNode *Node;
271 unsigned Idx = EmptyIdx;
288 SuffixTreeNode *insertLeaf(SuffixTreeNode &Parent,
unsigned StartIdx,
291 assert(StartIdx <= LeafEndIdx &&
"String can't start after it ends!");
293 SuffixTreeNode *
N =
new (NodeAllocator.
Allocate())
294 SuffixTreeNode(StartIdx, &LeafEndIdx,
nullptr, &Parent);
295 Parent.Children[Edge] =
N;
308 SuffixTreeNode *insertInternalNode(SuffixTreeNode *Parent,
unsigned StartIdx,
309 unsigned EndIdx,
unsigned Edge) {
311 assert(StartIdx <= EndIdx &&
"String can't start after it ends!");
312 assert(!(!Parent && StartIdx != EmptyIdx) &&
313 "Non-root internal nodes must have parents!");
315 unsigned *
E =
new (InternalEndIdxAllocator)
unsigned(EndIdx);
316 SuffixTreeNode *N =
new (NodeAllocator.
Allocate())
317 SuffixTreeNode(StartIdx, E, Root, Parent);
319 Parent->Children[Edge] =
N;
330 void setSuffixIndices(SuffixTreeNode &CurrNode,
unsigned CurrIdx) {
332 bool IsLeaf = CurrNode.Children.size() == 0 && !CurrNode.isRoot();
336 if (!CurrNode.isRoot()) {
337 if (CurrNode.ConcatLen == 0)
338 CurrNode.ConcatLen = CurrNode.size();
341 CurrNode.ConcatLen += CurrNode.Parent->ConcatLen;
345 for (
auto &ChildPair : CurrNode.Children) {
346 assert(ChildPair.second &&
"Node had a null child!");
347 setSuffixIndices(*ChildPair.second, CurrIdx + ChildPair.second->size());
353 CurrNode.SuffixIdx = Str.
size() - CurrIdx;
354 assert(CurrNode.Parent &&
"CurrNode had no parent!");
355 CurrNode.Parent->OccurrenceCount++;
358 LeafVector[CurrNode.SuffixIdx] = &CurrNode;
376 unsigned extend(
unsigned EndIdx,
unsigned SuffixesToAdd) {
377 SuffixTreeNode *NeedsLink =
nullptr;
379 while (SuffixesToAdd > 0) {
382 if (Active.Len == 0) {
387 assert(Active.Idx <= EndIdx &&
"Start index can't be after end index!");
390 unsigned FirstChar = Str[Active.Idx];
393 if (Active.Node->Children.count(FirstChar) == 0) {
395 insertLeaf(*Active.Node, EndIdx, FirstChar);
400 NeedsLink->Link = Active.Node;
406 SuffixTreeNode *NextNode = Active.Node->Children[FirstChar];
408 unsigned SubstringLen = NextNode->size();
412 if (Active.Len >= SubstringLen) {
415 Active.Idx += SubstringLen;
416 Active.Len -= SubstringLen;
417 Active.Node = NextNode;
423 unsigned LastChar = Str[EndIdx];
426 if (Str[NextNode->StartIdx + Active.Len] == LastChar) {
430 if (NeedsLink && !Active.Node->isRoot()) {
431 NeedsLink->Link = Active.Node;
453 SuffixTreeNode *SplitNode =
454 insertInternalNode(Active.Node, NextNode->StartIdx,
455 NextNode->StartIdx + Active.Len - 1, FirstChar);
459 insertLeaf(*SplitNode, EndIdx, LastChar);
463 NextNode->StartIdx += Active.Len;
464 NextNode->Parent = SplitNode;
465 SplitNode->Children[Str[NextNode->StartIdx]] = NextNode;
469 NeedsLink->Link = SplitNode;
471 NeedsLink = SplitNode;
478 if (Active.Node->isRoot()) {
479 if (Active.Len > 0) {
481 Active.Idx = EndIdx - SuffixesToAdd + 1;
485 Active.Node = Active.Node->Link;
489 return SuffixesToAdd;
496 SuffixTree(
const std::vector<unsigned> &Str) : Str(Str) {
497 Root = insertInternalNode(
nullptr, EmptyIdx, EmptyIdx, 0);
498 Root->IsInTree =
true;
500 LeafVector = std::vector<SuffixTreeNode *>(Str.size());
504 unsigned SuffixesToAdd = 0;
510 for (
unsigned PfxEndIdx = 0, End = Str.size(); PfxEndIdx < End;
513 LeafEndIdx = PfxEndIdx;
514 SuffixesToAdd = extend(PfxEndIdx, SuffixesToAdd);
518 assert(Root &&
"Root node can't be nullptr!");
519 setSuffixIndices(*Root, 0);
524 struct InstructionMapper {
530 unsigned IllegalInstrNumber = -3;
534 unsigned LegalInstrNumber = 0;
538 InstructionIntegerMap;
545 std::vector<unsigned> UnsignedVec;
549 std::vector<MachineBasicBlock::iterator> InstrList;
561 InstrList.push_back(It);
566 std::tie(ResultIt, WasInserted) =
567 InstructionIntegerMap.
insert(std::make_pair(&MI, LegalInstrNumber));
568 unsigned MINumber = ResultIt->second;
573 IntegerInstructionMap.
insert(std::make_pair(MINumber, &MI));
576 UnsignedVec.push_back(MINumber);
579 if (LegalInstrNumber >= IllegalInstrNumber)
583 "Tried to assign DenseMap tombstone or empty key to instruction.");
585 "Tried to assign DenseMap tombstone or empty key to instruction.");
596 unsigned MINumber = IllegalInstrNumber;
598 InstrList.push_back(It);
599 UnsignedVec.push_back(IllegalInstrNumber);
600 IllegalInstrNumber--;
602 assert(LegalInstrNumber < IllegalInstrNumber &&
603 "Instruction mapping overflow!");
606 "IllegalInstrNumber cannot be DenseMap tombstone or empty key!");
609 "IllegalInstrNumber cannot be DenseMap tombstone or empty key!");
634 mapToIllegalUnsigned(It);
638 mapToLegalUnsigned(It);
642 mapToLegalUnsigned(It);
643 InstrList.push_back(It);
644 UnsignedVec.push_back(IllegalInstrNumber);
645 IllegalInstrNumber--;
657 InstrList.push_back(MBB.
end());
658 UnsignedVec.push_back(IllegalInstrNumber);
659 IllegalInstrNumber--;
662 InstructionMapper() {
666 "DenseMapInfo<unsigned>'s empty key isn't -1!");
668 "DenseMapInfo<unsigned>'s tombstone key isn't -2!");
687 bool OutlineFromLinkOnceODRs =
false;
693 bool RunOnAllFunctions =
true;
696 std::vector<Function *> CreatedIRFunctions;
698 StringRef getPassName()
const override {
return "Machine Outliner"; }
713 void emitNotOutliningCheaperRemark(
714 unsigned StringLen, std::vector<Candidate> &CandidatesForRepeatedSeq,
715 OutlinedFunction &OF);
718 void emitOutlinedFunctionRemark(OutlinedFunction &OF);
738 findCandidates(SuffixTree &
ST,
739 InstructionMapper &Mapper,
740 std::vector<std::shared_ptr<Candidate>> &CandidateList,
741 std::vector<OutlinedFunction> &FunctionList);
752 const ArrayRef<std::shared_ptr<Candidate>> &CandidateList,
753 std::vector<OutlinedFunction> &FunctionList,
754 InstructionMapper &Mapper);
758 InstructionMapper &Mapper);
773 buildCandidateList(std::vector<std::shared_ptr<Candidate>> &CandidateList,
774 std::vector<OutlinedFunction> &FunctionList,
775 SuffixTree &
ST, InstructionMapper &Mapper);
779 void prune(Candidate &
C, std::vector<OutlinedFunction> &FunctionList);
793 void pruneOverlaps(std::vector<std::shared_ptr<Candidate>> &CandidateList,
794 std::vector<OutlinedFunction> &FunctionList,
795 InstructionMapper &Mapper,
unsigned MaxCandidateLen);
799 bool runOnModule(
Module &M)
override;
803 DISubprogram *getSubprogramOrNull(
const OutlinedFunction &OF) {
805 for (
const std::shared_ptr<Candidate> &
C : OF.Candidates)
806 if (C && C->getMF() && (SP = C->getMF()->getFunction().
getSubprogram()))
818 MachineOutliner *OL =
new MachineOutliner();
819 OL->RunOnAllFunctions = RunOnAllFunctions;
828 void MachineOutliner::emitNotOutliningCheaperRemark(
829 unsigned StringLen,
std::vector<Candidate> &CandidatesForRepeatedSeq,
830 OutlinedFunction &OF) {
831 Candidate &C = CandidatesForRepeatedSeq.front();
835 C.front()->getDebugLoc(), C.getMBB());
836 R <<
"Did not outline " <<
NV(
"Length", StringLen) <<
" instructions" 837 <<
" from " <<
NV(
"NumOccurrences", CandidatesForRepeatedSeq.size())
839 <<
" Bytes from outlining all occurrences (" 840 <<
NV(
"OutliningCost", OF.getOutliningCost()) <<
")" 841 <<
" >= Unoutlined instruction bytes (" 842 <<
NV(
"NotOutliningCost", OF.getNotOutlinedCost()) <<
")" 843 <<
" (Also found at: ";
846 for (
unsigned i = 1, e = CandidatesForRepeatedSeq.size(); i < e; i++) {
848 CandidatesForRepeatedSeq[i].front()->getDebugLoc());
858 void MachineOutliner::emitOutlinedFunctionRemark(OutlinedFunction &OF) {
863 R <<
"Saved " <<
NV(
"OutliningBenefit", OF.getBenefit()) <<
" bytes by " 864 <<
"outlining " <<
NV(
"Length", OF.Sequence.size()) <<
" instructions " 865 <<
"from " <<
NV(
"NumOccurrences", OF.getOccurrenceCount())
870 for (
size_t i = 0, e = OF.Candidates.size(); i < e; i++) {
873 if (!OF.Candidates[i]->InCandidateList)
877 OF.Candidates[i]->front()->getDebugLoc());
887 unsigned MachineOutliner::findCandidates(
888 SuffixTree &
ST, InstructionMapper &Mapper,
889 std::vector<std::shared_ptr<Candidate>> &CandidateList,
890 std::vector<OutlinedFunction> &FunctionList) {
891 CandidateList.clear();
892 FunctionList.clear();
896 for (SuffixTreeNode *Leaf : ST.LeafVector) {
897 assert(Leaf &&
"Leaves in LeafVector cannot be null!");
901 assert(Leaf->Parent &&
"All leaves must have parents!");
902 SuffixTreeNode &Parent = *(Leaf->Parent);
905 if (Parent.OccurrenceCount < 2 || Parent.isRoot() || !Parent.IsInTree)
909 unsigned StringLen = Leaf->ConcatLen - (
unsigned)Leaf->size();
919 std::vector<Candidate> CandidatesForRepeatedSeq;
922 for (
auto &ChildPair : Parent.Children) {
923 SuffixTreeNode *M = ChildPair.second;
925 if (M && M->IsInTree && M->isLeaf()) {
928 unsigned StartIdx = M->SuffixIdx;
929 unsigned EndIdx = StartIdx + StringLen - 1;
953 CandidatesForRepeatedSeq.end(),
954 [&StartIdx, &EndIdx](
const Candidate &
C) {
955 return (EndIdx < C.getStartIdx() ||
956 StartIdx > C.getEndIdx());
965 CandidatesForRepeatedSeq.emplace_back(StartIdx, StringLen, StartIt,
966 EndIt, StartIt->getParent(),
967 FunctionList.size());
975 if (CandidatesForRepeatedSeq.empty())
981 CandidatesForRepeatedSeq[0].getMF()->getSubtarget().getInstrInfo();
983 OutlinedFunction OF =
987 if (OF.Candidates.empty())
990 std::vector<unsigned> Seq;
991 for (
unsigned i = Leaf->SuffixIdx; i < Leaf->SuffixIdx + StringLen; i++)
992 Seq.push_back(ST.Str[i]);
994 OF.Name = FunctionList.size();
997 if (OF.getBenefit() < 1) {
998 emitNotOutliningCheaperRemark(StringLen, CandidatesForRepeatedSeq, OF);
1002 if (StringLen > MaxLen)
1007 for (std::shared_ptr<Candidate> &C : OF.Candidates)
1008 CandidateList.push_back(C);
1009 FunctionList.push_back(OF);
1012 Parent.IsInTree =
false;
1019 void MachineOutliner::prune(Candidate &C,
1020 std::vector<OutlinedFunction> &FunctionList) {
1022 OutlinedFunction &
F = FunctionList[C.FunctionIdx];
1028 C.InCandidateList =
false;
1031 dbgs() <<
"--- Num fns left for candidate: " 1032 << F.getOccurrenceCount() <<
"\n";
1033 dbgs() <<
"--- Candidate's functions's benefit: " << F.getBenefit()
1037 void MachineOutliner::pruneOverlaps(
1038 std::vector<std::shared_ptr<Candidate>> &CandidateList,
1039 std::vector<OutlinedFunction> &FunctionList, InstructionMapper &Mapper,
1040 unsigned MaxCandidateLen) {
1044 auto ShouldSkipCandidate = [&FunctionList,
this](Candidate &
C) {
1047 if (!C.InCandidateList)
1051 if (FunctionList[C.FunctionIdx].getBenefit() < 1) {
1052 prune(C, FunctionList);
1065 for (
auto It = CandidateList.begin(), Et = CandidateList.end(); It != Et;
1067 Candidate &C1 = **It;
1071 if (ShouldSkipCandidate(C1))
1076 unsigned FarthestPossibleIdx = 0;
1079 if (C1.getStartIdx() > MaxCandidateLen)
1080 FarthestPossibleIdx = C1.getStartIdx() - MaxCandidateLen;
1085 for (
auto Sit = It + 1; Sit != Et; Sit++) {
1086 Candidate &C2 = **Sit;
1089 if (C2.getStartIdx() < FarthestPossibleIdx)
1094 if (ShouldSkipCandidate(C2))
1105 if (C2.getEndIdx() < C1.getStartIdx())
1115 if (C2.Benefit > C1.Benefit) {
1118 prune(C1, FunctionList);
1123 prune(C2, FunctionList);
1128 unsigned MachineOutliner::buildCandidateList(
1129 std::vector<std::shared_ptr<Candidate>> &CandidateList,
1130 std::vector<OutlinedFunction> &FunctionList, SuffixTree &ST,
1131 InstructionMapper &Mapper) {
1133 std::vector<unsigned> CandidateSequence;
1134 unsigned MaxCandidateLen = 0;
1137 findCandidates(ST, Mapper, CandidateList, FunctionList);
1143 CandidateList.begin(), CandidateList.end(),
1144 [](
const std::shared_ptr<Candidate> &LHS,
1145 const std::shared_ptr<Candidate> &RHS) {
return *LHS < *RHS; });
1147 return MaxCandidateLen;
1151 MachineOutliner::createOutlinedFunction(
Module &M,
const OutlinedFunction &OF,
1152 InstructionMapper &Mapper) {
1157 std::ostringstream NameStream;
1158 NameStream <<
"OUTLINED_FUNCTION_" << OF.Name;
1164 assert(F &&
"Function was null!");
1176 F->
addFnAttr(Attribute::OptimizeForSize);
1180 CreatedIRFunctions.push_back(F);
1193 MF.insert(MF.begin(), &MBB);
1197 for (
unsigned Str : OF.Sequence) {
1199 MF.CloneMachineInstr(Mapper.IntegerInstructionMap.find(Str)->second);
1220 for (Function *F : CreatedIRFunctions) {
1233 DINode::DIFlags::FlagArtificial ,
1249 MF.getRegInfo().freezeReservedRegs(MF);
1253 bool MachineOutliner::outline(
1254 Module &M,
const ArrayRef<std::shared_ptr<Candidate>> &CandidateList,
1255 std::vector<OutlinedFunction> &FunctionList, InstructionMapper &Mapper) {
1257 bool OutlinedSomething =
false;
1259 for (
const std::shared_ptr<Candidate> &Cptr : CandidateList) {
1260 Candidate &C = *Cptr;
1262 if (!C.InCandidateList)
1266 OutlinedFunction &OF = FunctionList[C.FunctionIdx];
1269 if (OF.getBenefit() < 1)
1274 OF.MF = createOutlinedFunction(M, OF, Mapper);
1275 emitOutlinedFunctionRemark(OF);
1283 assert(StartIt != C.getMBB()->end() &&
"StartIt out of bounds!");
1284 assert(EndIt != C.getMBB()->end() &&
"EndIt out of bounds!");
1324 MBB.
erase(std::next(StartIt), std::next(EndIt));
1325 OutlinedSomething =
true;
1331 LLVM_DEBUG(
dbgs() <<
"OutlinedSomething = " << OutlinedSomething <<
"\n";);
1333 return OutlinedSomething;
1336 bool MachineOutliner::runOnModule(
Module &M) {
1350 dbgs() <<
"Machine Outliner: Running on ";
1351 if (RunOnAllFunctions)
1352 dbgs() <<
"all functions";
1354 dbgs() <<
"target-default functions";
1362 InstructionMapper Mapper;
1407 Mapper.convertToUnsignedVec(MBB, *TII);
1412 SuffixTree
ST(Mapper.UnsignedVec);
1413 std::vector<std::shared_ptr<Candidate>> CandidateList;
1414 std::vector<OutlinedFunction> FunctionList;
1417 unsigned MaxCandidateLen =
1418 buildCandidateList(CandidateList, FunctionList, ST, Mapper);
1421 pruneOverlaps(CandidateList, FunctionList, Mapper, MaxCandidateLen);
1424 bool OutlinedSomething = outline(M, CandidateList, FunctionList, Mapper);
1426 return OutlinedSomething;
void finalize()
Construct any deferred debug info descriptors.
std::vector< unsigned > Sequence
The sequence of integers corresponding to the instructions in this function.
DISubprogram * createFunction(DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit, bool isDefinition, unsigned ScopeLine, DINode::DIFlags Flags=DINode::FlagZero, bool isOptimized=false, DITemplateParameterArray TParams=nullptr, DISubprogram *Decl=nullptr, DITypeArray ThrownTypes=nullptr)
Create a new descriptor for the specified subprogram.
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
DiagnosticInfoOptimizationBase::Argument NV
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Compute iterated dominance frontiers using a linear time algorithm.
Constant * getOrInsertFunction(StringRef Name, FunctionType *T, AttributeList AttributeList)
Look up the specified function in the module symbol table.
A Module instance is used to store all the information related to an LLVM module. ...
const MachineFunctionProperties & getProperties() const
Get the function properties.
This class represents a function call, abstracting a target machine's calling convention.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly...
STATISTIC(NumFunctions, "Total number of functions")
iterator_range< mop_iterator > operands()
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
static MachineOperand CreateReg(unsigned Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isEarlyClobber=false, unsigned SubReg=0, bool isDebug=false, bool isInternalRead=false, bool isRenamable=false)
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
AnalysisUsage & addRequired()
virtual MachineBasicBlock::iterator insertOutlinedCall(Module &M, MachineBasicBlock &MBB, MachineBasicBlock::iterator &It, MachineFunction &MF, const outliner::Candidate &C) const
Insert a call to an outlined function into the program.
instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
const HexagonInstrInfo * TII
LLVMContext & getContext() const
Get the global data context.
DISubroutineType * createSubroutineType(DITypeRefArray ParameterTypes, DINode::DIFlags Flags=DINode::FlagZero, unsigned CC=0)
Create subroutine type.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
virtual const TargetInstrInfo * getInstrInfo() const
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
virtual bool isFunctionSafeToOutlineFrom(MachineFunction &MF, bool OutlineFromLinkOnceODRs) const
Return true if the function can safely be outlined from.
TargetInstrInfo - Interface to description of machine instruction set.
DITypeRefArray getOrCreateTypeArray(ArrayRef< Metadata *> Elements)
Get a DITypeRefArray, create one if required.
virtual bool shouldOutlineFromFunctionByDefault(MachineFunction &MF) const
Return true if the function should be outlined from by default.
initializer< Ty > init(const Ty &Val)
void setSubprogram(DISubprogram *SP)
Set the attached subprogram.
bool isLeaf(ID id)
Returns true if the intrinsic is a leaf, i.e.
LLVM Basic Block Representation.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
This is an important class for using LLVM in a threaded context.
Allocate memory in an ever growing pool, as if by bump-pointer.
size_t size() const
size - Get the array size.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
DebugLoc findDebugLoc(instr_iterator MBBI)
Find the next valid DebugLoc starting at MBBI, skipping any DBG_VALUE and DBG_LABEL instructions...
virtual outliner::InstrType getOutliningType(MachineBasicBlock::iterator &MIT, unsigned Flags) const
Returns how or if MI should be outlined.
Contains all data structures shared between the outliner implemented in MachineOutliner.cpp and target implementations of the outliner.
Represent the analysis usage information of a pass.
static Type * getVoidTy(LLVMContext &C)
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
T * Allocate(size_t num=1)
Allocate space for an array of objects without constructing them.
bool hasAddressTaken() const
Test whether this block is potentially the target of an indirect branch.
MachineFunction & getOrCreateMachineFunction(const Function &F)
Returns the MachineFunction constructed for the IR function F.
ModulePass * createMachineOutlinerPass(bool RunOnAllFunctions=true)
This pass performs outlining on machine instructions directly before printing assembly.
std::string & str()
Flushes the stream contents to the target string and returns the string's reference.
void initializeMachineOutlinerPass(PassRegistry &)
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
virtual void buildOutlinedFrame(MachineBasicBlock &MBB, MachineFunction &MF, const outliner::OutlinedFunction &OF) const
Insert a custom frame for outlined functions.
void dropMemRefs()
Clear this MachineInstr's memory reference descriptor list.
MachineFunction * getMachineFunction(const Function &F) const
Returns the MachineFunction associated to IR function F if there is one, otherwise nullptr...
MachineOperand class - Representation of each machine instruction operand.
A BumpPtrAllocator that allows only elements of a specific type to be allocated.
void setLinkage(LinkageTypes LT)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
DISubprogram * getSubprogram() const
Get the subprogram for this scope.
void setDebugLoc(DebugLoc dl)
Replace current source information with new such.
void setPreservesAll()
Set by analyses that do not transform their input at all.
TargetSubtargetInfo - Generic base class for all target subtargets.
Representation of each machine instruction.
ReturnInst * CreateRetVoid()
Create a 'ret void' instruction.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
void setUnnamedAddr(UnnamedAddr Val)
StringRef getName() const
Return a constant reference to the value's name.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Rename collisions when linking (static functions).
void finalizeSubprogram(DISubprogram *SP)
Finalize a specific subprogram - no new variables may be added to this subprogram afterwards...
INITIALIZE_PASS(MachineOutliner, DEBUG_TYPE, "Machine Function Outliner", false, false) void MachineOutliner
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool hasProperty(Property P) const
A raw_ostream that writes to an std::string.
void getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV, bool CannotUsePrivateLabel) const
Print the appropriate prefix and the specified global variable's name.
void addFnAttr(Attribute::AttrKind Kind)
Add function attributes to this function.
StringRef - Represent a constant reference to a string, i.e.
UnaryPredicate for_each(R &&Range, UnaryPredicate P)
Provide wrappers to std::for_each which take ranges instead of having to pass begin/end explicitly...
static cl::opt< bool > EnableLinkOnceODROutlining("enable-linkonceodr-outlining", cl::Hidden, cl::desc("Enable the machine outliner on linkonceodr functions"), cl::init(false))
virtual unsigned getMachineOutlinerMBBFlags(MachineBasicBlock &MBB) const
Returns target-defined flags defining properties of the MBB for the outliner.
virtual outliner::OutlinedFunction getOutliningCandidateInfo(std::vector< outliner::Candidate > &RepeatedSequenceLocs) const
Returns a outliner::OutlinedFunction struct containing target-specific information for a set of outli...
The operation is expected to be selectable directly by the target, and no transformation is necessary...
This class contains meta information specific to a module.