75 #define DEBUG_TYPE "prologepilog" 79 STATISTIC(NumLeafFuncWithSpills,
"Number of leaf functions with CSRs");
80 STATISTIC(NumFuncSeen,
"Number of functions seen in PEI");
105 unsigned MaxCSFrameIndex = 0;
115 bool FrameIndexVirtualScavenging;
119 bool FrameIndexEliminationScavenging;
143 cl::desc(
"Warn for stack size bigger than the given" 160 "Number of bytes used for stack in all functions");
183 for (
auto &
MI : MBB) {
184 if (!
MI.isDebugInstr())
186 if (!
MI.isDebugValue() || !
MI.getDebugVariable()->isParameter())
188 if (
MI.getOperand(0).isFI()) {
197 return Var == DV->getDebugVariable() &&
204 EntryDbgValues[&MBB].push_back(&
MI);
208 if (EntryDbgValues.
count(&MBB))
209 for (
auto *
MI : EntryDbgValues[&MBB])
210 MI->removeFromParent();
223 ORE = &getAnalysis<MachineOptimizationRemarkEmitterPass>().getORE();
228 calculateCallFrameInfo(MF);
232 calculateSaveRestoreBlocks(MF);
241 spillCalleeSavedRegs(MF);
248 calculateFrameObjectOffsets(MF);
256 insertPrologEpilogCode(MF);
259 for (
auto &
I : EntryDbgValues)
260 I.first->insert(
I.first->begin(),
I.second.begin(),
I.second.end());
265 replaceFrameIndices(MF);
284 <<
ore::NV(
"NumStackBytes", StackSize) <<
" stack bytes in function";
289 RestoreBlocks.clear();
303 unsigned MaxCallFrameSize = 0;
312 if (FrameSetupOpcode == ~0u && FrameDestroyOpcode == ~0u)
315 std::vector<MachineBasicBlock::iterator> FrameSDOps;
320 if (Size > MaxCallFrameSize) MaxCallFrameSize =
Size;
322 FrameSDOps.push_back(
I);
323 }
else if (
I->isInlineAsm()) {
336 for (std::vector<MachineBasicBlock::iterator>::iterator
337 i = FrameSDOps.begin(),
e = FrameSDOps.end(); i !=
e; ++i) {
366 if (!RestoreBlock->succ_empty() || RestoreBlock->isReturnBlock())
372 SaveBlocks.push_back(&MF.
front());
374 if (MBB.isEHFuncletEntry())
375 SaveBlocks.push_back(&MBB);
376 if (MBB.isReturnBlock())
377 RestoreBlocks.push_back(&MBB);
383 unsigned &MinCSFrameIndex,
384 unsigned &MaxCSFrameIndex) {
385 if (SavedRegs.
empty())
391 std::vector<CalleeSavedInfo> CSI;
392 for (
unsigned i = 0; CSRegs[i]; ++i) {
393 unsigned Reg = CSRegs[i];
394 if (SavedRegs.
test(Reg))
406 unsigned NumFixedSpillSlots;
412 for (
auto &CS : CSI) {
415 if (CS.isSpilledToReg())
418 unsigned Reg = CS.getReg();
423 CS.setFrameIdx(FrameIdx);
430 while (FixedSlot != FixedSpillSlots + NumFixedSpillSlots &&
431 FixedSlot->
Reg != Reg)
435 if (FixedSlot == FixedSpillSlots + NumFixedSpillSlots) {
443 Align = std::min(Align, StackAlign);
445 if ((
unsigned)FrameIdx < MinCSFrameIndex) MinCSFrameIndex = FrameIdx;
446 if ((
unsigned)FrameIdx > MaxCSFrameIndex) MaxCSFrameIndex = FrameIdx;
452 CS.setFrameIdx(FrameIdx);
491 while (!WorkList.
empty()) {
495 if (CurBB == Save && Save != Restore)
500 if (Visited.
insert(SuccBB).second)
507 for (
unsigned i = 0,
e = CSI.size(); i !=
e; ++i) {
512 if (!MRI.
isReserved(Reg) && !MBB->isLiveIn(Reg))
520 if (CSI[i].isSpilledToReg()) {
522 if (Visited.count(&MBB))
525 if (!MBB.isLiveIn(DstReg))
526 MBB.addLiveIn(DstReg);
545 unsigned Reg = CS.getReg();
547 if (CS.isSpilledToReg()) {
549 TII.
get(TargetOpcode::COPY), CS.getDstReg())
562 std::vector<CalleeSavedInfo> &CSI) {
574 unsigned Reg = CI.getReg();
575 if (CI.isSpilledToReg()) {
582 "loadRegFromStackSlot didn't insert any code!");
613 if (!F.hasFnAttribute(Attribute::Naked)) {
619 NumLeafFuncWithSpills++;
636 bool StackGrowsDown, int64_t &
Offset,
637 unsigned &MaxAlign,
unsigned Skew) {
646 MaxAlign =
std::max(MaxAlign, Align);
649 Offset =
alignTo(Offset, Align, Skew);
651 if (StackGrowsDown) {
652 LLVM_DEBUG(
dbgs() <<
"alloc FI(" << FrameIdx <<
") at SP[" << -Offset
656 LLVM_DEBUG(
dbgs() <<
"alloc FI(" << FrameIdx <<
") at SP[" << Offset
667 unsigned MinCSFrameIndex,
unsigned MaxCSFrameIndex,
668 int64_t FixedCSEnd,
BitVector &StackBytesFree) {
673 StackBytesFree.
resize(FixedCSEnd,
true);
682 for (
int i = MinCSFrameIndex; i <= (int)MaxCSFrameIndex; ++i)
686 for (
int i : AllocatedFrameSlots) {
691 int ObjStart, ObjEnd;
692 if (StackGrowsDown) {
694 ObjStart = -ObjOffset - ObjSize;
697 ObjStart = ObjOffset;
698 ObjEnd = ObjOffset + ObjSize;
702 StackBytesFree.
reset(ObjStart, ObjEnd);
709 bool StackGrowsDown,
unsigned MaxAlign,
714 if (StackBytesFree.
none()) {
717 StackBytesFree.
clear();
722 if (ObjAlign > MaxAlign)
727 for (FreeStart = StackBytesFree.
find_first(); FreeStart != -1;
728 FreeStart = StackBytesFree.
find_next(FreeStart)) {
731 unsigned ObjStart = StackGrowsDown ? FreeStart + ObjSize : FreeStart;
732 if (
alignTo(ObjStart, ObjAlign) != ObjStart)
735 if (FreeStart + ObjSize > StackBytesFree.
size())
738 bool AllBytesFree =
true;
739 for (
unsigned Byte = 0; Byte < ObjSize; ++Byte)
740 if (!StackBytesFree.
test(FreeStart + Byte)) {
741 AllBytesFree =
false;
751 if (StackGrowsDown) {
752 int ObjStart = -(FreeStart + ObjSize);
753 LLVM_DEBUG(
dbgs() <<
"alloc FI(" << FrameIdx <<
") scavenged at SP[" 754 << ObjStart <<
"]\n");
757 LLVM_DEBUG(
dbgs() <<
"alloc FI(" << FrameIdx <<
") scavenged at SP[" 758 << FreeStart <<
"]\n");
762 StackBytesFree.
reset(FreeStart, FreeStart + ObjSize);
772 int64_t &
Offset,
unsigned &MaxAlign,
unsigned Skew) {
775 E = UnassignedObjs.
end();
I !=
E; ++
I) {
787 bool StackGrowsDown =
798 LocalAreaOffset = -LocalAreaOffset;
799 assert(LocalAreaOffset >= 0
800 &&
"Local area offset should be in direction of stack growth");
801 int64_t
Offset = LocalAreaOffset;
806 #ifdef EXPENSIVE_CHECKS 811 "MaxAlignment is invalid");
824 if (StackGrowsDown) {
834 if (FixedOff > Offset) Offset = FixedOff;
839 if (StackGrowsDown) {
840 for (
unsigned i = MinCSFrameIndex; i <= MaxCSFrameIndex; ++i) {
851 Offset =
alignTo(Offset, Align, Skew);
853 LLVM_DEBUG(
dbgs() <<
"alloc FI(" << i <<
") at SP[" << -Offset <<
"]\n");
856 }
else if (MaxCSFrameIndex >= MinCSFrameIndex) {
858 for (
unsigned i = MaxCSFrameIndex; i != MinCSFrameIndex - 1; --i) {
868 Offset =
alignTo(Offset, Align, Skew);
870 LLVM_DEBUG(
dbgs() <<
"alloc FI(" << i <<
") at SP[" << Offset <<
"]\n");
878 int64_t FixedCSEnd =
Offset;
885 bool EarlyScavengingSlots = (TFI.
hasFP(MF) &&
889 if (RS && EarlyScavengingSlots) {
891 RS->getScavengingFrameIndices(SFIs);
905 Offset =
alignTo(Offset, Align, Skew);
907 LLVM_DEBUG(
dbgs() <<
"Local frame base offset: " << Offset <<
"\n");
912 int64_t FIOffset = (StackGrowsDown ? -
Offset :
Offset) + Entry.second;
913 LLVM_DEBUG(
dbgs() <<
"alloc FI(" << Entry.first <<
") at SP[" << FIOffset
920 MaxAlign =
std::max(Align, MaxAlign);
926 EHRegNodeFrameIndex = FuncInfo->EHRegNodeFrameIndex;
946 "Stack protector not pre-allocated by LocalStackSlotPass.");
952 if (i >= MinCSFrameIndex && i <= MaxCSFrameIndex)
954 if (RS && RS->isScavengingFrameIndex((
int)i))
958 if (StackProtectorFI == (
int)i || EHRegNodeFrameIndex == (int)i)
984 !(LargeArrayObjs.
empty() && SmallArrayObjs.
empty() &&
987 "LocalStackSlotPass.");
990 Offset, MaxAlign, Skew);
992 Offset, MaxAlign, Skew);
994 Offset, MaxAlign, Skew);
1004 if (i >= MinCSFrameIndex && i <= MaxCSFrameIndex)
1006 if (RS && RS->isScavengingFrameIndex((
int)i))
1012 if (ProtectedObjs.count(i))
1037 if (!ObjectsToAllocate.
empty() &&
1041 FixedCSEnd, StackBytesFree);
1044 for (
auto &Object : ObjectsToAllocate)
1051 if (RS && !EarlyScavengingSlots) {
1053 RS->getScavengingFrameIndices(SFIs);
1071 unsigned StackAlign;
1080 StackAlign =
std::max(StackAlign, MaxAlign);
1081 Offset =
alignTo(Offset, StackAlign, Skew);
1085 int64_t StackSize = Offset - LocalAreaOffset;
1087 NumBytesStackSpace += StackSize;
1141 FrameIndexEliminationScavenging = (RS && !FrameIndexVirtualScavenging) ||
1151 DFI != DFE; ++DFI) {
1154 if (DFI.getPathLength() >= 2) {
1157 "DFS stack predecessor is already visited.\n");
1158 SPAdj = SPState[StackPred->
getNumber()];
1161 replaceFrameIndices(BB, MF, SPAdj);
1166 for (
auto &BB : MF) {
1167 if (Reachable.
count(&BB))
1171 replaceFrameIndices(&BB, MF, SPAdj);
1178 "getRegisterInfo() must be implemented!");
1183 if (RS && FrameIndexEliminationScavenging)
1184 RS->enterBasicBlock(*BB);
1186 bool InsideCallSequence =
false;
1189 if (TII.isFrameInstr(*
I)) {
1190 InsideCallSequence = TII.isFrameSetup(*
I);
1191 SPAdj += TII.getSPAdjust(*
I);
1198 bool DidFinishLoop =
true;
1207 assert(i == 0 &&
"Frame indices can only appear as the first " 1208 "operand of a DBG_VALUE machine instruction");
1235 bool WithStackValue =
true;
1250 if (MI.
getOpcode() == TargetOpcode::STATEPOINT) {
1252 "Frame indicies can only appear as the first operand of a " 1253 "DBG_VALUE machine instruction");
1270 bool AtBeginning = (
I == BB->
begin());
1271 if (!AtBeginning) --
I;
1277 FrameIndexEliminationScavenging ? RS :
nullptr);
1285 DidFinishLoop =
false;
1296 if (DidFinishLoop && InsideCallSequence)
1297 SPAdj += TII.getSPAdjust(MI);
1299 if (DoIncr &&
I != BB->
end()) ++
I;
1302 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 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...
bool isReserved(Register PhysReg) const
isReserved - Returns true when PhysReg is a reserved register.
void setCalleeSavedInfoValid(bool v)
static bool fragmentsOverlap(const FragmentInfo &A, const FragmentInfo &B)
Check if fragments overlap between a pair of FragmentInfos.
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...
bool hasStackProtectorIndex() const
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
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.
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 ...
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.
static DIExpression * prepend(const DIExpression *Expr, uint8_t Flags, int64_t Offset=0)
Prepend DIExpr with a deref and offset operation and optionally turn it into a stack value or/and an ...
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.
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly...
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
static void stashEntryDbgValues(MachineBasicBlock &MBB, SavedDbgValuesMap &EntryDbgValues)
Stash DBG_VALUEs that describe parameters and which are placed at the start of the block...
void setHasNosplitStack(bool b)
uint64_t value() const
This is a hole in the type system and should not be abused.
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
unsigned getKillRegState(bool B)
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.
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
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.
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)...
bool isImplicit() const
Return whether this is an implicit location description.
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 DIExpression * prependOpcodes(const DIExpression *Expr, SmallVectorImpl< uint64_t > &Ops, bool StackValue=false, bool EntryValue=false)
Prepend DIExpr with the given opcodes and optionally turn it into a stack value.
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.
This struct is a compact representation of a valid (non-zero power of two) alignment.
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...
bool isComplex() const
Return whether the location is computed on the expression stack, meaning it cannot be a simple regist...
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...
Align max(MaybeAlign Lhs, Align Rhs)
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.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
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.
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
void push_back(MachineInstr *MI)
void setMaxCallFrameSize(unsigned S)
bool empty() const
Determine if the SetVector is empty or not.
void ChangeToRegister(Register 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...
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
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
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.
uint8_t getStackID(int ObjectIdx) const
Align getLocalFrameMaxAlign() const
Return the required alignment of the local object blob.
MachineBasicBlock * getSavePoint() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool hasProperty(Property P) const
int CreateStackObject(uint64_t Size, Align 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...
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.
bool isIndirectDebugValue() const
A DBG_VALUE is indirect iff the first operand is a register and the second operand is an immediate...
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 hasCalls() const
Return true if the current function has any function calls.