74 #define DEBUG_TYPE "prologepilog" 78 STATISTIC(NumLeafFuncWithSpills,
"Number of leaf functions with CSRs");
79 STATISTIC(NumFuncSeen,
"Number of functions seen in PEI");
104 unsigned MaxCSFrameIndex = 0;
114 bool FrameIndexVirtualScavenging;
118 bool FrameIndexEliminationScavenging;
142 cl::desc(
"Warn for stack size bigger than the given" 159 "Number of bytes used for stack in all functions");
182 FrameIndexEliminationScavenging = (RS && !FrameIndexVirtualScavenging) ||
184 ORE = &getAnalysis<MachineOptimizationRemarkEmitterPass>().getORE();
189 calculateCallFrameInfo(MF);
193 calculateSaveRestoreBlocks(MF);
197 spillCalleeSavedRegs(MF);
204 calculateFrameObjectOffsets(MF);
212 insertPrologEpilogCode(MF);
217 replaceFrameIndices(MF);
236 <<
ore::NV(
"NumStackBytes", StackSize) <<
" stack bytes in function";
241 RestoreBlocks.clear();
255 unsigned MaxCallFrameSize = 0;
264 if (FrameSetupOpcode == ~0u && FrameDestroyOpcode == ~0u)
267 std::vector<MachineBasicBlock::iterator> FrameSDOps;
272 if (Size > MaxCallFrameSize) MaxCallFrameSize =
Size;
274 FrameSDOps.push_back(
I);
275 }
else if (
I->isInlineAsm()) {
288 for (std::vector<MachineBasicBlock::iterator>::iterator
289 i = FrameSDOps.begin(), e = FrameSDOps.end(); i != e; ++i) {
318 if (!RestoreBlock->succ_empty() || RestoreBlock->isReturnBlock())
324 SaveBlocks.push_back(&MF.
front());
326 if (MBB.isEHFuncletEntry())
327 SaveBlocks.push_back(&MBB);
328 if (MBB.isReturnBlock())
329 RestoreBlocks.push_back(&MBB);
335 unsigned &MinCSFrameIndex,
336 unsigned &MaxCSFrameIndex) {
337 if (SavedRegs.
empty())
343 std::vector<CalleeSavedInfo> CSI;
344 for (
unsigned i = 0; CSRegs[i]; ++i) {
345 unsigned Reg = CSRegs[i];
346 if (SavedRegs.
test(Reg))
358 unsigned NumFixedSpillSlots;
364 for (
auto &CS : CSI) {
367 if (CS.isSpilledToReg())
370 unsigned Reg = CS.getReg();
375 CS.setFrameIdx(FrameIdx);
382 while (FixedSlot != FixedSpillSlots + NumFixedSpillSlots &&
383 FixedSlot->
Reg != Reg)
387 if (FixedSlot == FixedSpillSlots + NumFixedSpillSlots) {
395 Align = std::min(Align, StackAlign);
397 if ((
unsigned)FrameIdx < MinCSFrameIndex) MinCSFrameIndex = FrameIdx;
398 if ((
unsigned)FrameIdx > MaxCSFrameIndex) MaxCSFrameIndex = FrameIdx;
404 CS.setFrameIdx(FrameIdx);
443 while (!WorkList.
empty()) {
447 if (CurBB == Save && Save != Restore)
452 if (Visited.
insert(SuccBB).second)
459 for (
unsigned i = 0, e = CSI.size(); i != e; ++i) {
464 if (!MRI.
isReserved(Reg) && !MBB->isLiveIn(Reg))
472 if (CSI[i].isSpilledToReg()) {
474 if (Visited.count(&MBB))
477 if (!MBB.isLiveIn(DstReg))
478 MBB.addLiveIn(DstReg);
497 unsigned Reg = CS.getReg();
507 std::vector<CalleeSavedInfo> &CSI) {
519 unsigned Reg = CI.getReg();
523 "loadRegFromStackSlot didn't insert any code!");
559 NumLeafFuncWithSpills++;
576 bool StackGrowsDown, int64_t &
Offset,
577 unsigned &MaxAlign,
unsigned Skew) {
586 MaxAlign =
std::max(MaxAlign, Align);
589 Offset =
alignTo(Offset, Align, Skew);
591 if (StackGrowsDown) {
592 LLVM_DEBUG(
dbgs() <<
"alloc FI(" << FrameIdx <<
") at SP[" << -Offset
596 LLVM_DEBUG(
dbgs() <<
"alloc FI(" << FrameIdx <<
") at SP[" << Offset
607 unsigned MinCSFrameIndex,
unsigned MaxCSFrameIndex,
608 int64_t FixedCSEnd,
BitVector &StackBytesFree) {
613 StackBytesFree.
resize(FixedCSEnd,
true);
620 for (
int i = MinCSFrameIndex; i <= (int)MaxCSFrameIndex; ++i)
623 for (
int i : AllocatedFrameSlots) {
628 int ObjStart, ObjEnd;
629 if (StackGrowsDown) {
631 ObjStart = -ObjOffset - ObjSize;
634 ObjStart = ObjOffset;
635 ObjEnd = ObjOffset + ObjSize;
639 StackBytesFree.
reset(ObjStart, ObjEnd);
646 bool StackGrowsDown,
unsigned MaxAlign,
651 if (StackBytesFree.
none()) {
654 StackBytesFree.
clear();
659 if (ObjAlign > MaxAlign)
664 for (FreeStart = StackBytesFree.
find_first(); FreeStart != -1;
665 FreeStart = StackBytesFree.
find_next(FreeStart)) {
668 unsigned ObjStart = StackGrowsDown ? FreeStart + ObjSize : FreeStart;
669 if (
alignTo(ObjStart, ObjAlign) != ObjStart)
672 if (FreeStart + ObjSize > StackBytesFree.
size())
675 bool AllBytesFree =
true;
676 for (
unsigned Byte = 0; Byte < ObjSize; ++Byte)
677 if (!StackBytesFree.
test(FreeStart + Byte)) {
678 AllBytesFree =
false;
688 if (StackGrowsDown) {
689 int ObjStart = -(FreeStart + ObjSize);
690 LLVM_DEBUG(
dbgs() <<
"alloc FI(" << FrameIdx <<
") scavenged at SP[" 691 << ObjStart <<
"]\n");
694 LLVM_DEBUG(
dbgs() <<
"alloc FI(" << FrameIdx <<
") scavenged at SP[" 695 << FreeStart <<
"]\n");
699 StackBytesFree.
reset(FreeStart, FreeStart + ObjSize);
709 int64_t &
Offset,
unsigned &MaxAlign,
unsigned Skew) {
712 E = UnassignedObjs.
end();
I !=
E; ++
I) {
724 bool StackGrowsDown =
735 LocalAreaOffset = -LocalAreaOffset;
736 assert(LocalAreaOffset >= 0
737 &&
"Local area offset should be in direction of stack growth");
738 int64_t
Offset = LocalAreaOffset;
749 if (StackGrowsDown) {
759 if (FixedOff > Offset) Offset = FixedOff;
764 if (StackGrowsDown) {
765 for (
unsigned i = MinCSFrameIndex; i <= MaxCSFrameIndex; ++i) {
772 Offset =
alignTo(Offset, Align, Skew);
774 LLVM_DEBUG(
dbgs() <<
"alloc FI(" << i <<
") at SP[" << -Offset <<
"]\n");
777 }
else if (MaxCSFrameIndex >= MinCSFrameIndex) {
779 for (
unsigned i = MaxCSFrameIndex; i != MinCSFrameIndex - 1; --i) {
785 Offset =
alignTo(Offset, Align, Skew);
787 LLVM_DEBUG(
dbgs() <<
"alloc FI(" << i <<
") at SP[" << Offset <<
"]\n");
795 int64_t FixedCSEnd =
Offset;
802 bool EarlyScavengingSlots = (TFI.
hasFP(MF) &&
806 if (RS && EarlyScavengingSlots) {
808 RS->getScavengingFrameIndices(SFIs);
822 Offset =
alignTo(Offset, Align, Skew);
824 LLVM_DEBUG(
dbgs() <<
"Local frame base offset: " << Offset <<
"\n");
829 int64_t FIOffset = (StackGrowsDown ? -
Offset :
Offset) + Entry.second;
830 LLVM_DEBUG(
dbgs() <<
"alloc FI(" << Entry.first <<
") at SP[" << FIOffset
837 MaxAlign =
std::max(Align, MaxAlign);
843 EHRegNodeFrameIndex = FuncInfo->EHRegNodeFrameIndex;
861 if (i >= MinCSFrameIndex && i <= MaxCSFrameIndex)
863 if (RS && RS->isScavengingFrameIndex((
int)i))
868 EHRegNodeFrameIndex == (
int)i)
888 Offset, MaxAlign, Skew);
890 Offset, MaxAlign, Skew);
892 Offset, MaxAlign, Skew);
902 if (i >= MinCSFrameIndex && i <= MaxCSFrameIndex)
904 if (RS && RS->isScavengingFrameIndex((
int)i))
909 EHRegNodeFrameIndex == (
int)i)
911 if (ProtectedObjs.count(i))
933 if (!ObjectsToAllocate.
empty() &&
937 FixedCSEnd, StackBytesFree);
940 for (
auto &Object : ObjectsToAllocate)
947 if (RS && !EarlyScavengingSlots) {
949 RS->getScavengingFrameIndices(SFIs);
976 StackAlign =
std::max(StackAlign, MaxAlign);
977 Offset =
alignTo(Offset, StackAlign, Skew);
981 int64_t StackSize = Offset - LocalAreaOffset;
983 NumBytesStackSpace += StackSize;
1039 DFI != DFE; ++DFI) {
1042 if (DFI.getPathLength() >= 2) {
1045 "DFS stack predecessor is already visited.\n");
1046 SPAdj = SPState[StackPred->
getNumber()];
1049 replaceFrameIndices(BB, MF, SPAdj);
1054 for (
auto &BB : MF) {
1055 if (Reachable.
count(&BB))
1059 replaceFrameIndices(&BB, MF, SPAdj);
1066 "getRegisterInfo() must be implemented!");
1071 if (RS && FrameIndexEliminationScavenging)
1072 RS->enterBasicBlock(*BB);
1074 bool InsideCallSequence =
false;
1077 if (TII.isFrameInstr(*
I)) {
1078 InsideCallSequence = TII.isFrameSetup(*
I);
1079 SPAdj += TII.getSPAdjust(*
I);
1086 bool DidFinishLoop =
true;
1095 assert(i == 0 &&
"Frame indices can only appear as the first " 1096 "operand of a DBG_VALUE machine instruction");
1113 if (MI.
getOpcode() == TargetOpcode::STATEPOINT) {
1115 "Frame indicies can only appear as the first operand of a " 1116 "DBG_VALUE machine instruction");
1133 bool AtBeginning = (
I == BB->
begin());
1134 if (!AtBeginning) --
I;
1140 FrameIndexEliminationScavenging ? RS :
nullptr);
1148 DidFinishLoop =
false;
1159 if (DidFinishLoop && InsideCallSequence)
1160 SPAdj += TII.getSPAdjust(MI);
1162 if (DoIncr &&
I != BB->
end()) ++
I;
1165 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.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
void setSavePoint(MachineBasicBlock *NewSave)
void setRestorePoint(MachineBasicBlock *NewRestore)
virtual bool requiresRegisterScavenging(const MachineFunction &MF) const
Returns true if the target requires (and can make use of) the register scavenger. ...
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...
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
void setCalleeSavedInfoValid(bool v)
This class represents lattice values for constants.
bool empty() const
empty - Tests whether there are no bits in this bitvector.
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...
Did not trigger a stack protector.
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...
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...
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
unsigned getNumBlockIDs() const
getNumBlockIDs - Return the number of MBB ID's allocated.
static void updateLiveness(MachineFunction &MF)
Helper function to update the liveness information for the callee-saved registers.
const MachineFunctionProperties & getProperties() const
Get the function properties.
bool isDeadObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a dead object.
void push_back(const T &Elt)
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...
static void insertCSRSaves(MachineBasicBlock &SaveBlock, ArrayRef< CalleeSavedInfo > CSI)
Insert restore code for the callee-saved registers used in the function.
iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
virtual bool canSimplifyCallFramePseudos(const MachineFunction &MF) const
canSimplifyCallFramePseudos - When possible, it's best to simplify the call frame pseudo ops before d...
int64_t getLocalFrameSize() const
Get the size of the local object blob.
bool test(unsigned Idx) const
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
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...
STATISTIC(NumFunctions, "Total number of functions")
unsigned const TargetRegisterInfo * TRI
bool adjustsStack() const
Return true if this function adjusts the stack – e.g., when calling another function.
MachineModuleInfo & getMMI() const
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...
unsigned getCallFrameDestroyOpcode() const
int getOffsetOfLocalArea() const
getOffsetOfLocalArea - This method returns the offset of the local area from the stack pointer on ent...
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 ...
iterator end()
Get an iterator to the end of the SetVector.
int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSpillSlot, const AllocaInst *Alloca=nullptr, uint8_t ID=0)
Create a new statically sized stack object, returning a nonnegative identifier to represent it...
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 ...
static DIExpression * prepend(const DIExpression *Expr, bool DerefBefore, int64_t Offset=0, bool DerefAfter=false, bool StackValue=false)
Prepend DIExpr with a deref and offset operation and optionally turn it into a stack value...
iterator_range< succ_iterator > successors()
virtual void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS=nullptr) const
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
virtual void processFunctionBeforeFrameFinalized(MachineFunction &MF, RegScavenger *RS=nullptr) const
processFunctionBeforeFrameFinalized - This method is called immediately before the specified function...
bool isVariableSizedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a variable sized object.
unsigned getSpillAlignment(const TargetRegisterClass &RC) const
Return the minimum required alignment in bytes for a spill slot for a register of this class...
virtual const SpillSlot * getCalleeSavedSpillSlots(unsigned &NumEntries) const
getCalleeSavedSpillSlots - This method returns a pointer to an array of pairs, that contains an entry...
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
void clear()
clear - Removes all bits from the bitvector. Does not change capacity.
std::pair< int, int64_t > getLocalFrameObjectMap(int i) const
Get the local offset mapping for a for an object.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const HexagonInstrInfo * TII
virtual bool usesPhysRegsForPEI() const
True if the target uses physical regs at Prolog/Epilog insertion time.
unsigned getNumOperands() const
Retuns the total number of operands.
MachineBasicBlock * getRestorePoint() const
int find_first() const
find_first - Returns the index of the first set bit, -1 if none of the bits are set.
virtual bool hasFP(const MachineFunction &MF) const =0
hasFP - Return true if the specified function should have a dedicated frame pointer register...
virtual bool assignCalleeSavedSpillSlots(MachineFunction &MF, const TargetRegisterInfo *TRI, std::vector< CalleeSavedInfo > &CSI) const
assignCalleeSavedSpillSlots - Allows target to override spill slot assignment logic.
The address of this allocation is exposed and triggered protection.
virtual bool requiresFrameIndexScavenging(const MachineFunction &MF) const
Returns true if the target requires post PEI scavenging of registers for materializing frame index co...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
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"))
int find_next(unsigned Prev) const
find_next - Returns the index of the next set bit following the "Prev" bit.
This file contains the simple types necessary to represent the attributes associated with functions a...
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
MachineFunctionPass * createPrologEpilogInserterPass()
virtual unsigned getStackAlignmentSkew(const MachineFunction &MF) const
Return the skew that has to be applied to stack alignment under certain conditions (e...
void scavengeFrameVirtualRegs(MachineFunction &MF, RegScavenger &RS)
Replaces all frame index virtual registers with physical registers.
auto reverse(ContainerTy &&C, typename std::enable_if< has_rbegin< ContainerTy >::value >::type *=nullptr) -> decltype(make_range(C.rbegin(), C.rend()))
bool getUseLocalStackAllocationBlock() const
Get whether the local allocation blob should be allocated together or let PEI allocate the locals in ...
bool insert(const value_type &X)
Insert a new element into the SetVector.
virtual bool targetHandlesStackFrameRounding() const
targetHandlesStackFrameRounding - Returns true if the target is responsible for rounding up the stack...
virtual bool needsFrameIndexResolution(const MachineFunction &MF) const
iterator begin()
Get an iterator to the beginning of the SetVector.
int getObjectIndexBegin() const
Return the minimum frame object index.
bool isObjectPreAllocated(int ObjectIdx) const
Return true if the object was pre-allocated into the local block.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
int getObjectIndexEnd() const
Return one past the maximum frame object index.
SSPLayoutKind getObjectSSPLayout(int ObjectIdx) const
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...
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
virtual const TargetInstrInfo * getInstrInfo() const
void setHasNosplitStack(bool b)
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
virtual void adjustForSegmentedStacks(MachineFunction &MF, MachineBasicBlock &PrologueMBB) const
Adjust the prologue to have the function use segmented stacks.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
void setHasSplitStack(bool b)
TargetInstrInfo - Interface to description of machine instruction set.
Array or nested array >= SSP-buffer-size.
virtual void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const =0
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
unsigned getObjectAlignment(int ObjectIdx) const
Return the alignment of the specified stack object.
initializer< Ty > init(const Ty &Val)
This file declares the machine register scavenger class.
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
CodeGenOpt::Level getOptLevel() const
Returns the optimization level: None, Less, Default, or Aggressive.
unsigned const MachineRegisterInfo * MRI
void initializePEIPass(PassRegistry &)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
DISubprogram * getSubprogram() const
Get the attached subprogram.
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.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
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...
StackDirection getStackGrowthDirection() const
getStackGrowthDirection - Return the direction the stack grows
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
int getStackProtectorIndex() const
Return the index for the stack protector object.
unsigned getCallFrameSetupOpcode() const
These methods return the opcode of the frame setup/destroy instructions if they exist (-1 otherwise)...
Represent the analysis usage information of a pass.
df_ext_iterator< T, SetTy > df_ext_begin(const T &G, SetTy &S)
unsigned getMaxAlignment() const
Return the alignment in bytes that this function must be aligned to, which is greater than the defaul...
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.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
static void assignCalleeSavedSpillSlots(MachineFunction &F, const BitVector &SavedRegs, unsigned &MinCSFrameIndex, unsigned &MaxCSFrameIndex)
INITIALIZE_PASS_BEGIN(PEI, DEBUG_TYPE, "Prologue/Epilogue Insertion", false, false) INITIALIZE_PASS_END(PEI
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
Used in the streaming interface as the general argument type.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
const MachineBasicBlock & front() const
typename vector_type::const_iterator const_iterator
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
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.
const DIExpression * getDebugExpression() const
Return the complex address expression referenced by this DBG_VALUE instruction.
virtual bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, std::vector< CalleeSavedInfo > &CSI, const TargetRegisterInfo *TRI) const
restoreCalleeSavedRegisters - Issues instruction(s) to restore all callee saved registers and returns...
A SetVector that performs no allocations if smaller than a certain size.
Iterator for intrusive lists based on ilist_node.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
unsigned getMaxCallFrameSize() const
Return the maximum size of a call frame that must be allocated for an outgoing function call...
bool shouldSplitStack() const
Should we be emitting segmented stack stuff for the function.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
virtual void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const =0
bool isDebugValue() const
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...
Prologue Epilogue Insertion &Frame Finalization
bool isFrameInstr(const MachineInstr &I) const
Returns true if the argument is a frame pseudo instruction.
Information about stack frame layout on the target.
int CreateFixedSpillStackObject(uint64_t Size, int64_t SPOffset, bool IsImmutable=false)
Create a spill slot at a fixed location on the stack.
LLVM_NODISCARD T pop_back_val()
const WinEHFuncInfo * getWinEHFuncInfo() const
getWinEHFuncInfo - Return information about how the current function uses Windows exception handling...
static void insertCSRRestores(MachineBasicBlock &RestoreBlock, std::vector< CalleeSavedInfo > &CSI)
Insert restore code for the callee-saved registers used in the function.
void setPreservesCFG()
This function should be called by the pass, iff they do not:
void setAdjustsStack(bool V)
int64_t getFrameSize(const MachineInstr &I) const
Returns size of the frame associated with the given frame instruction.
void setMetadata(const MDNode *MD)
const Function & getFunction() const
Return the LLVM function that this machine code represents.
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...
unsigned getTransientStackAlignment() const
getTransientStackAlignment - This method returns the number of bytes to which the stack pointer must ...
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...
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...
char & PrologEpilogCodeInserterID
PrologEpilogCodeInserter - This pass inserts prolog and epilog code, and eliminates abstract frame re...
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
bool none() const
none - Returns true if none of the bits are set.
virtual bool isFPCloseToIncomingSP() const
isFPCloseToIncomingSP - Return true if the frame pointer is close to the incoming stack pointer...
Representation of each machine instruction.
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...
void setCalleeSavedInfo(const std::vector< CalleeSavedInfo > &CSI)
Used by prolog/epilog inserter to set the function's callee saved information.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
virtual bool requiresFrameIndexReplacementScavenging(const MachineFunction &MF) const
Returns true if the target requires using the RegScavenger directly for frame elimination despite usi...
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
LLVM_NODISCARD bool empty() const
const std::vector< CalleeSavedInfo > & getCalleeSavedInfo() const
Returns a reference to call saved info vector for the current function.
void push_back(MachineInstr *MI)
void setMaxCallFrameSize(unsigned S)
unsigned getLocalFrameMaxAlign() const
Return the required alignment of the local object blob.
virtual const TargetFrameLowering * getFrameLowering() const
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
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...
size_type size() const
size - Returns the number of bits in this bitvector.
void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
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...
virtual void inlineStackProbe(MachineFunction &MF, MachineBasicBlock &PrologueMBB) const
Replace a StackProbe stub (if any) with the actual probe code inline.
MachineBasicBlock * getSavePoint() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool hasProperty(Property P) const
bool needsStackRealignment(const MachineFunction &MF) const
True if storage within the function requires the stack pointer to be aligned more than the normal cal...
Array or nested array < SSP-buffer-size.
const MCPhysReg * getCalleeSavedRegs() const
Returns list of callee saved registers.
virtual void orderFrameObjects(const MachineFunction &MF, SmallVectorImpl< int > &objectsToAllocate) const
Order the symbols in the local stack frame.
bool isMaxCallFrameSizeComputed() const
void setObjectOffset(int ObjectIdx, int64_t SPOffset)
Set the stack frame offset of the specified object.
void setIsDebug(bool Val=true)
const MachineOperand & getOperand(unsigned i) const
int64_t getLocalFrameObjectCount() const
Return the number of objects allocated into the local object block.
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects...
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...
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...
bool isReserved(unsigned PhysReg) const
isReserved - Returns true when PhysReg is a reserved register.
bool hasCalls() const
Return true if the current function has any function calls.