74 #define DEBUG_TYPE "prologepilog" 100 unsigned MaxCSFrameIndex = 0;
110 bool FrameIndexVirtualScavenging;
114 bool FrameIndexEliminationScavenging;
138 cl::desc(
"Warn for stack size bigger than the given" 155 "Number of bytes used for stack in all functions");
177 FrameIndexEliminationScavenging = (RS && !FrameIndexVirtualScavenging) ||
179 ORE = &getAnalysis<MachineOptimizationRemarkEmitterPass>().getORE();
184 calculateCallFrameInfo(MF);
188 calculateSaveRestoreBlocks(MF);
192 spillCalleeSavedRegs(MF);
199 calculateFrameObjectOffsets(MF);
207 insertPrologEpilogCode(MF);
212 replaceFrameIndices(MF);
231 <<
ore::NV(
"NumStackBytes", StackSize) <<
" stack bytes in function";
236 RestoreBlocks.clear();
250 unsigned MaxCallFrameSize = 0;
259 if (FrameSetupOpcode == ~0u && FrameDestroyOpcode == ~0u)
262 std::vector<MachineBasicBlock::iterator> FrameSDOps;
267 if (Size > MaxCallFrameSize) MaxCallFrameSize =
Size;
269 FrameSDOps.push_back(
I);
270 }
else if (
I->isInlineAsm()) {
283 for (std::vector<MachineBasicBlock::iterator>::iterator
284 i = FrameSDOps.begin(), e = FrameSDOps.end(); i != e; ++i) {
313 if (!RestoreBlock->succ_empty() || RestoreBlock->isReturnBlock())
319 SaveBlocks.push_back(&MF.
front());
321 if (MBB.isEHFuncletEntry())
322 SaveBlocks.push_back(&MBB);
323 if (MBB.isReturnBlock())
324 RestoreBlocks.push_back(&MBB);
330 unsigned &MinCSFrameIndex,
331 unsigned &MaxCSFrameIndex) {
332 if (SavedRegs.
empty())
338 std::vector<CalleeSavedInfo> CSI;
339 for (
unsigned i = 0; CSRegs[i]; ++i) {
340 unsigned Reg = CSRegs[i];
341 if (SavedRegs.
test(Reg))
353 unsigned NumFixedSpillSlots;
359 for (
auto &CS : CSI) {
360 unsigned Reg = CS.getReg();
365 CS.setFrameIdx(FrameIdx);
372 while (FixedSlot != FixedSpillSlots + NumFixedSpillSlots &&
373 FixedSlot->
Reg != Reg)
377 if (FixedSlot == FixedSpillSlots + NumFixedSpillSlots) {
385 Align = std::min(Align, StackAlign);
387 if ((
unsigned)FrameIdx < MinCSFrameIndex) MinCSFrameIndex = FrameIdx;
388 if ((
unsigned)FrameIdx > MaxCSFrameIndex) MaxCSFrameIndex = FrameIdx;
394 CS.setFrameIdx(FrameIdx);
433 while (!WorkList.
empty()) {
437 if (CurBB == Save && Save != Restore)
442 if (Visited.
insert(SuccBB).second)
449 for (
unsigned i = 0, e = CSI.size(); i != e; ++i) {
454 if (!MRI.
isReserved(Reg) && !MBB->isLiveIn(Reg))
472 unsigned Reg = CS.getReg();
482 std::vector<CalleeSavedInfo> &CSI) {
494 unsigned Reg = CI.getReg();
498 "loadRegFromStackSlot didn't insert any code!");
528 if (!F.hasFnAttribute(Attribute::Naked)) {
548 bool StackGrowsDown, int64_t &
Offset,
549 unsigned &MaxAlign,
unsigned Skew) {
558 MaxAlign =
std::max(MaxAlign, Align);
561 Offset =
alignTo(Offset, Align, Skew);
563 if (StackGrowsDown) {
564 LLVM_DEBUG(
dbgs() <<
"alloc FI(" << FrameIdx <<
") at SP[" << -Offset
568 LLVM_DEBUG(
dbgs() <<
"alloc FI(" << FrameIdx <<
") at SP[" << Offset
579 unsigned MinCSFrameIndex,
unsigned MaxCSFrameIndex,
580 int64_t FixedCSEnd,
BitVector &StackBytesFree) {
585 StackBytesFree.
resize(FixedCSEnd,
true);
592 for (
int i = MinCSFrameIndex; i <= (int)MaxCSFrameIndex; ++i)
595 for (
int i : AllocatedFrameSlots) {
600 int ObjStart, ObjEnd;
601 if (StackGrowsDown) {
603 ObjStart = -ObjOffset - ObjSize;
606 ObjStart = ObjOffset;
607 ObjEnd = ObjOffset + ObjSize;
611 StackBytesFree.
reset(ObjStart, ObjEnd);
618 bool StackGrowsDown,
unsigned MaxAlign,
623 if (StackBytesFree.
none()) {
626 StackBytesFree.
clear();
631 if (ObjAlign > MaxAlign)
636 for (FreeStart = StackBytesFree.
find_first(); FreeStart != -1;
637 FreeStart = StackBytesFree.
find_next(FreeStart)) {
640 unsigned ObjStart = StackGrowsDown ? FreeStart + ObjSize : FreeStart;
641 if (
alignTo(ObjStart, ObjAlign) != ObjStart)
644 if (FreeStart + ObjSize > StackBytesFree.
size())
647 bool AllBytesFree =
true;
648 for (
unsigned Byte = 0; Byte < ObjSize; ++Byte)
649 if (!StackBytesFree.
test(FreeStart + Byte)) {
650 AllBytesFree =
false;
660 if (StackGrowsDown) {
661 int ObjStart = -(FreeStart + ObjSize);
662 LLVM_DEBUG(
dbgs() <<
"alloc FI(" << FrameIdx <<
") scavenged at SP[" 663 << ObjStart <<
"]\n");
666 LLVM_DEBUG(
dbgs() <<
"alloc FI(" << FrameIdx <<
") scavenged at SP[" 667 << FreeStart <<
"]\n");
671 StackBytesFree.
reset(FreeStart, FreeStart + ObjSize);
681 int64_t &
Offset,
unsigned &MaxAlign,
unsigned Skew) {
684 E = UnassignedObjs.
end();
I !=
E; ++
I) {
696 bool StackGrowsDown =
707 LocalAreaOffset = -LocalAreaOffset;
708 assert(LocalAreaOffset >= 0
709 &&
"Local area offset should be in direction of stack growth");
710 int64_t
Offset = LocalAreaOffset;
721 if (StackGrowsDown) {
731 if (FixedOff > Offset) Offset = FixedOff;
736 if (StackGrowsDown) {
737 for (
unsigned i = MinCSFrameIndex; i <= MaxCSFrameIndex; ++i) {
744 Offset =
alignTo(Offset, Align, Skew);
746 LLVM_DEBUG(
dbgs() <<
"alloc FI(" << i <<
") at SP[" << -Offset <<
"]\n");
749 }
else if (MaxCSFrameIndex >= MinCSFrameIndex) {
751 for (
unsigned i = MaxCSFrameIndex; i != MinCSFrameIndex - 1; --i) {
757 Offset =
alignTo(Offset, Align, Skew);
759 LLVM_DEBUG(
dbgs() <<
"alloc FI(" << i <<
") at SP[" << Offset <<
"]\n");
767 int64_t FixedCSEnd =
Offset;
774 bool EarlyScavengingSlots = (TFI.
hasFP(MF) &&
778 if (RS && EarlyScavengingSlots) {
780 RS->getScavengingFrameIndices(SFIs);
794 Offset =
alignTo(Offset, Align, Skew);
796 LLVM_DEBUG(
dbgs() <<
"Local frame base offset: " << Offset <<
"\n");
801 int64_t FIOffset = (StackGrowsDown ? -
Offset :
Offset) + Entry.second;
802 LLVM_DEBUG(
dbgs() <<
"alloc FI(" << Entry.first <<
") at SP[" << FIOffset
809 MaxAlign =
std::max(Align, MaxAlign);
815 EHRegNodeFrameIndex = FuncInfo->EHRegNodeFrameIndex;
833 if (i >= MinCSFrameIndex && i <= MaxCSFrameIndex)
835 if (RS && RS->isScavengingFrameIndex((
int)i))
840 EHRegNodeFrameIndex == (
int)i)
860 Offset, MaxAlign, Skew);
862 Offset, MaxAlign, Skew);
864 Offset, MaxAlign, Skew);
874 if (i >= MinCSFrameIndex && i <= MaxCSFrameIndex)
876 if (RS && RS->isScavengingFrameIndex((
int)i))
881 EHRegNodeFrameIndex == (
int)i)
883 if (ProtectedObjs.count(i))
905 if (!ObjectsToAllocate.
empty() &&
909 FixedCSEnd, StackBytesFree);
912 for (
auto &Object : ObjectsToAllocate)
919 if (RS && !EarlyScavengingSlots) {
921 RS->getScavengingFrameIndices(SFIs);
948 StackAlign =
std::max(StackAlign, MaxAlign);
949 Offset =
alignTo(Offset, StackAlign, Skew);
953 int64_t StackSize = Offset - LocalAreaOffset;
955 NumBytesStackSpace += StackSize;
1011 DFI != DFE; ++DFI) {
1014 if (DFI.getPathLength() >= 2) {
1017 "DFS stack predecessor is already visited.\n");
1018 SPAdj = SPState[StackPred->
getNumber()];
1021 replaceFrameIndices(BB, MF, SPAdj);
1026 for (
auto &BB : MF) {
1027 if (Reachable.
count(&BB))
1031 replaceFrameIndices(&BB, MF, SPAdj);
1038 "getRegisterInfo() must be implemented!");
1043 if (RS && FrameIndexEliminationScavenging)
1044 RS->enterBasicBlock(*BB);
1046 bool InsideCallSequence =
false;
1049 if (TII.isFrameInstr(*
I)) {
1050 InsideCallSequence = TII.isFrameSetup(*
I);
1051 SPAdj += TII.getSPAdjust(*
I);
1058 bool DidFinishLoop =
true;
1067 assert(i == 0 &&
"Frame indices can only appear as the first " 1068 "operand of a DBG_VALUE machine instruction");
1085 if (MI.
getOpcode() == TargetOpcode::STATEPOINT) {
1087 "Frame indicies can only appear as the first operand of a " 1088 "DBG_VALUE machine instruction");
1105 bool AtBeginning = (
I == BB->
begin());
1106 if (!AtBeginning) --
I;
1112 FrameIndexEliminationScavenging ? RS :
nullptr);
1120 DidFinishLoop =
false;
1131 if (DidFinishLoop && InsideCallSequence)
1132 SPAdj += TII.getSPAdjust(MI);
1134 if (DoIncr &&
I != BB->
end()) ++
I;
1137 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.
void push_back(const T &Elt)
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)
Compute iterated dominance frontiers using a linear time algorithm.
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.
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
unsigned getNumOperands() const
Access to explicit operands of the instruction.
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.
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
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 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.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
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...
virtual bool usesPhysRegsForPEI() const
True if the target uses physical regs at Prolog/Epilog insertion time.
bool isReserved(unsigned PhysReg) const
isReserved - Returns true when PhysReg is a reserved register.