48 #define DEBUG_TYPE "prologepilog"
52 unsigned &MinCSFrameIndex,
53 unsigned &MaxCXFrameIndex,
81 unsigned &MinCSFrameIndex,
unsigned &MaxCSFrameIndex,
84 SpillCalleeSavedRegisters;
85 std::function<void(MachineFunction &MF, RegScavenger &RS)>
86 ScavengeFrameVirtualRegs;
88 bool UsesCalleeSaves =
false;
95 unsigned MaxCSFrameIndex = 0;
105 bool FrameIndexVirtualScavenging;
109 bool FrameIndexEliminationScavenging;
127 cl::desc(
"Warn for stack size bigger than the given"
144 "Number of bytes used for stack in all functions");
162 if (!SpillCalleeSavedRegisters) {
166 unsigned &,
unsigned &,
const MBBVector &,
167 const MBBVector &) {};
172 UsesCalleeSaves =
true;
182 FrameIndexEliminationScavenging = (RS && !FrameIndexVirtualScavenging) ||
188 calculateCallFrameInfo(Fn);
192 calculateSaveRestoreBlocks(Fn);
195 SpillCalleeSavedRegisters(Fn, RS, MinCSFrameIndex, MaxCSFrameIndex,
196 SaveBlocks, RestoreBlocks);
203 calculateFrameObjectOffsets(Fn);
211 insertPrologEpilogCode(Fn);
216 replaceFrameIndices(Fn);
222 ScavengeFrameVirtualRegs(Fn, *RS);
238 RestoreBlocks.clear();
252 unsigned MaxCallFrameSize = 0;
261 if (FrameSetupOpcode == ~0u && FrameDestroyOpcode == ~0u)
264 std::vector<MachineBasicBlock::iterator> FrameSDOps;
269 if (Size > MaxCallFrameSize) MaxCallFrameSize =
Size;
271 FrameSDOps.push_back(
I);
272 }
else if (
I->isInlineAsm()) {
285 for (std::vector<MachineBasicBlock::iterator>::iterator
286 i = FrameSDOps.begin(), e = FrameSDOps.end(); i != e; ++i) {
315 if (!RestoreBlock->succ_empty() || RestoreBlock->isReturnBlock())
321 SaveBlocks.push_back(&Fn.
front());
323 if (MBB.isEHFuncletEntry())
324 SaveBlocks.push_back(&MBB);
325 if (MBB.isReturnBlock())
326 RestoreBlocks.push_back(&MBB);
332 unsigned &MinCSFrameIndex,
333 unsigned &MaxCSFrameIndex) {
334 if (SavedRegs.
empty())
340 std::vector<CalleeSavedInfo> CSI;
341 for (
unsigned i = 0; CSRegs[i]; ++i) {
342 unsigned Reg = CSRegs[i];
343 if (SavedRegs.
test(Reg))
355 unsigned NumFixedSpillSlots;
361 for (
auto &CS : CSI) {
362 unsigned Reg = CS.getReg();
367 CS.setFrameIdx(FrameIdx);
374 while (FixedSlot != FixedSpillSlots + NumFixedSpillSlots &&
375 FixedSlot->
Reg != Reg)
379 if (FixedSlot == FixedSpillSlots + NumFixedSpillSlots) {
387 Align =
std::min(Align, StackAlign);
389 if ((
unsigned)FrameIdx < MinCSFrameIndex) MinCSFrameIndex = FrameIdx;
390 if ((
unsigned)FrameIdx > MaxCSFrameIndex) MaxCSFrameIndex = FrameIdx;
396 CS.setFrameIdx(FrameIdx);
435 while (!WorkList.
empty()) {
439 if (CurBB == Save && Save != Restore)
444 if (Visited.
insert(SuccBB).second)
451 for (
unsigned i = 0, e = CSI.size(); i != e; ++i) {
456 if (!MRI.
isReserved(Reg) && !MBB->isLiveIn(Reg))
485 I = SaveBlock->begin();
487 for (
unsigned i = 0, e = CSI.size(); i != e; ++i) {
489 unsigned Reg = CSI[i].getReg();
506 while (I2 != MBB->begin() && (--I2)->isTerminator())
509 bool AtStart = I == MBB->begin();
517 for (
unsigned i = 0, e = CSI.size(); i != e; ++i) {
518 unsigned Reg = CSI[i].getReg();
521 assert(I != MBB->begin() &&
522 "loadRegFromStackSlot didn't insert any code!");
537 unsigned &MinCSFrameIndex,
538 unsigned &MaxCSFrameIndex,
561 bool StackGrowsDown, int64_t &
Offset,
562 unsigned &MaxAlign,
unsigned Skew) {
571 MaxAlign =
std::max(MaxAlign, Align);
574 Offset =
alignTo(Offset, Align, Skew);
576 if (StackGrowsDown) {
577 DEBUG(
dbgs() <<
"alloc FI(" << FrameIdx <<
") at SP[" << -Offset <<
"]\n");
580 DEBUG(
dbgs() <<
"alloc FI(" << FrameIdx <<
") at SP[" << Offset <<
"]\n");
591 unsigned MinCSFrameIndex,
unsigned MaxCSFrameIndex,
592 int64_t FixedCSEnd,
BitVector &StackBytesFree) {
597 StackBytesFree.
resize(FixedCSEnd,
true);
604 for (
int i = MinCSFrameIndex; i <= (int)MaxCSFrameIndex; ++i)
607 for (
int i : AllocatedFrameSlots) {
612 int ObjStart, ObjEnd;
613 if (StackGrowsDown) {
615 ObjStart = -ObjOffset - ObjSize;
618 ObjStart = ObjOffset;
619 ObjEnd = ObjOffset + ObjSize;
623 StackBytesFree.
reset(ObjStart, ObjEnd);
631 bool StackGrowsDown,
unsigned MaxAlign,
636 if (StackBytesFree.
none()) {
639 StackBytesFree.
clear();
644 if (ObjAlign > MaxAlign)
649 for (FreeStart = StackBytesFree.
find_first(); FreeStart != -1;
650 FreeStart = StackBytesFree.
find_next(FreeStart)) {
653 unsigned ObjStart = StackGrowsDown ? FreeStart + ObjSize : FreeStart;
654 if (
alignTo(ObjStart, ObjAlign) != ObjStart)
657 if (FreeStart + ObjSize > StackBytesFree.
size())
660 bool AllBytesFree =
true;
661 for (
unsigned Byte = 0; Byte < ObjSize; ++Byte)
662 if (!StackBytesFree.
test(FreeStart + Byte)) {
663 AllBytesFree =
false;
673 if (StackGrowsDown) {
674 int ObjStart = -(FreeStart + ObjSize);
675 DEBUG(
dbgs() <<
"alloc FI(" << FrameIdx <<
") scavenged at SP[" << ObjStart
679 DEBUG(
dbgs() <<
"alloc FI(" << FrameIdx <<
") scavenged at SP[" << FreeStart
684 StackBytesFree.
reset(FreeStart, FreeStart + ObjSize);
694 int64_t &
Offset,
unsigned &MaxAlign,
unsigned Skew) {
697 E = UnassignedObjs.
end();
I !=
E; ++
I) {
711 bool StackGrowsDown =
722 LocalAreaOffset = -LocalAreaOffset;
723 assert(LocalAreaOffset >= 0
724 &&
"Local area offset should be in direction of stack growth");
725 int64_t
Offset = LocalAreaOffset;
736 if (StackGrowsDown) {
746 if (FixedOff > Offset) Offset = FixedOff;
751 if (StackGrowsDown) {
752 for (
unsigned i = MinCSFrameIndex; i <= MaxCSFrameIndex; ++i) {
759 Offset =
alignTo(Offset, Align, Skew);
761 DEBUG(
dbgs() <<
"alloc FI(" << i <<
") at SP[" << -Offset <<
"]\n");
764 }
else if (MaxCSFrameIndex >= MinCSFrameIndex) {
766 for (
unsigned i = MaxCSFrameIndex; i != MinCSFrameIndex - 1; --i) {
772 Offset =
alignTo(Offset, Align, Skew);
774 DEBUG(
dbgs() <<
"alloc FI(" << i <<
") at SP[" << Offset <<
"]\n");
782 int64_t FixedCSEnd =
Offset;
789 bool EarlyScavengingSlots = (TFI.
hasFP(Fn) &&
793 if (RS && EarlyScavengingSlots) {
795 RS->getScavengingFrameIndices(SFIs);
809 Offset =
alignTo(Offset, Align, Skew);
811 DEBUG(
dbgs() <<
"Local frame base offset: " << Offset <<
"\n");
816 int64_t FIOffset = (StackGrowsDown ? -Offset :
Offset) + Entry.second;
817 DEBUG(
dbgs() <<
"alloc FI(" << Entry.first <<
") at SP[" <<
824 MaxAlign =
std::max(Align, MaxAlign);
828 int EHRegNodeFrameIndex = INT_MAX;
830 EHRegNodeFrameIndex = FuncInfo->EHRegNodeFrameIndex;
848 if (i >= MinCSFrameIndex && i <= MaxCSFrameIndex)
850 if (RS && RS->isScavengingFrameIndex((
int)i))
855 EHRegNodeFrameIndex == (
int)i)
875 Offset, MaxAlign, Skew);
877 Offset, MaxAlign, Skew);
879 Offset, MaxAlign, Skew);
889 if (i >= MinCSFrameIndex && i <= MaxCSFrameIndex)
891 if (RS && RS->isScavengingFrameIndex((
int)i))
896 EHRegNodeFrameIndex == (
int)i)
898 if (ProtectedObjs.count(i))
906 if (EHRegNodeFrameIndex != INT_MAX)
920 if (!ObjectsToAllocate.
empty() &&
924 FixedCSEnd, StackBytesFree);
927 for (
auto &Object : ObjectsToAllocate)
934 if (RS && !EarlyScavengingSlots) {
936 RS->getScavengingFrameIndices(SFIs);
963 StackAlign =
std::max(StackAlign, MaxAlign);
964 Offset =
alignTo(Offset, StackAlign, Skew);
968 int64_t StackSize = Offset - LocalAreaOffset;
970 NumBytesStackSpace += StackSize;
1024 DFI != DFE; ++DFI) {
1027 if (DFI.getPathLength() >= 2) {
1030 "DFS stack predecessor is already visited.\n");
1031 SPAdj = SPState[StackPred->
getNumber()];
1034 replaceFrameIndices(BB, Fn, SPAdj);
1039 for (
auto &BB : Fn) {
1040 if (Reachable.
count(&BB))
1044 replaceFrameIndices(&BB, Fn, SPAdj);
1051 "getRegisterInfo() must be implemented!");
1056 if (RS && FrameIndexEliminationScavenging)
1057 RS->enterBasicBlock(*BB);
1059 bool InsideCallSequence =
false;
1063 if (TII.isFrameInstr(*
I)) {
1064 InsideCallSequence = TII.isFrameSetup(*
I);
1065 SPAdj += TII.getSPAdjust(*
I);
1072 bool DidFinishLoop =
true;
1081 assert(i == 0 &&
"Frame indices can only appear as the first "
1082 "operand of a DBG_VALUE machine instruction");
1097 if (MI.
getOpcode() == TargetOpcode::STATEPOINT) {
1099 "Frame indicies can only appear as the first operand of a "
1100 "DBG_VALUE machine instruction");
1117 bool AtBeginning = (
I == BB->
begin());
1118 if (!AtBeginning) --
I;
1124 FrameIndexEliminationScavenging ? RS :
nullptr);
1132 DidFinishLoop =
false;
1143 if (DidFinishLoop && InsideCallSequence)
1144 SPAdj += TII.getSPAdjust(MI);
1146 if (DoIncr &&
I != BB->
end()) ++
I;
1149 if (RS && FrameIndexEliminationScavenging && DidFinishLoop)
unsigned StackSymbolOrdering
StackSymbolOrdering - When true, this will allow CodeGen to order the local stack symbols (for code s...
void resize(unsigned N, bool t=false)
resize - Grow or shrink the bitvector.
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
void push_back(const T &Elt)
virtual void orderFrameObjects(const MachineFunction &MF, SmallVectorImpl< int > &objectsToAllocate) const
Order the symbols in the local stack frame.
virtual bool hasReservedSpillSlot(const MachineFunction &MF, unsigned Reg, int &FrameIdx) const
Return true if target has reserved a spill slot in the stack frame of the given function for the spec...
void setSavePoint(MachineBasicBlock *NewSave)
int find_first() const
find_first - Returns the index of the first set bit, -1 if none of the bits are set.
void setRestorePoint(MachineBasicBlock *NewRestore)
bool isFrameInstr(const MachineInstr &I) const
Returns true if the argument is a frame pseudo instruction.
size_type size() const
size - Returns the number of bits in this bitvector.
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
static void AdjustStackOffset(MachineFrameInfo &MFI, int FrameIdx, bool StackGrowsDown, int64_t &Offset, unsigned &MaxAlign, unsigned Skew)
AdjustStackOffset - Helper function used to adjust the stack frame offset.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
void setCalleeSavedInfoValid(bool v)
STATISTIC(NumFunctions,"Total number of functions")
bool none() const
none - Returns true if none of the bits are set.
static void computeFreeStackSlots(MachineFrameInfo &MFI, bool StackGrowsDown, unsigned MinCSFrameIndex, unsigned MaxCSFrameIndex, int64_t FixedCSEnd, BitVector &StackBytesFree)
Compute which bytes of fixed and callee-save stack area are unused and keep track of them in StackByt...
void ChangeToRegister(unsigned Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isDebug=false)
ChangeToRegister - Replace this operand with a new register operand of the specified value...
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
Maximum length of the test input libFuzzer tries to guess a good value based on the corpus and reports it always prefer smaller inputs during the corpus shuffle When libFuzzer itself reports a bug this exit code will be used If indicates the maximal total time in seconds to run the fuzzer minimizes the provided crash input Use with tries to cleanse the provided crash input to make it contain fewer original bytes Use with exact_artifact_path to specify the output Experimental Use value profile to guide fuzzing Number of jobs to run If min(jobs, NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload
static void updateLiveness(MachineFunction &MF)
Helper function to update the liveness information for the callee-saved registers.
MachineBasicBlock * getRestorePoint() const
int find_next(unsigned Prev) const
find_next - Returns the index of the next set bit following the "Prev" bit.
virtual bool usesPhysRegsForPEI() const
True if the target uses physical regs at Prolog/Epilog insertion time.
unsigned getSpillAlignment(const TargetRegisterClass &RC) const
Return the minimum required alignment for a spill slot for a register of this class.
virtual void adjustForHiPEPrologue(MachineFunction &MF, MachineBasicBlock &PrologueMBB) const
Adjust the prologue to add Erlang Run-Time System (ERTS) specific code in the assembly prologue to ex...
virtual unsigned getStackAlignmentSkew(const MachineFunction &MF) const
Return the skew that has to be applied to stack alignment under certain conditions (e...
bool adjustsStack() const
Return true if this function adjusts the stack – e.g., when calling another function.
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew=0)
Returns the next integer (mod 2**64) that is greater than or equal to Value and is a multiple of Alig...
SmallVector< MachineBasicBlock *, 4 > MBBVector
virtual bool requiresFrameIndexScavenging(const MachineFunction &MF) const
Returns true if the target requires post PEI scavenging of registers for materializing frame index co...
virtual const SpillSlot * getCalleeSavedSpillSlots(unsigned &NumEntries) const
getCalleeSavedSpillSlots - This method returns a pointer to an array of pairs, that contains an entry...
iterator end()
Get an iterator to the end of the SetVector.
bool isObjectPreAllocated(int ObjectIdx) const
Return true if the object was pre-allocated into the local block.
void clearVirtRegs()
clearVirtRegs - Remove all virtual registers (after physreg assignment).
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
iterator_range< succ_iterator > successors()
unsigned getMaxAlignment() const
Return the alignment in bytes that this function must be aligned to, which is greater than the defaul...
Prologue Epilogue Insertion &Frame false
const std::vector< CalleeSavedInfo > & getCalleeSavedInfo() const
Returns a reference to call saved info vector for the current function.
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects...
virtual bool targetHandlesStackFrameRounding() const
targetHandlesStackFrameRounding - Returns true if the target is responsible for rounding up the stack...
int64_t getLocalFrameSize() const
Get the size of the local object blob.
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
virtual void inlineStackProbe(MachineFunction &MF, MachineBasicBlock &PrologueMBB) const
Replace a StackProbe stub (if any) with the actual probe code inline.
unsigned getCallFrameDestroyOpcode() const
Did not trigger a stack protector.
void clear()
clear - Removes all bits from the bitvector. Does not change capacity.
unsigned getNumBlockIDs() const
getNumBlockIDs - Return the number of MBB ID's allocated.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
virtual void processFunctionBeforeFrameFinalized(MachineFunction &MF, RegScavenger *RS=nullptr) const
processFunctionBeforeFrameFinalized - This method is called immediately before the specified function...
INITIALIZE_PASS_BEGIN(PEI, DEBUG_TYPE,"Prologue/Epilogue Insertion", false, false) INITIALIZE_PASS_END(PEI
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const HexagonInstrInfo * TII
virtual bool hasFP(const MachineFunction &MF) const =0
hasFP - Return true if the specified function should have a dedicated frame pointer register...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Reg
All possible values of the reg field in the ModR/M byte.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
The address of this allocation is exposed and triggered protection.
MachineFunctionPass * createPrologEpilogInserterPass()
virtual bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const std::vector< CalleeSavedInfo > &CSI, const TargetRegisterInfo *TRI) const
restoreCalleeSavedRegisters - Issues instruction(s) to restore all callee saved registers and returns...
int CreateFixedSpillStackObject(uint64_t Size, int64_t SPOffset, bool Immutable=false)
Create a spill slot at a fixed location on the stack.
LLVM_NODISCARD bool empty() const
unsigned getNumOperands() const
Access to explicit operands of the instruction.
void scavengeFrameVirtualRegs(MachineFunction &MF, RegScavenger &RS)
Replaces all frame index virtual registers with physical registers.
const MachineBasicBlock & front() const
bool isVariableSizedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a variable sized object.
int getObjectIndexBegin() const
Return the minimum frame object index.
bool insert(const value_type &X)
Insert a new element into the SetVector.
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
unsigned getCallFrameSetupOpcode() const
These methods return the opcode of the frame setup/destroy instructions if they exist (-1 otherwise)...
virtual bool needsFrameIndexResolution(const MachineFunction &MF) const
virtual int getFrameIndexReferencePreferSP(const MachineFunction &MF, int FI, unsigned &FrameReg, bool IgnoreSPUpdates) const
Same as getFrameIndexReference, except that the stack pointer (as opposed to the frame pointer) will ...
unsigned getLocalFrameMaxAlign() const
Return the required alignment of the local object blob.
iterator begin()
Get an iterator to the beginning of the SetVector.
virtual bool enableStackSlotScavenging(const MachineFunction &MF) const
Returns true if the stack slot holes in the fixed and callee-save stack area should be used when allo...
virtual void eliminateFrameIndex(MachineBasicBlock::iterator MI, int SPAdj, unsigned FIOperandNum, RegScavenger *RS=nullptr) const =0
This method must be overriden to eliminate abstract frame indices from instructions which may use the...
virtual bool useFPForScavengingIndex(const MachineFunction &MF) const
Returns true if the target wants to use frame pointer based accesses to spill to the scavenger emerge...
CodeGenOpt::Level getOptLevel() const
Returns the optimization level: None, Less, Default, or Aggressive.
static cl::opt< unsigned > WarnStackSize("warn-stack-size", cl::Hidden, cl::init((unsigned)-1), cl::desc("Warn for stack size bigger than the given"" number"))
virtual MachineBasicBlock::iterator eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const
This method is called during prolog/epilog code insertion to eliminate call frame setup and destroy p...
virtual int getFrameIndexReference(const MachineFunction &MF, int FI, unsigned &FrameReg) const
getFrameIndexReference - This method should return the base register and offset used to reference a f...
unsigned getTransientStackAlignment() const
getTransientStackAlignment - This method returns the number of bytes to which the stack pointer must ...
int64_t getLocalFrameObjectCount() const
Return the number of objects allocated into the local object block.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
virtual bool requiresRegisterScavenging(const MachineFunction &MF) const
Returns true if the target requires (and can make use of) the register scavenger. ...
TargetInstrInfo - Interface to description of machine instruction set.
std::pair< int, int64_t > getLocalFrameObjectMap(int i) const
Get the local offset mapping for a for an object.
bool isDebugValue() const
virtual void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const =0
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
const MCPhysReg * getCalleeSavedRegs() const
Returns list of callee saved registers.
initializer< Ty > init(const Ty &Val)
This file declares the machine register scavenger class.
bool getUseLocalStackAllocationBlock() const
Get whether the local allocation blob should be allocated together or let PEI allocate the locals in ...
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
unsigned const MachineRegisterInfo * MRI
void initializePEIPass(PassRegistry &)
virtual bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const std::vector< CalleeSavedInfo > &CSI, const TargetRegisterInfo *TRI) const
spillCalleeSavedRegisters - Issues instruction(s) to spill all callee saved registers and returns tru...
df_ext_iterator< T, SetTy > df_ext_end(const T &G, SetTy &S)
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
bool isReserved(unsigned PhysReg) const
isReserved - Returns true when PhysReg is a reserved register.
void setStackSize(uint64_t Size)
Set the size of the stack.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
const MachineOperand & getOperand(unsigned i) const
bool empty() const
empty - Tests whether there are no bits in this bitvector.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
virtual void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned DestReg, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const
Load the specified register of the given register class from the specified stack frame index...
SmallSetVector< int, 8 > StackObjSet
StackObjSet - A set of stack object indexes.
Represent the analysis usage information of a pass.
df_ext_iterator< T, SetTy > df_ext_begin(const T &G, SetTy &S)
bool shouldSplitStack() const
Should we be emitting segmented stack stuff for the function.
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE,"Assign register bank of generic virtual registers", false, false) RegBankSelect
void setImm(int64_t immVal)
static bool scavengeStackSlot(MachineFrameInfo &MFI, int FrameIdx, bool StackGrowsDown, unsigned MaxAlign, BitVector &StackBytesFree)
Assign frame object to an unused portion of the stack in the fixed stack object range.
SSPLayoutKind getSSPLayout(const AllocaInst *AI) const
static void assignCalleeSavedSpillSlots(MachineFunction &F, const BitVector &SavedRegs, unsigned &MinCSFrameIndex, unsigned &MaxCSFrameIndex)
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
static void insertCSRSpillsAndRestores(MachineFunction &Fn, const MBBVector &SaveBlocks, const MBBVector &RestoreBlocks)
insertCSRSpillsAndRestores - Insert spill and restore code for callee saved registers used in the fun...
virtual void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const
Store the specified register of the given register class to the specified stack frame index...
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
typename vector_type::const_iterator const_iterator
virtual bool hasReservedCallFrame(const MachineFunction &MF) const
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required, we reserve argument space for call sites in the function immediately on entry to the current function.
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
bool isDeadObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a dead object.
virtual void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS=nullptr) const
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
virtual const TargetFrameLowering * getFrameLowering() const
int64_t getFrameSize(const MachineInstr &I) const
Returns size of the frame associated with the given frame instruction.
A SetVector that performs no allocations if smaller than a certain size.
static void doSpillCalleeSavedRegs(MachineFunction &MF, RegScavenger *RS, unsigned &MinCSFrameIndex, unsigned &MaxCXFrameIndex, const MBBVector &SaveBlocks, const MBBVector &RestoreBlocks)
Iterator for intrusive lists based on ilist_node.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
bool isMaxCallFrameSizeComputed() const
virtual bool requiresFrameIndexReplacementScavenging(const MachineFunction &MF) const
Returns true if the target requires using the RegScavenger directly for frame elimination despite usi...
virtual void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const =0
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
unsigned getObjectAlignment(int ObjectIdx) const
Return the alignment of the specified stack object.
bool test(unsigned Idx) const
int getOffsetOfLocalArea() const
getOffsetOfLocalArea - This method returns the offset of the local area from the stack pointer on ent...
Prologue Epilogue Insertion &Frame Finalization
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
unsigned getMaxCallFrameSize() const
Return the maximum size of a call frame that must be allocated for an outgoing function call...
Information about stack frame layout on the target.
LLVM_NODISCARD T pop_back_val()
virtual bool canSimplifyCallFramePseudos(const MachineFunction &MF) const
canSimplifyCallFramePseudos - When possible, it's best to simplify the call frame pseudo ops before d...
void setPreservesCFG()
This function should be called by the pass, iff they do not:
void setAdjustsStack(bool V)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
The CalleeSavedInfo class tracks the information need to locate where a callee saved register is in t...
const TargetRegisterClass * getMinimalPhysRegClass(unsigned Reg, MVT VT=MVT::Other) const
Returns the Register Class of a physical register of the given type, picking the most sub register cl...
int getStackProtectorIndex() const
Return the index for the stack protector object.
char & PrologEpilogCodeInserterID
PrologEpilogCodeInserter - This pass inserts prolog and epilog code, and eliminates abstract frame re...
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
llvm_unreachable("Unknown RegBank!")
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
MachineFunctionProperties & set(Property P)
MachineBasicBlock * getSavePoint() const
Representation of each machine instruction.
void setCalleeSavedInfo(const std::vector< CalleeSavedInfo > &CSI)
Used by prolog/epilog inserter to set the function's callee saved information.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
StackDirection getStackGrowthDirection() const
getStackGrowthDirection - Return the direction the stack grows
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
void push_back(MachineInstr *MI)
virtual void adjustForSegmentedStacks(MachineFunction &MF, MachineBasicBlock &PrologueMBB) const
Adjust the prologue to have the function use segmented stacks.
void setMaxCallFrameSize(unsigned S)
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
const WinEHFuncInfo * getWinEHFuncInfo() const
getWinEHFuncInfo - Return information about how the current function uses Windows exception handling...
void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSS, const AllocaInst *Alloca=nullptr)
Create a new statically sized stack object, returning a nonnegative identifier to represent it...
virtual bool assignCalleeSavedSpillSlots(MachineFunction &MF, const TargetRegisterInfo *TRI, std::vector< CalleeSavedInfo > &CSI) const
assignCalleeSavedSpillSlots - Allows target to override spill slot assignment logic.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
virtual const TargetInstrInfo * getInstrInfo() const
Primary interface to the complete machine description for the target machine.
print Print MemDeps of function
void setObjectOffset(int ObjectIdx, int64_t SPOffset)
Set the stack frame offset of the specified object.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
bool needsStackRealignment(const MachineFunction &MF) const
True if storage within the function requires the stack pointer to be aligned more than the normal cal...
int getObjectIndexEnd() const
Return one past the maximum frame object index.
unsigned getSpillSize(const TargetRegisterClass &RC) const
Return the size in bytes of the stack slot allocated to hold a spilled copy of a register from class ...
const AllocaInst * getObjectAllocation(int ObjectIdx) const
Return the underlying Alloca of the specified stack object if it exists.
static void AssignProtectedObjSet(const StackObjSet &UnassignedObjs, SmallSet< int, 16 > &ProtectedObjs, MachineFrameInfo &MFI, bool StackGrowsDown, int64_t &Offset, unsigned &MaxAlign, unsigned Skew)
AssignProtectedObjSet - Helper function to assign large stack objects (i.e., those required to be clo...
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
Array or nested array >= SSP-buffer-size.
Properties which a MachineFunction may have at a given point in time.
Array or nested array < SSP-buffer-size.
virtual bool isFPCloseToIncomingSP() const
isFPCloseToIncomingSP - Return true if the frame pointer is close to the incoming stack pointer...