80 #define DEBUG_TYPE "machine-outliner" 86 STATISTIC(NumOutlined,
"Number of candidates outlined");
87 STATISTIC(FunctionsCreated,
"Number of functions created");
96 cl::desc(
"Enable the machine outliner on linkonceodr functions"),
102 const unsigned EmptyIdx = -1;
119 struct SuffixTreeNode {
129 unsigned StartIdx = EmptyIdx;
137 unsigned *EndIdx =
nullptr;
142 unsigned SuffixIdx = EmptyIdx;
162 SuffixTreeNode *
Link =
nullptr;
166 unsigned ConcatLen = 0;
169 bool isLeaf()
const {
return SuffixIdx != EmptyIdx; }
172 bool isRoot()
const {
return StartIdx == EmptyIdx; }
175 size_t size()
const {
181 assert(*EndIdx != EmptyIdx &&
"EndIdx is undefined!");
185 return *EndIdx - StartIdx + 1;
188 SuffixTreeNode(
unsigned StartIdx,
unsigned *EndIdx, SuffixTreeNode *Link)
189 : StartIdx(StartIdx), EndIdx(EndIdx), Link(Link) {}
222 struct RepeatedSubstring {
227 std::vector<unsigned> StartIndices;
238 SuffixTreeNode *Root =
nullptr;
250 unsigned LeafEndIdx = -1;
256 SuffixTreeNode *Node =
nullptr;
259 unsigned Idx = EmptyIdx;
276 SuffixTreeNode *insertLeaf(SuffixTreeNode &Parent,
unsigned StartIdx,
279 assert(StartIdx <= LeafEndIdx &&
"String can't start after it ends!");
281 SuffixTreeNode *
N =
new (NodeAllocator.
Allocate())
282 SuffixTreeNode(StartIdx, &LeafEndIdx,
nullptr);
283 Parent.Children[Edge] =
N;
296 SuffixTreeNode *insertInternalNode(SuffixTreeNode *Parent,
unsigned StartIdx,
297 unsigned EndIdx,
unsigned Edge) {
299 assert(StartIdx <= EndIdx &&
"String can't start after it ends!");
300 assert(!(!Parent && StartIdx != EmptyIdx) &&
301 "Non-root internal nodes must have parents!");
303 unsigned *
E =
new (InternalEndIdxAllocator)
unsigned(EndIdx);
305 new (NodeAllocator.
Allocate()) SuffixTreeNode(StartIdx, E, Root);
307 Parent->Children[Edge] =
N;
314 void setSuffixIndices() {
317 std::vector<std::pair<SuffixTreeNode *, unsigned>> ToVisit;
320 SuffixTreeNode *CurrNode = Root;
323 unsigned CurrNodeLen = 0;
324 ToVisit.push_back({CurrNode, CurrNodeLen});
325 while (!ToVisit.empty()) {
326 std::tie(CurrNode, CurrNodeLen) = ToVisit.back();
328 CurrNode->ConcatLen = CurrNodeLen;
329 for (
auto &ChildPair : CurrNode->Children) {
330 assert(ChildPair.second &&
"Node had a null child!");
332 {ChildPair.second, CurrNodeLen + ChildPair.second->size()});
336 if (CurrNode->Children.size() == 0 && !CurrNode->isRoot())
337 CurrNode->SuffixIdx = Str.
size() - CurrNodeLen;
355 unsigned extend(
unsigned EndIdx,
unsigned SuffixesToAdd) {
356 SuffixTreeNode *NeedsLink =
nullptr;
358 while (SuffixesToAdd > 0) {
361 if (Active.Len == 0) {
366 assert(Active.Idx <= EndIdx &&
"Start index can't be after end index!");
369 unsigned FirstChar = Str[Active.Idx];
372 if (Active.Node->Children.count(FirstChar) == 0) {
374 insertLeaf(*Active.Node, EndIdx, FirstChar);
379 NeedsLink->Link = Active.Node;
385 SuffixTreeNode *NextNode = Active.Node->Children[FirstChar];
387 unsigned SubstringLen = NextNode->size();
391 if (Active.Len >= SubstringLen) {
394 Active.Idx += SubstringLen;
395 Active.Len -= SubstringLen;
396 Active.Node = NextNode;
402 unsigned LastChar = Str[EndIdx];
405 if (Str[NextNode->StartIdx + Active.Len] == LastChar) {
409 if (NeedsLink && !Active.Node->isRoot()) {
410 NeedsLink->Link = Active.Node;
432 SuffixTreeNode *SplitNode =
433 insertInternalNode(Active.Node, NextNode->StartIdx,
434 NextNode->StartIdx + Active.Len - 1, FirstChar);
438 insertLeaf(*SplitNode, EndIdx, LastChar);
442 NextNode->StartIdx += Active.Len;
443 SplitNode->Children[Str[NextNode->StartIdx]] = NextNode;
447 NeedsLink->Link = SplitNode;
449 NeedsLink = SplitNode;
456 if (Active.Node->isRoot()) {
457 if (Active.Len > 0) {
459 Active.Idx = EndIdx - SuffixesToAdd + 1;
463 Active.Node = Active.Node->Link;
467 return SuffixesToAdd;
474 SuffixTree(
const std::vector<unsigned> &Str) : Str(Str) {
475 Root = insertInternalNode(
nullptr, EmptyIdx, EmptyIdx, 0);
480 unsigned SuffixesToAdd = 0;
485 for (
unsigned PfxEndIdx = 0, End = Str.size(); PfxEndIdx < End;
488 LeafEndIdx = PfxEndIdx;
489 SuffixesToAdd = extend(PfxEndIdx, SuffixesToAdd);
493 assert(Root &&
"Root node can't be nullptr!");
498 struct RepeatedSubstringIterator {
501 SuffixTreeNode *N =
nullptr;
504 RepeatedSubstring RS;
507 std::vector<SuffixTreeNode *> ToVisit;
513 const unsigned MinLength = 2;
519 RS = RepeatedSubstring();
523 std::vector<SuffixTreeNode *> LeafChildren;
526 while (!ToVisit.empty()) {
527 SuffixTreeNode *Curr = ToVisit.back();
529 LeafChildren.clear();
533 unsigned Length = Curr->ConcatLen;
538 for (
auto &ChildPair : Curr->Children) {
540 if (!ChildPair.second->isLeaf())
541 ToVisit.push_back(ChildPair.second);
545 else if (Length >= MinLength)
546 LeafChildren.push_back(ChildPair.second);
555 if (LeafChildren.size() >= 2) {
559 for (SuffixTreeNode *Leaf : LeafChildren)
560 RS.StartIndices.push_back(Leaf->SuffixIdx);
572 RepeatedSubstring &
operator*() {
return RS; }
574 RepeatedSubstringIterator &operator++() {
579 RepeatedSubstringIterator operator++(
int I) {
580 RepeatedSubstringIterator It(*
this);
585 bool operator==(
const RepeatedSubstringIterator &Other) {
588 bool operator!=(
const RepeatedSubstringIterator &Other) {
589 return !(*
this == Other);
592 RepeatedSubstringIterator(SuffixTreeNode *N) : N(N) {
597 ToVisit.push_back(N);
603 typedef RepeatedSubstringIterator iterator;
604 iterator
begin() {
return iterator(Root); }
605 iterator
end() {
return iterator(
nullptr); }
609 struct InstructionMapper {
615 unsigned IllegalInstrNumber = -3;
619 unsigned LegalInstrNumber = 0;
623 InstructionIntegerMap;
629 std::vector<unsigned> UnsignedVec;
633 std::vector<MachineBasicBlock::iterator> InstrList;
639 bool AddedIllegalLastTime =
false;
647 unsigned mapToLegalUnsigned(
649 bool &HaveLegalRange,
unsigned &NumLegalInBlock,
650 std::vector<unsigned> &UnsignedVecForMBB,
651 std::vector<MachineBasicBlock::iterator> &InstrListForMBB) {
654 AddedIllegalLastTime =
false;
658 if (CanOutlineWithPrevInstr)
659 HaveLegalRange =
true;
660 CanOutlineWithPrevInstr =
true;
667 InstrListForMBB.push_back(It);
672 std::tie(ResultIt, WasInserted) =
673 InstructionIntegerMap.
insert(std::make_pair(&MI, LegalInstrNumber));
674 unsigned MINumber = ResultIt->second;
680 UnsignedVecForMBB.push_back(MINumber);
683 if (LegalInstrNumber >= IllegalInstrNumber)
687 "Tried to assign DenseMap tombstone or empty key to instruction.");
689 "Tried to assign DenseMap tombstone or empty key to instruction.");
700 unsigned mapToIllegalUnsigned(
702 std::vector<unsigned> &UnsignedVecForMBB,
703 std::vector<MachineBasicBlock::iterator> &InstrListForMBB) {
705 CanOutlineWithPrevInstr =
false;
708 if (AddedIllegalLastTime)
709 return IllegalInstrNumber;
712 AddedIllegalLastTime =
true;
713 unsigned MINumber = IllegalInstrNumber;
715 InstrListForMBB.push_back(It);
716 UnsignedVecForMBB.push_back(IllegalInstrNumber);
717 IllegalInstrNumber--;
719 assert(LegalInstrNumber < IllegalInstrNumber &&
720 "Instruction mapping overflow!");
723 "IllegalInstrNumber cannot be DenseMap tombstone or empty key!");
726 "IllegalInstrNumber cannot be DenseMap tombstone or empty key!");
750 MBBFlagsMap[&MBB] = Flags;
756 unsigned NumLegalInBlock = 0;
760 bool HaveLegalRange =
false;
764 bool CanOutlineWithPrevInstr =
false;
768 std::vector<unsigned> UnsignedVecForMBB;
769 std::vector<MachineBasicBlock::iterator> InstrListForMBB;
775 mapToIllegalUnsigned(It, CanOutlineWithPrevInstr, UnsignedVecForMBB,
780 mapToLegalUnsigned(It, CanOutlineWithPrevInstr, HaveLegalRange,
781 NumLegalInBlock, UnsignedVecForMBB, InstrListForMBB);
785 mapToLegalUnsigned(It, CanOutlineWithPrevInstr, HaveLegalRange,
786 NumLegalInBlock, UnsignedVecForMBB, InstrListForMBB);
789 mapToIllegalUnsigned(It, CanOutlineWithPrevInstr, UnsignedVecForMBB,
796 AddedIllegalLastTime =
false;
803 if (HaveLegalRange) {
808 mapToIllegalUnsigned(It, CanOutlineWithPrevInstr, UnsignedVecForMBB,
810 InstrList.insert(InstrList.end(), InstrListForMBB.begin(),
811 InstrListForMBB.end());
812 UnsignedVec.insert(UnsignedVec.end(), UnsignedVecForMBB.begin(),
813 UnsignedVecForMBB.end());
817 InstructionMapper() {
821 "DenseMapInfo<unsigned>'s empty key isn't -1!");
823 "DenseMapInfo<unsigned>'s tombstone key isn't -2!");
842 bool OutlineFromLinkOnceODRs =
false;
848 bool RunOnAllFunctions =
true;
850 StringRef getPassName()
const override {
return "Machine Outliner"; }
865 void emitNotOutliningCheaperRemark(
866 unsigned StringLen, std::vector<Candidate> &CandidatesForRepeatedSeq,
867 OutlinedFunction &OF);
870 void emitOutlinedFunctionRemark(OutlinedFunction &OF);
885 void findCandidates(InstructionMapper &Mapper,
886 std::vector<OutlinedFunction> &FunctionList);
894 bool outline(
Module &M, std::vector<OutlinedFunction> &FunctionList,
895 InstructionMapper &Mapper,
unsigned &OutlinedFunctionNum);
899 InstructionMapper &Mapper,
903 bool runOnModule(
Module &M)
override;
907 bool doOutline(
Module &M,
unsigned &OutlinedFunctionNum);
911 DISubprogram *getSubprogramOrNull(
const OutlinedFunction &OF) {
912 for (
const Candidate &
C : OF.Candidates)
921 void populateMapper(InstructionMapper &Mapper,
Module &M,
943 MachineOutliner *OL =
new MachineOutliner();
944 OL->RunOnAllFunctions = RunOnAllFunctions;
953 void MachineOutliner::emitNotOutliningCheaperRemark(
954 unsigned StringLen,
std::vector<Candidate> &CandidatesForRepeatedSeq,
955 OutlinedFunction &OF) {
960 Candidate &C = CandidatesForRepeatedSeq.front();
964 C.front()->getDebugLoc(), C.getMBB());
965 R <<
"Did not outline " <<
NV(
"Length", StringLen) <<
" instructions" 966 <<
" from " <<
NV(
"NumOccurrences", CandidatesForRepeatedSeq.size())
968 <<
" Bytes from outlining all occurrences (" 969 <<
NV(
"OutliningCost", OF.getOutliningCost()) <<
")" 970 <<
" >= Unoutlined instruction bytes (" 971 <<
NV(
"NotOutliningCost", OF.getNotOutlinedCost()) <<
")" 972 <<
" (Also found at: ";
975 for (
unsigned i = 1,
e = CandidatesForRepeatedSeq.size(); i <
e; i++) {
977 CandidatesForRepeatedSeq[i].front()->
getDebugLoc());
987 void MachineOutliner::emitOutlinedFunctionRemark(OutlinedFunction &OF) {
992 R <<
"Saved " <<
NV(
"OutliningBenefit", OF.getBenefit()) <<
" bytes by " 993 <<
"outlining " <<
NV(
"Length", OF.getNumInstrs()) <<
" instructions " 994 <<
"from " <<
NV(
"NumOccurrences", OF.getOccurrenceCount())
999 for (
size_t i = 0,
e = OF.Candidates.size(); i <
e; i++) {
1002 OF.Candidates[i].front()->getDebugLoc());
1012 void MachineOutliner::findCandidates(
1013 InstructionMapper &Mapper, std::vector<OutlinedFunction> &FunctionList) {
1014 FunctionList.clear();
1015 SuffixTree
ST(Mapper.UnsignedVec);
1019 std::vector<Candidate> CandidatesForRepeatedSeq;
1020 for (
auto It = ST.begin(), Et = ST.end(); It != Et; ++It) {
1021 CandidatesForRepeatedSeq.clear();
1022 SuffixTree::RepeatedSubstring RS = *It;
1023 unsigned StringLen = RS.Length;
1024 for (
const unsigned &StartIdx : RS.StartIndices) {
1025 unsigned EndIdx = StartIdx + StringLen - 1;
1048 CandidatesForRepeatedSeq.begin(), CandidatesForRepeatedSeq.end(),
1049 [&StartIdx, &EndIdx](
const Candidate &
C) {
1050 return (EndIdx < C.getStartIdx() || StartIdx > C.getEndIdx());
1060 CandidatesForRepeatedSeq.emplace_back(StartIdx, StringLen, StartIt,
1061 EndIt, MBB, FunctionList.
size(),
1062 Mapper.MBBFlagsMap[MBB]);
1069 if (CandidatesForRepeatedSeq.size() < 2)
1075 CandidatesForRepeatedSeq[0].getMF()->getSubtarget().getInstrInfo();
1077 OutlinedFunction OF =
1082 if (OF.Candidates.size() < 2)
1086 if (OF.getBenefit() < 1) {
1087 emitNotOutliningCheaperRemark(StringLen, CandidatesForRepeatedSeq, OF);
1091 FunctionList.push_back(OF);
1096 Module &M, OutlinedFunction &OF, InstructionMapper &Mapper,
unsigned Name) {
1101 std::string FunctionName = (
"OUTLINED_FUNCTION_" +
Twine(Name)).str();
1118 F->
addFnAttr(Attribute::OptimizeForSize);
1125 Candidate &FirstCand = OF.Candidates.front();
1143 for (
auto I = FirstCand.front(), E = std::next(FirstCand.back());
I !=
E;
1178 DINode::DIFlags::FlagArtificial ,
1180 DISubprogram::SPFlagDefinition | DISubprogram::SPFlagOptimized);
1194 bool MachineOutliner::outline(
Module &M,
1195 std::vector<OutlinedFunction> &FunctionList,
1196 InstructionMapper &Mapper,
1197 unsigned &OutlinedFunctionNum) {
1199 bool OutlinedSomething =
false;
1203 const OutlinedFunction &RHS) {
1204 return LHS.getBenefit() > RHS.getBenefit();
1209 for (OutlinedFunction &OF : FunctionList) {
1212 erase_if(OF.Candidates, [&Mapper](Candidate &C) {
1214 Mapper.UnsignedVec.begin() + C.getStartIdx(),
1215 Mapper.UnsignedVec.begin() + C.getEndIdx() + 1,
1216 [](unsigned I) { return (I == static_cast<unsigned>(-1)); });
1220 if (OF.getBenefit() < 1)
1225 OF.MF = createOutlinedFunction(M, OF, Mapper, OutlinedFunctionNum);
1226 emitOutlinedFunctionRemark(OF);
1228 OutlinedFunctionNum++;
1234 for (Candidate &C : OF.Candidates) {
1278 MBB.
erase(std::next(StartIt), std::next(EndIt));
1282 Mapper.UnsignedVec.begin() + C.getEndIdx() + 1,
1283 [](
unsigned &
I) {
I =
static_cast<unsigned>(-1); });
1284 OutlinedSomething =
true;
1291 LLVM_DEBUG(
dbgs() <<
"OutlinedSomething = " << OutlinedSomething <<
"\n";);
1293 return OutlinedSomething;
1296 void MachineOutliner::populateMapper(InstructionMapper &Mapper,
Module &M,
1345 Mapper.convertToUnsignedVec(MBB, *TII);
1350 void MachineOutliner::initSizeRemarkInfo(
1366 void MachineOutliner::emitInstrCountChangedRemark(
1380 std::string Fname =
F.getName();
1382 unsigned FnCountBefore = 0;
1385 auto It = FunctionToInstrCount.
find(Fname);
1389 if (It != FunctionToInstrCount.
end())
1390 FnCountBefore = It->second;
1393 int64_t FnDelta = static_cast<int64_t>(FnCountAfter) -
1394 static_cast<int64_t
>(FnCountBefore);
1405 <<
": MI instruction count changed from " 1418 bool MachineOutliner::runOnModule(
Module &M) {
1425 unsigned OutlinedFunctionNum = 0;
1427 if (!doOutline(M, OutlinedFunctionNum))
1432 bool MachineOutliner::doOutline(
Module &M,
unsigned &OutlinedFunctionNum) {
1441 dbgs() <<
"Machine Outliner: Running on ";
1442 if (RunOnAllFunctions)
1443 dbgs() <<
"all functions";
1445 dbgs() <<
"target-default functions";
1452 InstructionMapper Mapper;
1455 populateMapper(Mapper, M, MMI);
1456 std::vector<OutlinedFunction> FunctionList;
1459 findCandidates(Mapper, FunctionList);
1472 if (ShouldEmitSizeRemarks)
1473 initSizeRemarkInfo(M, MMI, FunctionToInstrCount);
1476 bool OutlinedSomething =
1477 outline(M, FunctionList, Mapper, OutlinedFunctionNum);
1482 if (ShouldEmitSizeRemarks && OutlinedSomething)
1483 emitInstrCountChangedRemark(M, MMI, FunctionToInstrCount);
1485 return OutlinedSomething;
void finalize()
Construct any deferred debug info descriptors.
const Function & getFunction() const
unsigned getInstructionCount() const
Return the number of MachineInstrs in this MachineFunction.
const_iterator end(StringRef path)
Get end iterator over path.
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...
bool isCall(QueryType Type=AnyInBundle) const
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
DiagnosticInfoOptimizationBase::Argument NV
const MachineFunction * getMF() const
Return the function that contains the basic block that this instruction belongs to.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
MachineFunctionProperties & reset(Property P)
A Module instance is used to store all the information related to an LLVM module. ...
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
const MachineFunctionProperties & getProperties() const
Get the function properties.
This class represents a function call, abstracting a target machine's calling convention.
iterator find(StringRef Key)
Externally visible function.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
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")
DISubprogram * createFunction(DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DISubroutineType *Ty, unsigned ScopeLine, DINode::DIFlags Flags=DINode::FlagZero, DISubprogram::DISPFlags SPFlags=DISubprogram::SPFlagZero, DITemplateParameterArray TParams=nullptr, DISubprogram *Decl=nullptr, DITypeArray ThrownTypes=nullptr)
Create a new descriptor for the specified subprogram.
iterator_range< mop_iterator > operands()
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
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.
void freezeReservedRegs(const MachineFunction &)
freezeReservedRegs - Called by the register allocator to freeze the set of reserved registers before ...
APInt operator*(APInt a, uint64_t RHS)
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
void eraseCallSiteInfo(const MachineInstr *MI)
Erase the call site info for MI.
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.
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=nullptr)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
void dropMemRefs(MachineFunction &MF)
Clear this MachineInstr's memory reference descriptor list.
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.
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
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.
bool shouldEmitInstrCountChangedRemark()
Return true if size-info optimization remark is enabled, false otherwise.
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.
virtual bool isMBBSafeToOutlineFrom(MachineBasicBlock &MBB, unsigned &Flags) const
Optional target hook that returns true if MBB is safe to outline from, and returns any target-specifi...
Represent the analysis usage information of a pass.
static Type * getVoidTy(LLVMContext &C)
static FunctionType * get(Type *Result, ArrayRef< Type *> Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
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.
static MachineOperand CreateReg(Register 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)
Used in the streaming interface as the general argument type.
bool hasAddressTaken() const
Test whether this block is potentially the target of an indirect branch.
const MachineBasicBlock & front() const
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.
MachineInstr * CloneMachineInstr(const MachineInstr *Orig)
Create a new MachineInstr which is a copy of Orig, identical in all ways except the instruction has n...
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)
void erase_if(Container &C, UnaryPredicate P)
Provide a container algorithm similar to C++ Library Fundamentals v2's erase_if which is equivalent t...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
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.
bool operator!=(uint64_t V1, const APInt &V2)
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)
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
static DebugLoc getDebugLoc(MachineBasicBlock::instr_iterator FirstMI, MachineBasicBlock::instr_iterator LastMI)
Return the first found DebugLoc that has a DILocation, given a range of instructions.
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...
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
void insert(iterator MBBI, MachineBasicBlock *MBB)
void stable_sort(R &&Range)
A raw_ostream that writes to an std::string.
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
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.
bool operator==(uint64_t V1, const APInt &V2)
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 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.