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 unsigned StartIdx = EmptyIdx;
140 unsigned *EndIdx =
nullptr;
145 unsigned SuffixIdx = EmptyIdx;
165 SuffixTreeNode *
Link =
nullptr;
169 unsigned ConcatLen = 0;
172 bool isLeaf()
const {
return SuffixIdx != EmptyIdx; }
175 bool isRoot()
const {
return StartIdx == EmptyIdx; }
178 size_t size()
const {
184 assert(*EndIdx != EmptyIdx &&
"EndIdx is undefined!");
188 return *EndIdx - StartIdx + 1;
191 SuffixTreeNode(
unsigned StartIdx,
unsigned *EndIdx, SuffixTreeNode *Link)
192 : StartIdx(StartIdx), EndIdx(EndIdx), Link(Link) {}
225 struct RepeatedSubstring {
230 std::vector<unsigned> StartIndices;
241 SuffixTreeNode *Root =
nullptr;
253 unsigned LeafEndIdx = -1;
259 SuffixTreeNode *Node;
262 unsigned Idx = EmptyIdx;
279 SuffixTreeNode *insertLeaf(SuffixTreeNode &Parent,
unsigned StartIdx,
282 assert(StartIdx <= LeafEndIdx &&
"String can't start after it ends!");
284 SuffixTreeNode *
N =
new (NodeAllocator.
Allocate())
285 SuffixTreeNode(StartIdx, &LeafEndIdx,
nullptr);
286 Parent.Children[Edge] =
N;
299 SuffixTreeNode *insertInternalNode(SuffixTreeNode *Parent,
unsigned StartIdx,
300 unsigned EndIdx,
unsigned Edge) {
302 assert(StartIdx <= EndIdx &&
"String can't start after it ends!");
303 assert(!(!Parent && StartIdx != EmptyIdx) &&
304 "Non-root internal nodes must have parents!");
306 unsigned *
E =
new (InternalEndIdxAllocator)
unsigned(EndIdx);
307 SuffixTreeNode *N =
new (NodeAllocator.
Allocate())
308 SuffixTreeNode(StartIdx, E, Root);
310 Parent->Children[Edge] =
N;
321 void setSuffixIndices(SuffixTreeNode &CurrNode,
unsigned CurrNodeLen) {
323 bool IsLeaf = CurrNode.Children.size() == 0 && !CurrNode.isRoot();
326 CurrNode.ConcatLen = CurrNodeLen;
328 for (
auto &ChildPair : CurrNode.Children) {
329 assert(ChildPair.second &&
"Node had a null child!");
330 setSuffixIndices(*ChildPair.second,
331 CurrNodeLen + ChildPair.second->size());
336 CurrNode.SuffixIdx = Str.
size() - CurrNodeLen;
353 unsigned extend(
unsigned EndIdx,
unsigned SuffixesToAdd) {
354 SuffixTreeNode *NeedsLink =
nullptr;
356 while (SuffixesToAdd > 0) {
359 if (Active.Len == 0) {
364 assert(Active.Idx <= EndIdx &&
"Start index can't be after end index!");
367 unsigned FirstChar = Str[Active.Idx];
370 if (Active.Node->Children.count(FirstChar) == 0) {
372 insertLeaf(*Active.Node, EndIdx, FirstChar);
377 NeedsLink->Link = Active.Node;
383 SuffixTreeNode *NextNode = Active.Node->Children[FirstChar];
385 unsigned SubstringLen = NextNode->size();
389 if (Active.Len >= SubstringLen) {
392 Active.Idx += SubstringLen;
393 Active.Len -= SubstringLen;
394 Active.Node = NextNode;
400 unsigned LastChar = Str[EndIdx];
403 if (Str[NextNode->StartIdx + Active.Len] == LastChar) {
407 if (NeedsLink && !Active.Node->isRoot()) {
408 NeedsLink->Link = Active.Node;
430 SuffixTreeNode *SplitNode =
431 insertInternalNode(Active.Node, NextNode->StartIdx,
432 NextNode->StartIdx + Active.Len - 1, FirstChar);
436 insertLeaf(*SplitNode, EndIdx, LastChar);
440 NextNode->StartIdx += Active.Len;
441 SplitNode->Children[Str[NextNode->StartIdx]] = NextNode;
445 NeedsLink->Link = SplitNode;
447 NeedsLink = SplitNode;
454 if (Active.Node->isRoot()) {
455 if (Active.Len > 0) {
457 Active.Idx = EndIdx - SuffixesToAdd + 1;
461 Active.Node = Active.Node->Link;
465 return SuffixesToAdd;
472 SuffixTree(
const std::vector<unsigned> &Str) : Str(Str) {
473 Root = insertInternalNode(
nullptr, EmptyIdx, EmptyIdx, 0);
478 unsigned SuffixesToAdd = 0;
484 for (
unsigned PfxEndIdx = 0, End = Str.size(); PfxEndIdx < End;
487 LeafEndIdx = PfxEndIdx;
488 SuffixesToAdd = extend(PfxEndIdx, SuffixesToAdd);
492 assert(Root &&
"Root node can't be nullptr!");
493 setSuffixIndices(*Root, 0);
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.");
701 bool &CanOutlineWithPrevInstr, std::vector<unsigned> &UnsignedVecForMBB,
702 std::vector<MachineBasicBlock::iterator> &InstrListForMBB) {
704 CanOutlineWithPrevInstr =
false;
707 if (AddedIllegalLastTime)
708 return IllegalInstrNumber;
711 AddedIllegalLastTime =
true;
712 unsigned MINumber = IllegalInstrNumber;
714 InstrListForMBB.push_back(It);
715 UnsignedVecForMBB.push_back(IllegalInstrNumber);
716 IllegalInstrNumber--;
718 assert(LegalInstrNumber < IllegalInstrNumber &&
719 "Instruction mapping overflow!");
722 "IllegalInstrNumber cannot be DenseMap tombstone or empty key!");
725 "IllegalInstrNumber cannot be DenseMap tombstone or empty key!");
749 MBBFlagsMap[&MBB] = Flags;
755 unsigned NumLegalInBlock = 0;
759 bool HaveLegalRange =
false;
763 bool CanOutlineWithPrevInstr =
false;
767 std::vector<unsigned> UnsignedVecForMBB;
768 std::vector<MachineBasicBlock::iterator> InstrListForMBB;
774 mapToIllegalUnsigned(It, CanOutlineWithPrevInstr,
775 UnsignedVecForMBB, InstrListForMBB);
779 mapToLegalUnsigned(It, CanOutlineWithPrevInstr, HaveLegalRange,
780 NumLegalInBlock, UnsignedVecForMBB, InstrListForMBB);
784 mapToLegalUnsigned(It, CanOutlineWithPrevInstr, HaveLegalRange,
785 NumLegalInBlock, UnsignedVecForMBB, InstrListForMBB);
788 mapToIllegalUnsigned(It, CanOutlineWithPrevInstr, UnsignedVecForMBB,
795 AddedIllegalLastTime =
false;
802 if (HaveLegalRange) {
807 mapToIllegalUnsigned(It, CanOutlineWithPrevInstr, UnsignedVecForMBB,
809 InstrList.insert(InstrList.end(), InstrListForMBB.begin(),
810 InstrListForMBB.end());
811 UnsignedVec.insert(UnsignedVec.end(), UnsignedVecForMBB.begin(),
812 UnsignedVecForMBB.end());
816 InstructionMapper() {
820 "DenseMapInfo<unsigned>'s empty key isn't -1!");
822 "DenseMapInfo<unsigned>'s tombstone key isn't -2!");
841 bool OutlineFromLinkOnceODRs =
false;
847 bool RunOnAllFunctions =
true;
849 StringRef getPassName()
const override {
return "Machine Outliner"; }
864 void emitNotOutliningCheaperRemark(
865 unsigned StringLen, std::vector<Candidate> &CandidatesForRepeatedSeq,
866 OutlinedFunction &OF);
869 void emitOutlinedFunctionRemark(OutlinedFunction &OF);
884 void findCandidates(InstructionMapper &Mapper,
885 std::vector<OutlinedFunction> &FunctionList);
893 bool outline(
Module &M, std::vector<OutlinedFunction> &FunctionList,
894 InstructionMapper &Mapper);
898 InstructionMapper &Mapper,
903 bool runOnModule(
Module &M)
override;
907 DISubprogram *getSubprogramOrNull(
const OutlinedFunction &OF) {
909 for (
const Candidate &
C : OF.Candidates)
910 if (C.getMF() && (SP = C.getMF()->getFunction().
getSubprogram()))
917 void populateMapper(InstructionMapper &Mapper,
Module &M,
924 void initSizeRemarkInfo(
930 void emitInstrCountChangedRemark(
940 MachineOutliner *OL =
new MachineOutliner();
941 OL->RunOnAllFunctions = RunOnAllFunctions;
950 void MachineOutliner::emitNotOutliningCheaperRemark(
951 unsigned StringLen,
std::vector<Candidate> &CandidatesForRepeatedSeq,
952 OutlinedFunction &OF) {
957 Candidate &C = CandidatesForRepeatedSeq.front();
961 C.front()->getDebugLoc(), C.getMBB());
962 R <<
"Did not outline " <<
NV(
"Length", StringLen) <<
" instructions" 963 <<
" from " <<
NV(
"NumOccurrences", CandidatesForRepeatedSeq.size())
965 <<
" Bytes from outlining all occurrences (" 966 <<
NV(
"OutliningCost", OF.getOutliningCost()) <<
")" 967 <<
" >= Unoutlined instruction bytes (" 968 <<
NV(
"NotOutliningCost", OF.getNotOutlinedCost()) <<
")" 969 <<
" (Also found at: ";
972 for (
unsigned i = 1, e = CandidatesForRepeatedSeq.size(); i < e; i++) {
974 CandidatesForRepeatedSeq[i].front()->
getDebugLoc());
984 void MachineOutliner::emitOutlinedFunctionRemark(OutlinedFunction &OF) {
989 R <<
"Saved " <<
NV(
"OutliningBenefit", OF.getBenefit()) <<
" bytes by " 990 <<
"outlining " <<
NV(
"Length", OF.getNumInstrs()) <<
" instructions " 991 <<
"from " <<
NV(
"NumOccurrences", OF.getOccurrenceCount())
996 for (
size_t i = 0, e = OF.Candidates.size(); i < e; i++) {
999 OF.Candidates[i].front()->getDebugLoc());
1010 MachineOutliner::findCandidates(InstructionMapper &Mapper,
1011 std::vector<OutlinedFunction> &FunctionList) {
1012 FunctionList.clear();
1013 SuffixTree
ST(Mapper.UnsignedVec);
1017 std::vector<Candidate> CandidatesForRepeatedSeq;
1018 for (
auto It = ST.begin(), Et = ST.end(); It != Et; ++It) {
1019 CandidatesForRepeatedSeq.clear();
1020 SuffixTree::RepeatedSubstring RS = *It;
1021 unsigned StringLen = RS.Length;
1022 for (
const unsigned &StartIdx : RS.StartIndices) {
1023 unsigned EndIdx = StartIdx + StringLen - 1;
1046 CandidatesForRepeatedSeq.begin(), CandidatesForRepeatedSeq.end(),
1047 [&StartIdx, &EndIdx](
const Candidate &
C) {
1048 return (EndIdx < C.getStartIdx() || StartIdx > C.getEndIdx());
1058 CandidatesForRepeatedSeq.emplace_back(StartIdx, StringLen, StartIt,
1059 EndIt, MBB, FunctionList.
size(),
1060 Mapper.MBBFlagsMap[MBB]);
1067 if (CandidatesForRepeatedSeq.size() < 2)
1073 CandidatesForRepeatedSeq[0].getMF()->getSubtarget().getInstrInfo();
1075 OutlinedFunction OF =
1080 if (OF.Candidates.size() < 2)
1084 if (OF.getBenefit() < 1) {
1085 emitNotOutliningCheaperRemark(StringLen, CandidatesForRepeatedSeq, OF);
1089 FunctionList.push_back(OF);
1094 MachineOutliner::createOutlinedFunction(
Module &M, OutlinedFunction &OF,
1095 InstructionMapper &Mapper,
1101 std::ostringstream NameStream;
1104 NameStream <<
"OUTLINED_FUNCTION_" <<
Name;
1110 assert(F &&
"Function was null!");
1129 Candidate &FirstCand = OF.Candidates.front();
1130 const Function &ParentFn = FirstCand.getMF()->getFunction();
1145 MF.insert(MF.begin(), &MBB);
1147 for (
auto I = FirstCand.front(), E = std::next(FirstCand.back());
I !=
E;
1161 MF.getRegInfo().freezeReservedRegs(MF);
1182 DINode::DIFlags::FlagArtificial ,
1184 DISubprogram::SPFlagDefinition | DISubprogram::SPFlagOptimized);
1198 bool MachineOutliner::outline(
Module &M,
1199 std::vector<OutlinedFunction> &FunctionList,
1200 InstructionMapper &Mapper) {
1202 bool OutlinedSomething =
false;
1205 unsigned OutlinedFunctionNum = 0;
1209 FunctionList.begin(), FunctionList.end(),
1210 [](
const OutlinedFunction &LHS,
const OutlinedFunction &RHS) {
1211 return LHS.getBenefit() > RHS.getBenefit();
1216 for (OutlinedFunction &OF : FunctionList) {
1219 erase_if(OF.Candidates, [&Mapper](Candidate &C) {
1221 Mapper.UnsignedVec.begin() + C.getStartIdx(),
1222 Mapper.UnsignedVec.begin() + C.getEndIdx() + 1,
1223 [](unsigned I) { return (I == static_cast<unsigned>(-1)); });
1227 if (OF.getBenefit() < 1)
1232 OF.MF = createOutlinedFunction(M, OF, Mapper, OutlinedFunctionNum);
1233 emitOutlinedFunctionRemark(OF);
1235 OutlinedFunctionNum++;
1241 for (Candidate &C : OF.Candidates) {
1281 MBB.
erase(std::next(StartIt), std::next(EndIt));
1285 Mapper.UnsignedVec.begin() + C.getEndIdx() + 1,
1286 [](
unsigned &
I) {
I =
static_cast<unsigned>(-1); });
1287 OutlinedSomething =
true;
1294 LLVM_DEBUG(
dbgs() <<
"OutlinedSomething = " << OutlinedSomething <<
"\n";);
1296 return OutlinedSomething;
1299 void MachineOutliner::populateMapper(InstructionMapper &Mapper,
Module &M,
1348 Mapper.convertToUnsignedVec(MBB, *TII);
1353 void MachineOutliner::initSizeRemarkInfo(
1369 void MachineOutliner::emitInstrCountChangedRemark(
1383 std::string Fname =
F.getName();
1385 unsigned FnCountBefore = 0;
1388 auto It = FunctionToInstrCount.
find(Fname);
1392 if (It != FunctionToInstrCount.
end())
1393 FnCountBefore = It->second;
1396 int64_t FnDelta = static_cast<int64_t>(FnCountAfter) -
1397 static_cast<int64_t
>(FnCountBefore);
1409 <<
": MI instruction count changed from " 1422 bool MachineOutliner::runOnModule(
Module &M) {
1436 dbgs() <<
"Machine Outliner: Running on ";
1437 if (RunOnAllFunctions)
1438 dbgs() <<
"all functions";
1440 dbgs() <<
"target-default functions";
1447 InstructionMapper Mapper;
1450 populateMapper(Mapper, M, MMI);
1451 std::vector<OutlinedFunction> FunctionList;
1454 findCandidates(Mapper, FunctionList);
1467 if (ShouldEmitSizeRemarks)
1468 initSizeRemarkInfo(M, MMI, FunctionToInstrCount);
1471 bool OutlinedSomething = outline(M, FunctionList, Mapper);
1476 if (ShouldEmitSizeRemarks && OutlinedSomething)
1477 emitInstrCountChangedRemark(M, MMI, FunctionToInstrCount);
1479 return OutlinedSomething;
void finalize()
Construct any deferred debug info descriptors.
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...
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
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.
This class represents lattice values for constants.
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.
iterator find(StringRef Key)
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.
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()
amdgpu Simplify well known AMD library false Value Value const Twine & Name
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...
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...
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.
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.
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 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.
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.
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.
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.
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)
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...
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.
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.