LLVM 20.0.0git
|
#include "Target/X86/X86FrameLowering.h"
Public Member Functions | |
X86FrameLowering (const X86Subtarget &STI, MaybeAlign StackAlignOverride) | |
void | emitStackProbe (MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, bool InProlog, std::optional< MachineFunction::DebugInstrOperandPair > InstrNum=std::nullopt) const |
Emit target stack probe code. | |
bool | stackProbeFunctionModifiesSP () const override |
Does the stack probe function call return with a modified stack pointer? | |
void | inlineStackProbe (MachineFunction &MF, MachineBasicBlock &PrologMBB) const override |
Replace a StackProbe inline-stub with the actual probe code inline. | |
void | emitCalleeSavedFrameMovesFullCFA (MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI) const override |
Emits Dwarf Info specifying offsets of callee saved registers and frame pointer. | |
void | emitCalleeSavedFrameMoves (MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, bool IsPrologue) const |
void | emitPrologue (MachineFunction &MF, MachineBasicBlock &MBB) const override |
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function. | |
void | emitEpilogue (MachineFunction &MF, MachineBasicBlock &MBB) const override |
void | adjustForSegmentedStacks (MachineFunction &MF, MachineBasicBlock &PrologueMBB) const override |
Adjust the prologue to have the function use segmented stacks. | |
void | adjustForHiPEPrologue (MachineFunction &MF, MachineBasicBlock &PrologueMBB) const override |
Erlang programs may need a special prologue to handle the stack size they might need at runtime. | |
void | determineCalleeSaves (MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS=nullptr) const override |
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() should actually get saved. | |
bool | assignCalleeSavedSpillSlots (MachineFunction &MF, const TargetRegisterInfo *TRI, std::vector< CalleeSavedInfo > &CSI) const override |
bool | spillCalleeSavedRegisters (MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, ArrayRef< CalleeSavedInfo > CSI, const TargetRegisterInfo *TRI) const override |
spillCalleeSavedRegisters - Issues instruction(s) to spill all callee saved registers and returns true if it isn't possible / profitable to do so by issuing a series of store instructions via storeRegToStackSlot(). | |
bool | restoreCalleeSavedRegisters (MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, MutableArrayRef< CalleeSavedInfo > CSI, const TargetRegisterInfo *TRI) const override |
restoreCalleeSavedRegisters - Issues instruction(s) to restore all callee saved registers and returns true if it isn't possible / profitable to do so by issuing a series of load instructions via loadRegToStackSlot(). | |
void | spillFPBP (MachineFunction &MF) const override |
If a function uses base pointer and the base pointer is clobbered by inline asm, RA doesn't detect this case, and after the inline asm, the base pointer contains garbage value. | |
bool | hasFP (const MachineFunction &MF) const override |
hasFP - Return true if the specified function should have a dedicated frame pointer register. | |
bool | hasReservedCallFrame (const MachineFunction &MF) const override |
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. | |
bool | canSimplifyCallFramePseudos (const MachineFunction &MF) const override |
canSimplifyCallFramePseudos - If there is a reserved call frame, the call frame pseudos can be simplified. | |
bool | needsFrameIndexResolution (const MachineFunction &MF) const override |
StackOffset | getFrameIndexReference (const MachineFunction &MF, int FI, Register &FrameReg) const override |
getFrameIndexReference - This method should return the base register and offset used to reference a frame index location. | |
int | getWin64EHFrameIndexRef (const MachineFunction &MF, int FI, Register &SPReg) const |
StackOffset | getFrameIndexReferenceSP (const MachineFunction &MF, int FI, Register &SPReg, int Adjustment) const |
StackOffset | getFrameIndexReferencePreferSP (const MachineFunction &MF, int FI, Register &FrameReg, bool IgnoreSPUpdates) const override |
Same as getFrameIndexReference , except that the stack pointer (as opposed to the frame pointer) will be the preferred value for FrameReg . | |
MachineBasicBlock::iterator | eliminateCallFramePseudoInstr (MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const override |
This method is called during prolog/epilog code insertion to eliminate call frame setup and destroy pseudo instructions (but only if the Target is using them). | |
unsigned | getWinEHParentFrameOffset (const MachineFunction &MF) const override |
void | processFunctionBeforeFrameFinalized (MachineFunction &MF, RegScavenger *RS) const override |
processFunctionBeforeFrameFinalized - This method is called immediately before the specified function's frame layout (MF.getFrameInfo()) is finalized. | |
void | processFunctionBeforeFrameIndicesReplaced (MachineFunction &MF, RegScavenger *RS) const override |
processFunctionBeforeFrameIndicesReplaced - This method is called immediately before MO_FrameIndex operands are eliminated, but after the frame is finalized. | |
int | mergeSPUpdates (MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, bool doMergeWithPrevious) const |
Check the instruction before/after the passed instruction. | |
void | emitSPUpdate (MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, const DebugLoc &DL, int64_t NumBytes, bool InEpilogue) const |
Emit a series of instructions to increment / decrement the stack pointer by a constant value. | |
bool | canUseLEAForSPInEpilogue (const MachineFunction &MF) const |
Check that LEA can be used on SP in an epilogue sequence for MF . | |
bool | canUseAsPrologue (const MachineBasicBlock &MBB) const override |
Check whether or not the given MBB can be used as a prologue for the target. | |
bool | canUseAsEpilogue (const MachineBasicBlock &MBB) const override |
Check whether or not the given MBB can be used as a epilogue for the target. | |
bool | enableShrinkWrapping (const MachineFunction &MF) const override |
Returns true if the target will correctly handle shrink wrapping. | |
void | orderFrameObjects (const MachineFunction &MF, SmallVectorImpl< int > &ObjectsToAllocate) const override |
Order the symbols in the local stack. | |
void | BuildCFI (MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, const MCCFIInstruction &CFIInst, MachineInstr::MIFlag Flag=MachineInstr::NoFlags) const |
Wraps up getting a CFI index and building a MachineInstr for it. | |
MachineBasicBlock::iterator | restoreWin32EHStackPointers (MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, bool RestoreSP=false) const |
Sets up EBP and optionally ESI based on the incoming EBP value. | |
void | restoreWinEHStackPointersInParent (MachineFunction &MF) const |
int | getInitialCFAOffset (const MachineFunction &MF) const override |
Return initial CFA offset value i.e. | |
Register | getInitialCFARegister (const MachineFunction &MF) const override |
Return initial CFA register value i.e. | |
DwarfFrameBase | getDwarfFrameBase (const MachineFunction &MF) const override |
Return the frame base information to be encoded in the DWARF subprogram debug info. | |
bool | has128ByteRedZone (const MachineFunction &MF) const |
Return true if the function has a redzone (accessible bytes past the frame of the top of stack function) as part of it's ABI. | |
Public Member Functions inherited from llvm::TargetFrameLowering | |
TargetFrameLowering (StackDirection D, Align StackAl, int LAO, Align TransAl=Align(1), bool StackReal=true) | |
virtual | ~TargetFrameLowering () |
StackDirection | getStackGrowthDirection () const |
getStackGrowthDirection - Return the direction the stack grows | |
unsigned | getStackAlignment () const |
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligned on entry to a function. | |
Align | getStackAlign () const |
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligned on entry to a function. | |
virtual uint64_t | getStackThreshold () const |
getStackThreshold - Return the maximum stack size | |
int | alignSPAdjust (int SPAdj) const |
alignSPAdjust - This method aligns the stack adjustment to the correct alignment. | |
Align | getTransientStackAlign () const |
getTransientStackAlignment - This method returns the number of bytes to which the stack pointer must be aligned at all times, even between calls. | |
bool | isStackRealignable () const |
isStackRealignable - This method returns whether the stack can be realigned. | |
virtual bool | isStackIdSafeForLocalArea (unsigned StackId) const |
This method returns whether or not it is safe for an object with the given stack id to be bundled into the local area. | |
int | getOffsetOfLocalArea () const |
getOffsetOfLocalArea - This method returns the offset of the local area from the stack pointer on entrance to a function. | |
virtual bool | allocateScavengingFrameIndexesNearIncomingSP (const MachineFunction &MF) const |
Control the placement of special register scavenging spill slots when allocating a stack frame. | |
virtual bool | assignCalleeSavedSpillSlots (MachineFunction &MF, const TargetRegisterInfo *TRI, std::vector< CalleeSavedInfo > &CSI, unsigned &MinCSFrameIndex, unsigned &MaxCSFrameIndex) const |
assignCalleeSavedSpillSlots - Allows target to override spill slot assignment logic. | |
virtual bool | assignCalleeSavedSpillSlots (MachineFunction &MF, const TargetRegisterInfo *TRI, std::vector< CalleeSavedInfo > &CSI) const |
virtual const SpillSlot * | getCalleeSavedSpillSlots (unsigned &NumEntries) const |
getCalleeSavedSpillSlots - This method returns a pointer to an array of pairs, that contains an entry for each callee saved register that must be spilled to a particular stack location if it is spilled. | |
virtual bool | targetHandlesStackFrameRounding () const |
targetHandlesStackFrameRounding - Returns true if the target is responsible for rounding up the stack frame (probably at emitPrologue time). | |
virtual bool | enableShrinkWrapping (const MachineFunction &MF) const |
Returns true if the target will correctly handle shrink wrapping. | |
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 allocating other stack locations to reduce stack size. | |
virtual bool | enableCalleeSaveSkip (const MachineFunction &MF) const |
Returns true if the target can safely skip saving callee-saved registers for noreturn nounwind functions. | |
virtual void | emitPrologue (MachineFunction &MF, MachineBasicBlock &MBB) const =0 |
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function. | |
virtual void | emitEpilogue (MachineFunction &MF, MachineBasicBlock &MBB) const =0 |
virtual void | emitZeroCallUsedRegs (BitVector RegsToZero, MachineBasicBlock &MBB) const |
emitZeroCallUsedRegs - Zeros out call used registers. | |
virtual void | emitCalleeSavedFrameMovesFullCFA (MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI) const |
With basic block sections, emit callee saved frame moves for basic blocks that are in a different section. | |
virtual bool | enableCFIFixup (MachineFunction &MF) const |
Returns true if we may need to fix the unwind information for the function. | |
virtual void | resetCFIToInitialState (MachineBasicBlock &MBB) const |
Emit CFI instructions that recreate the state of the unwind information upon fucntion entry. | |
virtual void | inlineStackProbe (MachineFunction &MF, MachineBasicBlock &PrologueMBB) const |
Replace a StackProbe stub (if any) with the actual probe code inline. | |
virtual bool | stackProbeFunctionModifiesSP () const |
Does the stack probe function call return with a modified stack pointer? | |
virtual void | adjustForSegmentedStacks (MachineFunction &MF, MachineBasicBlock &PrologueMBB) const |
Adjust the prologue to have the function use segmented stacks. | |
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 explicitly handle the stack. | |
virtual bool | spillCalleeSavedRegisters (MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, ArrayRef< CalleeSavedInfo > CSI, const TargetRegisterInfo *TRI) const |
spillCalleeSavedRegisters - Issues instruction(s) to spill all callee saved registers and returns true if it isn't possible / profitable to do so by issuing a series of store instructions via storeRegToStackSlot(). | |
virtual bool | restoreCalleeSavedRegisters (MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, MutableArrayRef< CalleeSavedInfo > CSI, const TargetRegisterInfo *TRI) const |
restoreCalleeSavedRegisters - Issues instruction(s) to restore all callee saved registers and returns true if it isn't possible / profitable to do so by issuing a series of load instructions via loadRegToStackSlot(). | |
virtual bool | keepFramePointer (const MachineFunction &MF) const |
Return true if the target wants to keep the frame pointer regardless of the function attribute "frame-pointer". | |
virtual bool | hasFP (const MachineFunction &MF) const =0 |
hasFP - Return true if the specified function should have a dedicated frame pointer register. | |
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. | |
virtual bool | canSimplifyCallFramePseudos (const MachineFunction &MF) const |
canSimplifyCallFramePseudos - When possible, it's best to simplify the call frame pseudo ops before doing frame index elimination. | |
virtual bool | needsFrameIndexResolution (const MachineFunction &MF) const |
virtual StackOffset | getFrameIndexReference (const MachineFunction &MF, int FI, Register &FrameReg) const |
getFrameIndexReference - This method should return the base register and offset used to reference a frame index location. | |
virtual StackOffset | getFrameIndexReferencePreferSP (const MachineFunction &MF, int FI, Register &FrameReg, bool IgnoreSPUpdates) const |
Same as getFrameIndexReference , except that the stack pointer (as opposed to the frame pointer) will be the preferred value for FrameReg . | |
virtual StackOffset | getNonLocalFrameIndexReference (const MachineFunction &MF, int FI) const |
getNonLocalFrameIndexReference - This method returns the offset used to reference a frame index location. | |
virtual StackOffset | getFrameIndexReferenceFromSP (const MachineFunction &MF, int FI) const |
getFrameIndexReferenceFromSP - This method returns the offset from the stack pointer to the slot of the specified index. | |
virtual void | getCalleeSaves (const MachineFunction &MF, BitVector &SavedRegs) const |
Returns the callee-saved registers as computed by determineCalleeSaves in the BitVector SavedRegs . | |
virtual void | determineCalleeSaves (MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS=nullptr) const |
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() should actually get saved. | |
virtual void | processFunctionBeforeFrameFinalized (MachineFunction &MF, RegScavenger *RS=nullptr) const |
processFunctionBeforeFrameFinalized - This method is called immediately before the specified function's frame layout (MF.getFrameInfo()) is finalized. | |
virtual void | processFunctionBeforeFrameIndicesReplaced (MachineFunction &MF, RegScavenger *RS=nullptr) const |
processFunctionBeforeFrameIndicesReplaced - This method is called immediately before MO_FrameIndex operands are eliminated, but after the frame is finalized. | |
virtual unsigned | getWinEHParentFrameOffset (const MachineFunction &MF) const |
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 pseudo instructions (but only if the Target is using them). | |
virtual void | orderFrameObjects (const MachineFunction &MF, SmallVectorImpl< int > &objectsToAllocate) const |
Order the symbols in the local stack frame. | |
virtual bool | canUseAsPrologue (const MachineBasicBlock &MBB) const |
Check whether or not the given MBB can be used as a prologue for the target. | |
virtual bool | canUseAsEpilogue (const MachineBasicBlock &MBB) const |
Check whether or not the given MBB can be used as a epilogue for the target. | |
virtual TargetStackID::Value | getStackIDForScalableVectors () const |
Returns the StackID that scalable vectors should be associated with. | |
virtual bool | isSupportedStackID (TargetStackID::Value ID) const |
virtual bool | isProfitableForNoCSROpt (const Function &F) const |
Check if the no-CSR optimisation is profitable for the given function. | |
virtual int | getInitialCFAOffset (const MachineFunction &MF) const |
Return initial CFA offset value i.e. | |
virtual Register | getInitialCFARegister (const MachineFunction &MF) const |
Return initial CFA register value i.e. | |
virtual DwarfFrameBase | getDwarfFrameBase (const MachineFunction &MF) const |
Return the frame base information to be encoded in the DWARF subprogram debug info. | |
virtual void | spillFPBP (MachineFunction &MF) const |
If frame pointer or base pointer is clobbered by an instruction, we should spill/restore it around that instruction. | |
virtual void | emitRemarks (const MachineFunction &MF, MachineOptimizationRemarkEmitter *ORE) const |
This method is called at the end of prolog/epilog code insertion, so targets can emit remarks based on the final frame layout. | |
Public Attributes | |
const X86Subtarget & | STI |
const X86InstrInfo & | TII |
const X86RegisterInfo * | TRI |
unsigned | SlotSize |
bool | Is64Bit |
Is64Bit implies that x86_64 instructions are available. | |
bool | IsLP64 |
bool | Uses64BitFramePtr |
True if the 64-bit frame or stack pointer should be used. | |
unsigned | StackPtr |
Additional Inherited Members | |
Public Types inherited from llvm::TargetFrameLowering | |
enum | StackDirection { StackGrowsUp , StackGrowsDown } |
Static Public Member Functions inherited from llvm::TargetFrameLowering | |
static bool | isSafeForNoCSROpt (const Function &F) |
Check if given function is safe for not having callee saved registers. | |
Definition at line 28 of file X86FrameLowering.h.
X86FrameLowering::X86FrameLowering | ( | const X86Subtarget & | STI, |
MaybeAlign | StackAlignOverride | ||
) |
Definition at line 50 of file X86FrameLowering.cpp.
References llvm::X86RegisterInfo::getSlotSize(), llvm::X86RegisterInfo::getStackRegister(), Is64Bit, IsLP64, llvm::X86Subtarget::isTarget64BitLP64(), llvm::X86Subtarget::isTargetNaCl64(), SlotSize, StackPtr, STI, TRI, and Uses64BitFramePtr.
|
overridevirtual |
Erlang programs may need a special prologue to handle the stack size they might need at runtime.
That is because Erlang/OTP does not implement a C stack but uses a custom implementation of hybrid stack/heap architecture. (for more information see Eric Stenman's Ph.D. thesis: http://publications.uu.se/uu/fulltext/nbn_se_uu_diva-2688.pdf)
CheckStack: temp0 = sp - MaxStack if( temp0 < SP_LIMIT(P) ) goto IncStack else goto OldStart OldStart: ... IncStack: call inc_stack # doubles the stack space temp0 = sp - MaxStack if( temp0 < SP_LIMIT(P) ) goto IncStack else goto OldStart
Reimplemented from llvm::TargetFrameLowering.
Definition at line 3513 of file X86FrameLowering.cpp.
References llvm::MachineInstrBuilder::addExternalSymbol(), llvm::MachineInstrBuilder::addImm(), llvm::MachineBasicBlock::addLiveIn(), llvm::MachineInstrBuilder::addMBB(), llvm::MachineInstrBuilder::addReg(), llvm::addRegOffset(), llvm::MachineBasicBlock::addSuccessor(), llvm::Function::arg_size(), assert(), llvm::MachineFunction::begin(), llvm::BuildMI(), llvm::X86::COND_AE, llvm::X86::COND_LE, llvm::MachineFunction::CreateMachineBasicBlock(), DL, F, llvm::MachineFunction::getFrameInfo(), llvm::MachineFunction::getFunction(), llvm::MachineOperand::getGlobal(), getHiPELiteral(), llvm::Module::getNamedMetadata(), llvm::GlobalValue::getParent(), llvm::MachineFunction::getRegInfo(), GetScratchRegister(), llvm::MachineFrameInfo::getStackSize(), llvm::MachineFrameInfo::hasCalls(), Is64Bit, llvm::MachineOperand::isGlobal(), llvm::MachineRegisterInfo::isLiveIn(), IsLP64, llvm::X86Subtarget::isTargetLinux(), llvm::MachineBasicBlock::liveins(), MBB, MI, llvm::StringRef::npos, llvm::MachineFunction::push_front(), llvm::report_fatal_error(), SlotSize, STI, TII, and llvm::MachineFunction::verify().
|
overridevirtual |
Adjust the prologue to have the function use segmented stacks.
This works by adding a check even before the "normal" function prologue.
Reimplemented from llvm::TargetFrameLowering.
Definition at line 3205 of file X86FrameLowering.cpp.
References llvm::MachineInstrBuilder::addExternalSymbol(), llvm::MachineInstrBuilder::addImm(), llvm::MachineBasicBlock::addLiveIn(), llvm::MachineInstrBuilder::addMBB(), llvm::MachineInstrBuilder::addReg(), llvm::MachineBasicBlock::addSuccessor(), assert(), llvm::MachineFunction::begin(), llvm::BuildMI(), llvm::X86::COND_A, llvm::MachineFunction::CreateMachineBasicBlock(), DL, llvm::X86MachineFunctionInfo::getArgumentStackSize(), llvm::TargetMachine::getCodeModel(), llvm::MachineFunction::getFrameInfo(), llvm::MachineFunction::getFunction(), llvm::MachineFunction::getInfo(), getMOVriOpcode(), llvm::BranchProbability::getOne(), llvm::MachineFunction::getRegInfo(), GetScratchRegister(), llvm::MachineFrameInfo::getStackSize(), llvm::MachineFunction::getTarget(), llvm::BranchProbability::getZero(), HasNestArgument(), Is64Bit, llvm::MachineRegisterInfo::isLiveIn(), IsLP64, llvm::X86Subtarget::isTargetDarwin(), llvm::X86Subtarget::isTargetDragonFly(), llvm::X86Subtarget::isTargetFreeBSD(), llvm::X86Subtarget::isTargetLinux(), llvm::X86Subtarget::isTargetWin32(), llvm::X86Subtarget::isTargetWin64(), llvm::Function::isVarArg(), llvm::RegState::Kill, kSplitStackAvailable, llvm::CodeModel::Large, llvm::MachineBasicBlock::liveins(), llvm::MachineFrameInfo::needsSplitStackProlog(), llvm::MachineFunction::push_front(), llvm::report_fatal_error(), STI, TII, llvm::X86Subtarget::useIndirectThunkCalls(), and llvm::MachineFunction::verify().
|
overridevirtual |
Reimplemented from llvm::TargetFrameLowering.
Definition at line 2791 of file X86FrameLowering.cpp.
References llvm::X86MachineFunctionInfo::addCandidateForPush2Pop2(), llvm::alignDown(), llvm::alignTo(), assert(), contains(), llvm::count_if(), llvm::MachineFrameInfo::CreateFixedObject(), llvm::MachineFrameInfo::CreateFixedSpillStackObject(), llvm::MachineFrameInfo::CreateSpillStackObject(), llvm::MachineFrameInfo::ensureMaxAlignment(), llvm::MachineFunction::getFrameInfo(), llvm::X86RegisterInfo::getFrameRegister(), llvm::MachineFunction::getInfo(), llvm::X86MachineFunctionInfo::getNumCandidatesForPush2Pop2(), llvm::TargetFrameLowering::getOffsetOfLocalArea(), llvm::X86MachineFunctionInfo::getRestoreBasePointer(), llvm::X86MachineFunctionInfo::getTCReturnAddrDelta(), llvm::X86MachineFunctionInfo::getWinEHXMMSlotInfo(), llvm::MachineFunction::hasEHFunclets(), hasFP(), llvm::X86MachineFunctionInfo::hasSwiftAsyncContext(), I, llvm::X86MachineFunctionInfo::padForPush2Pop2(), llvm::reverse(), llvm::X86MachineFunctionInfo::setCalleeSavedFrameSize(), llvm::MachineFrameInfo::setCVBytesOfCalleeSavedRegisters(), llvm::X86MachineFunctionInfo::setHasSEHFramePtrSave(), llvm::X86MachineFunctionInfo::setPadForPush2Pop2(), llvm::X86MachineFunctionInfo::setRestoreBasePointer(), llvm::X86MachineFunctionInfo::setSEHFramePtrSaveIndex(), Size, SlotSize, STI, and TRI.
void X86FrameLowering::BuildCFI | ( | MachineBasicBlock & | MBB, |
MachineBasicBlock::iterator | MBBI, | ||
const DebugLoc & | DL, | ||
const MCCFIInstruction & | CFIInst, | ||
MachineInstr::MIFlag | Flag = MachineInstr::NoFlags |
||
) | const |
Wraps up getting a CFI index and building a MachineInstr for it.
Definition at line 445 of file X86FrameLowering.cpp.
References llvm::MachineInstrBuilder::addCFIIndex(), llvm::MachineFunction::addFrameInst(), llvm::BuildMI(), DL, llvm::MachineFunction::getInfo(), llvm::MCCFIInstruction::getOperation(), llvm::MachineBasicBlock::getParent(), MBB, MBBI, llvm::MCCFIInstruction::OpAdjustCfaOffset, llvm::MachineInstrBuilder::setMIFlag(), and TII.
Referenced by eliminateCallFramePseudoInstr(), emitCalleeSavedFrameMoves(), emitCalleeSavedFrameMovesFullCFA(), emitEpilogue(), emitPrologue(), and ExpandMOVImmSExti8().
|
overridevirtual |
canSimplifyCallFramePseudos - If there is a reserved call frame, the call frame pseudos can be simplified.
Having a FP, as in the default implementation, is not sufficient here since we can't always use it. Use a more nuanced condition.
Reimplemented from llvm::TargetFrameLowering.
Definition at line 74 of file X86FrameLowering.cpp.
References llvm::MachineFunction::getInfo(), llvm::X86RegisterInfo::hasBasePointer(), hasFP(), hasReservedCallFrame(), and TRI.
|
overridevirtual |
Check whether or not the given MBB
can be used as a epilogue for the target.
The epilogue will be inserted before the first terminator of that block. This method is used by the shrink-wrapping pass to decide if MBB
will be correctly handled by the target.
Reimplemented from llvm::TargetFrameLowering.
Definition at line 3853 of file X86FrameLowering.cpp.
References assert(), canUseLEAForSPInEpilogue(), flagsNeedToBePreservedBeforeTheTerminators(), llvm::MachineFunction::getInfo(), llvm::MachineBasicBlock::getParent(), llvm::X86MachineFunctionInfo::hasSwiftAsyncContext(), llvm::MachineBasicBlock::isReturnBlock(), llvm::X86Subtarget::isTargetWin64(), MBB, STI, and llvm::MachineBasicBlock::succ_empty().
|
overridevirtual |
Check whether or not the given MBB
can be used as a prologue for the target.
The prologue will be inserted first in this basic block. This method is used by the shrink-wrapping pass to decide if MBB
will be correctly handled by the target. As soon as the target enable shrink-wrapping without overriding this method, we assume that each basic block is a valid prologue.
Reimplemented from llvm::TargetFrameLowering.
Definition at line 3836 of file X86FrameLowering.cpp.
References assert(), llvm::MachineFunction::getInfo(), llvm::MachineBasicBlock::getParent(), llvm::MachineFunction::getSubtarget(), llvm::X86Subtarget::getTargetLowering(), llvm::X86MachineFunctionInfo::hasSwiftAsyncContext(), llvm::MachineBasicBlock::isLiveIn(), MBB, STI, and TRI.
bool X86FrameLowering::canUseLEAForSPInEpilogue | ( | const MachineFunction & | MF | ) | const |
Check that LEA can be used on SP in an epilogue sequence for MF
.
Definition at line 2260 of file X86FrameLowering.cpp.
References llvm::TargetMachine::getMCAsmInfo(), llvm::MachineFunction::getTarget(), hasFP(), and llvm::MCAsmInfo::usesWindowsCFI().
Referenced by canUseAsEpilogue().
|
overridevirtual |
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() should actually get saved.
The default implementation checks populates the SavedRegs
bitset with all registers which are modified in the function, targets may override this function to save additional registers. This method also sets up the register scavenger ensuring there is a free register or a frameindex available. This method should not be called by any passes outside of PEI, because it may change state passed in by MF
and RS
. The preferred interface outside PEI is getCalleeSaves.
Reimplemented from llvm::TargetFrameLowering.
Definition at line 3139 of file X86FrameLowering.cpp.
References llvm::TargetFrameLowering::determineCalleeSaves(), llvm::X86RegisterInfo::getBaseRegister(), llvm::getX86SubSuperRegister(), llvm::X86RegisterInfo::hasBasePointer(), llvm::X86Subtarget::isTarget64BitILP32(), llvm::BitVector::set(), STI, and TRI.
|
overridevirtual |
This method is called during prolog/epilog code insertion to eliminate call frame setup and destroy pseudo instructions (but only if the Target is using them).
It is responsible for eliminating these instructions, replacing them with concrete instructions. This method need only be implemented if using call frame setup/destroy pseudo instructions. Returns an iterator pointing to the instruction after the replaced one.
Reimplemented from llvm::TargetFrameLowering.
Definition at line 3726 of file X86FrameLowering.cpp.
References llvm::alignTo(), B, llvm::MachineBasicBlock::begin(), blockEndIsUnreachable(), BuildCFI(), llvm::MCCFIInstruction::createAdjustCfaOffset(), llvm::MCCFIInstruction::createGnuArgsSize(), DL, llvm::DwarfCFI, llvm::MachineBasicBlock::end(), llvm::MachineBasicBlock::erase(), F, llvm::X86InstrInfo::getFrameAdjustment(), llvm::MachineFunction::getFunction(), llvm::X86MachineFunctionInfo::getHasPushSequences(), llvm::MachineFunction::getInfo(), llvm::MachineFunction::getLandingPads(), llvm::TargetMachine::getMCAsmInfo(), llvm::TargetFrameLowering::getStackAlign(), llvm::MachineFunction::getTarget(), hasFP(), hasReservedCallFrame(), I, MBB, mergeSPUpdates(), llvm::MachineFunction::needsFrameMoves(), llvm::skipDebugInstructionsForward(), TII, and llvm::MCAsmInfo::usesWindowsCFI().
void X86FrameLowering::emitCalleeSavedFrameMoves | ( | MachineBasicBlock & | MBB, |
MachineBasicBlock::iterator | MBBI, | ||
const DebugLoc & | DL, | ||
bool | IsPrologue | ||
) | const |
Definition at line 483 of file X86FrameLowering.cpp.
References llvm::SmallString< InternalLen >::append(), BuildCFI(), llvm::MCCFIInstruction::createEscape(), llvm::MCCFIInstruction::createOffset(), llvm::MCCFIInstruction::createRestore(), DL, llvm::encodeSLEB128(), llvm::encodeULEB128(), FramePtr, llvm::MachineInstr::FrameSetup, llvm::MachineFrameInfo::getCalleeSavedInfo(), llvm::MachineFunction::getContext(), llvm::MachineFunction::getFrameInfo(), llvm::X86RegisterInfo::getFrameRegister(), llvm::MachineFunction::getInfo(), llvm::MachineFrameInfo::getObjectOffset(), llvm::MachineBasicBlock::getParent(), llvm::MCContext::getRegisterInfo(), llvm::X86MachineFunctionInfo::getStackPtrSaveMI(), llvm::getX86SubSuperRegister(), I, llvm::X86Subtarget::isTarget64BitILP32(), MBB, MBBI, MI, MRI, llvm::Offset, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SmallVectorBase< Size_T >::size(), SlotSize, STI, llvm::SmallString< InternalLen >::str(), and TRI.
Referenced by emitCalleeSavedFrameMovesFullCFA(), emitEpilogue(), and emitPrologue().
|
overridevirtual |
Emits Dwarf Info specifying offsets of callee saved registers and frame pointer.
This is called only when basic block sections are enabled.
Reimplemented from llvm::TargetFrameLowering.
Definition at line 463 of file X86FrameLowering.cpp.
References BuildCFI(), llvm::MCCFIInstruction::createOffset(), emitCalleeSavedFrameMoves(), FramePtr, llvm::MachineFunction::getContext(), llvm::X86RegisterInfo::getFrameRegister(), llvm::MachineBasicBlock::getParent(), llvm::MCContext::getRegisterInfo(), llvm::getX86SubSuperRegister(), hasFP(), Is64Bit, llvm::X86Subtarget::isTarget64BitILP32(), MBB, MBBI, MRI, llvm::Offset, STI, TRI, and Uses64BitFramePtr.
|
overridevirtual |
Implements llvm::TargetFrameLowering.
Definition at line 2343 of file X86FrameLowering.cpp.
References llvm::addFrameReference(), llvm::MachineInstrBuilder::addImm(), llvm::MachineInstrBuilder::addReg(), llvm::addRegOffset(), llvm::MachineInstrBuilder::addUse(), llvm::alignTo(), assert(), llvm::MachineBasicBlock::begin(), BuildCFI(), llvm::BuildMI(), calculateSetFPREG(), llvm::MCCFIInstruction::cfiDefCfa(), llvm::MCCFIInstruction::cfiDefCfaOffset(), llvm::MCCFIInstruction::createRestore(), DL, emitCalleeSavedFrameMoves(), emitSPUpdate(), llvm::MachineBasicBlock::end(), llvm::MachineInstr::FrameDestroy, FramePtr, llvm::X86MachineFunctionInfo::getAMXProgModel(), llvm::X86MachineFunctionInfo::getCalleeSavedFrameSize(), llvm::MachineBasicBlock::getFirstTerminator(), llvm::MachineFunction::getFrameInfo(), llvm::X86RegisterInfo::getFrameRegister(), llvm::MachineFunction::getFunction(), llvm::MachineFunction::getInfo(), getLEArOpcode(), llvm::TargetMachine::getMCAsmInfo(), getPOPOpcode(), llvm::X86MachineFunctionInfo::getStackPtrSaveMI(), llvm::MachineFrameInfo::getStackSize(), llvm::MachineFunction::getSubtarget(), llvm::MachineFunction::getTarget(), llvm::TargetMachine::getTargetTriple(), llvm::X86MachineFunctionInfo::getTCReturnAddrDelta(), llvm::getX86SubSuperRegister(), hasFP(), llvm::X86MachineFunctionInfo::hasSwiftAsyncContext(), llvm::MachineFrameInfo::hasVarSizedObjects(), llvm::MachineFunction::hasWinCFI(), Is64Bit, isFuncletReturnInstr(), llvm::Triple::isOSDarwin(), llvm::Triple::isOSWindows(), llvm::MachineBasicBlock::isReturnBlock(), isTailCallOpcode(), llvm::X86Subtarget::isTarget64BitILP32(), llvm::Register::isValid(), llvm::ManagedRA, MBB, MBBI, mergeSPUpdates(), MI, llvm::MachineFunction::needsFrameMoves(), llvm::Function::needsUnwindTableEntry(), llvm::Offset, llvm::MachineInstrBuilder::setMIFlag(), SlotSize, StackPtr, STI, llvm::MachineBasicBlock::succ_empty(), TII, TRI, Uses64BitFramePtr, and llvm::MCAsmInfo::usesWindowsCFI().
|
overridevirtual |
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
emitPrologue - Push callee-saved registers onto the stack, which automatically adjust the stack pointer.
Adjust the stack pointer to allocate space for local variables. Also emit labels used by the exception handler to generate the exception handling frames.
Implements llvm::TargetFrameLowering.
Definition at line 1527 of file X86FrameLowering.cpp.
References llvm::MachineInstrBuilder::addExternalSymbol(), llvm::addFrameReference(), llvm::MachineInstrBuilder::addImm(), llvm::MachineBasicBlock::addLiveIn(), llvm::MachineInstrBuilder::addMemOperand(), llvm::MachineInstrBuilder::addReg(), llvm::addRegOffset(), llvm::MachineInstrBuilder::addUse(), llvm::MachineFrameInfo::adjustsStack(), llvm::alignTo(), llvm::Alloc, llvm::Always, llvm::SmallString< InternalLen >::append(), llvm::Function::arg_size(), assert(), B, llvm::MachineBasicBlock::begin(), BuildCFI(), llvm::BuildMI(), calculateSetFPREG(), llvm::MCCFIInstruction::cfiDefCfa(), llvm::MCCFIInstruction::cfiDefCfaOffset(), llvm::classifyEHPersonality(), contains(), llvm::CoreCLR, llvm::MCCFIInstruction::createDefCfaRegister(), llvm::MCCFIInstruction::createEscape(), llvm::MCCFIInstruction::createOffset(), llvm::DeploymentBased, DL, llvm::WinEHFuncInfo::EHRegNodeFrameIndex, emitCalleeSavedFrameMoves(), emitSPUpdate(), emitStackProbe(), llvm::encodeULEB128(), llvm::MachineBasicBlock::end(), FramePtr, llvm::MachineInstr::FrameSetup, llvm::Function::getAttributes(), llvm::X86RegisterInfo::getBaseRegister(), llvm::X86MachineFunctionInfo::getCalleeSavedFrameSize(), llvm::Function::getCallingConv(), llvm::Module::getCodeViewFlag(), llvm::StackOffset::getFixed(), llvm::MachinePointerInfo::getFixedStack(), getFrameIndexReference(), llvm::MachineFunction::getFrameInfo(), llvm::X86RegisterInfo::getFrameRegister(), llvm::MachineFunction::getFunction(), llvm::X86MachineFunctionInfo::getHasSEHFramePtrSave(), llvm::MachineFunction::getInfo(), llvm::MachineFunction::getMachineMemOperand(), getMOVriOpcode(), llvm::GlobalValue::getParent(), llvm::Function::getPersonalityFn(), getPUSHOpcode(), llvm::MachineFunction::getRegInfo(), llvm::X86MachineFunctionInfo::getRestoreBasePointer(), llvm::X86MachineFunctionInfo::getRestoreBasePointerOffset(), llvm::X86MachineFunctionInfo::getSEHFramePtrSaveIndex(), llvm::X86TargetLowering::getStackProbeSize(), llvm::X86MachineFunctionInfo::getStackPtrSaveMI(), llvm::MachineFrameInfo::getStackSize(), llvm::MachineFunction::getSubtarget(), llvm::MachineFunction::getTarget(), llvm::X86Subtarget::getTargetLowering(), llvm::X86MachineFunctionInfo::getTCReturnAddrDelta(), llvm::X86MachineFunctionInfo::getUsesRedZone(), getWin64EHFrameIndexRef(), llvm::MachineFunction::getWinEHFuncInfo(), llvm::getX86SubSuperRegister(), has128ByteRedZone(), llvm::X86RegisterInfo::hasBasePointer(), llvm::MachineFrameInfo::hasCopyImplyingStackAdjustment(), llvm::MachineFunction::hasEHFunclets(), hasFP(), llvm::Function::hasPersonalityFn(), llvm::X86TargetLowering::hasStackProbeSymbol(), llvm::X86MachineFunctionInfo::hasSwiftAsyncContext(), llvm::MachineFrameInfo::hasVarSizedObjects(), llvm::MachineBasicBlock::insert(), Is64Bit, llvm::isAsynchronousEHPersonality(), llvm::MachineBasicBlock::isCleanupFuncletEntry(), isEAXLiveIn(), llvm::MachineBasicBlock::isEHFuncletEntry(), isOpcodeRep(), llvm::MachineRegisterInfo::isReserved(), llvm::X86InstrInfo::isStoreToStackSlot(), llvm::X86Subtarget::isTarget64BitILP32(), llvm::X86Subtarget::isTargetWin32(), llvm::Register::isValid(), llvm::RegState::Kill, MBB, MBBI, mergeSPUpdates(), MI, llvm::X86II::MO_GOTPCREL, llvm::MachineMemOperand::MOLoad, llvm::MachineMemOperand::MOStore, llvm::MachineMemOperand::MOVolatile, llvm::MSVC_CXX, llvm::Function::needsUnwindTableEntry(), llvm::Never, llvm::Offset, llvm::TargetMachine::Options, llvm::WinEHFuncInfo::PSPSymFrameIdx, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::report_fatal_error(), restoreWin32EHStackPointers(), llvm::WinEHFuncInfo::SEHSetFrameOffset, llvm::MachineFunction::setHasWinCFI(), llvm::MachineInstrBuilder::setMIFlag(), llvm::MachineFrameInfo::setOffsetAdjustment(), llvm::MachineFrameInfo::setStackSize(), llvm::X86MachineFunctionInfo::setUsesRedZone(), llvm::MachineFunction::shouldSplitStack(), SlotSize, StackPtr, STI, llvm::SmallString< InternalLen >::str(), llvm::X86Subtarget::swiftAsyncContextIsDynamicallySet(), llvm::TargetOptions::SwiftAsyncFramePointer, TII, TRI, llvm::RegState::Undef, llvm::Unknown, Uses64BitFramePtr, and llvm::CallingConv::X86_INTR.
void X86FrameLowering::emitSPUpdate | ( | MachineBasicBlock & | MBB, |
MachineBasicBlock::iterator & | MBBI, | ||
const DebugLoc & | DL, | ||
int64_t | NumBytes, | ||
bool | InEpilogue | ||
) | const |
Emit a series of instructions to increment / decrement the stack pointer by a constant value.
emitSPUpdate - Emit a series of instructions to increment / decrement the stack pointer by a constant value.
Definition at line 230 of file X86FrameLowering.cpp.
References llvm::MachineInstrBuilder::addImm(), llvm::MachineInstrBuilder::addReg(), llvm::addRegOffset(), assert(), llvm::BuildMI(), DL, llvm::X86RegisterInfo::findDeadCallerSavedReg(), llvm::MachineInstr::FrameDestroy, llvm::MachineInstr::FrameSetup, getADDrrOpcode(), llvm::getDefRegState(), getMOVriOpcode(), llvm::MachineBasicBlock::getParent(), getSUBrrOpcode(), llvm::MachineFunction::getSubtarget(), llvm::X86Subtarget::getTargetLowering(), llvm::getUndefRegState(), llvm::X86TargetLowering::hasInlineStackProbe(), Is64Bit, isEAXLiveIn(), llvm::RegState::Kill, MBB, MBBI, MI, llvm::Offset, llvm::MachineInstrBuilder::setMIFlag(), SlotSize, StackPtr, STI, TII, and TRI.
Referenced by emitEpilogue(), emitPrologue(), restoreCalleeSavedRegisters(), and spillCalleeSavedRegisters().
void X86FrameLowering::emitStackProbe | ( | MachineFunction & | MF, |
MachineBasicBlock & | MBB, | ||
MachineBasicBlock::iterator | MBBI, | ||
const DebugLoc & | DL, | ||
bool | InProlog, | ||
std::optional< MachineFunction::DebugInstrOperandPair > | InstrNum = std::nullopt |
||
) | const |
Emit target stack probe code.
This is required for all large stack allocations on Windows. The caller is required to materialize the number of bytes to probe in RAX/EAX. InstrNum
optionally contains a debug-info instruction number for the new stack pointer.
Definition at line 604 of file X86FrameLowering.cpp.
References llvm::MachineInstrBuilder::addImm(), llvm::BuildMI(), DL, llvm::MachineFunction::getSubtarget(), llvm::X86Subtarget::isTargetWindowsCoreCLR(), MBB, MBBI, STI, and TII.
Referenced by emitPrologue().
|
overridevirtual |
Returns true if the target will correctly handle shrink wrapping.
Reimplemented from llvm::TargetFrameLowering.
Definition at line 3879 of file X86FrameLowering.cpp.
References llvm::Function::getCallingConv(), llvm::MCObjectFileInfo::getCompactUnwindSection(), llvm::MachineFunction::getContext(), llvm::MachineFunction::getFunction(), llvm::MCContext::getObjectFileInfo(), llvm::Function::hasFnAttribute(), hasFP(), llvm::CallingConv::HiPE, and llvm::MachineFunction::shouldSplitStack().
|
overridevirtual |
Return the frame base information to be encoded in the DWARF subprogram debug info.
Reimplemented from llvm::TargetFrameLowering.
Definition at line 3968 of file X86FrameLowering.cpp.
References llvm::MachineFunction::getFrameInfo(), llvm::TargetRegisterInfo::getFrameRegister(), llvm::MachineFunction::getInfo(), getInitialCFAOffset(), getInitialCFARegister(), llvm::TargetSubtargetInfo::getRegisterInfo(), llvm::MachineFrameInfo::getStackSize(), llvm::MachineFunction::getSubtarget(), llvm::X86MachineFunctionInfo::hasCFIAdjustCfa(), llvm::TargetFrameLowering::DwarfFrameBase::Kind, llvm::TargetFrameLowering::DwarfFrameBase::Location, and llvm::TargetFrameLowering::DwarfFrameBase::Offset.
|
overridevirtual |
getFrameIndexReference - This method should return the base register and offset used to reference a frame index location.
Returns the displacement from the frame register to the stack frame of the specified index, along with the frame register used (in output arg FrameReg).
The offset is returned directly, and the base register is returned via FrameReg.
This is the default implementation which is overridden for some targets.
Reimplemented from llvm::TargetFrameLowering.
Definition at line 2600 of file X86FrameLowering.cpp.
References assert(), calculateSetFPREG(), llvm::X86RegisterInfo::getBaseRegister(), llvm::X86MachineFunctionInfo::getCalleeSavedFrameSize(), llvm::Function::getCallingConv(), llvm::X86MachineFunctionInfo::getFAIndex(), llvm::StackOffset::getFixed(), llvm::MachineFunction::getFrameInfo(), llvm::X86RegisterInfo::getFramePtr(), llvm::X86RegisterInfo::getFrameRegister(), llvm::MachineFunction::getFunction(), llvm::MachineFunction::getInfo(), llvm::TargetMachine::getMCAsmInfo(), llvm::MachineFrameInfo::getObjectAlign(), llvm::MachineFrameInfo::getObjectOffset(), llvm::TargetFrameLowering::getOffsetOfLocalArea(), llvm::X86MachineFunctionInfo::getRestoreBasePointer(), llvm::X86RegisterInfo::getStackRegister(), llvm::MachineFrameInfo::getStackSize(), llvm::MachineFunction::getTarget(), llvm::X86MachineFunctionInfo::getTCReturnAddrDelta(), llvm::X86RegisterInfo::hasBasePointer(), llvm::MachineFrameInfo::hasCalls(), llvm::isAligned(), llvm::MachineFrameInfo::isFixedObjectIndex(), llvm::Offset, SlotSize, TRI, llvm::MCAsmInfo::usesWindowsCFI(), and llvm::CallingConv::X86_INTR.
Referenced by llvm::X86RegisterInfo::eliminateFrameIndex(), emitPrologue(), getFrameIndexReferencePreferSP(), getWin64EHFrameIndexRef(), and restoreWin32EHStackPointers().
|
overridevirtual |
Same as getFrameIndexReference
, except that the stack pointer (as opposed to the frame pointer) will be the preferred value for FrameReg
.
This is generally used for emitting statepoint or EH tables that use offsets from RSP. If IgnoreSPUpdates
is true, the returned offset is only guaranteed to be valid with respect to the value of SP at the end of the prologue.
Reimplemented from llvm::TargetFrameLowering.
Definition at line 2709 of file X86FrameLowering.cpp.
References assert(), getFrameIndexReference(), getFrameIndexReferenceSP(), llvm::MachineFunction::getFrameInfo(), llvm::MachineFunction::getInfo(), llvm::MachineFrameInfo::getStackSize(), llvm::X86MachineFunctionInfo::getTCReturnAddrDelta(), hasReservedCallFrame(), llvm::MachineFrameInfo::isFixedObjectIndex(), llvm::X86Subtarget::isTargetWin64(), STI, and TRI.
StackOffset X86FrameLowering::getFrameIndexReferenceSP | ( | const MachineFunction & | MF, |
int | FI, | ||
Register & | SPReg, | ||
int | Adjustment | ||
) | const |
Definition at line 2699 of file X86FrameLowering.cpp.
References llvm::StackOffset::getFixed(), llvm::MachineFunction::getFrameInfo(), llvm::MachineFrameInfo::getObjectOffset(), llvm::TargetFrameLowering::getOffsetOfLocalArea(), llvm::X86RegisterInfo::getStackRegister(), and TRI.
Referenced by llvm::X86RegisterInfo::eliminateFrameIndex(), and getFrameIndexReferencePreferSP().
|
overridevirtual |
Return initial CFA offset value i.e.
the one valid at the beginning of the function (before any stack operations).
Reimplemented from llvm::TargetFrameLowering.
Definition at line 3958 of file X86FrameLowering.cpp.
References llvm::X86RegisterInfo::getSlotSize(), and TRI.
Referenced by getDwarfFrameBase().
|
overridevirtual |
Return initial CFA register value i.e.
the one valid at the beginning of the function (before any stack operations).
Reimplemented from llvm::TargetFrameLowering.
Definition at line 3963 of file X86FrameLowering.cpp.
References StackPtr.
Referenced by getDwarfFrameBase().
int X86FrameLowering::getWin64EHFrameIndexRef | ( | const MachineFunction & | MF, |
int | FI, | ||
Register & | SPReg | ||
) | const |
Definition at line 2683 of file X86FrameLowering.cpp.
References llvm::alignDown(), llvm::StackOffset::getFixed(), getFrameIndexReference(), llvm::MachineFunction::getFrameInfo(), llvm::MachineFunction::getInfo(), llvm::MachineFrameInfo::getMaxCallFrameSize(), llvm::TargetFrameLowering::getStackAlign(), llvm::X86RegisterInfo::getStackRegister(), llvm::X86MachineFunctionInfo::getWinEHXMMSlotInfo(), TRI, and value.
Referenced by llvm::X86RegisterInfo::eliminateFrameIndex(), and emitPrologue().
|
overridevirtual |
Reimplemented from llvm::TargetFrameLowering.
Definition at line 4126 of file X86FrameLowering.cpp.
References llvm::MachineFunction::getInfo(), llvm::Offset, and SlotSize.
bool X86FrameLowering::has128ByteRedZone | ( | const MachineFunction & | MF | ) | const |
Return true if the function has a redzone (accessible bytes past the frame of the top of stack function) as part of it's ABI.
Definition at line 1393 of file X86FrameLowering.cpp.
References assert(), llvm::Function::getCallingConv(), llvm::MachineFunction::getFunction(), llvm::MachineFunction::getSubtarget(), llvm::Function::hasFnAttribute(), Is64Bit, llvm::X86Subtarget::isCallingConvWin64(), and STI.
Referenced by emitLockedStackOp(), emitPrologue(), and llvm::X86InstrInfo::isFunctionSafeToOutlineFrom().
|
overridevirtual |
hasFP - Return true if the specified function should have a dedicated frame pointer register.
This is true if the function has variable sized allocas or if frame pointer elimination is disabled.
Implements llvm::TargetFrameLowering.
Definition at line 98 of file X86FrameLowering.cpp.
References llvm::MachineFunction::callsEHReturn(), llvm::MachineFunction::callsUnwindInit(), llvm::TargetOptions::DisableFramePointerElim(), llvm::X86MachineFunctionInfo::getForceFramePointer(), llvm::MachineFunction::getFrameInfo(), llvm::MachineFunction::getInfo(), llvm::MachineFunction::getTarget(), llvm::MachineFrameInfo::hasCopyImplyingStackAdjustment(), llvm::MachineFunction::hasEHFunclets(), llvm::MachineFrameInfo::hasOpaqueSPAdjustment(), llvm::MachineFrameInfo::hasPatchPoint(), llvm::X86MachineFunctionInfo::hasPreallocatedCall(), llvm::MachineFrameInfo::hasStackMap(), llvm::MachineFrameInfo::hasVarSizedObjects(), llvm::MachineFrameInfo::isFrameAddressTaken(), llvm::TargetMachine::Options, and TRI.
Referenced by assignCalleeSavedSpillSlots(), canSimplifyCallFramePseudos(), canUseLEAForSPInEpilogue(), eliminateCallFramePseudoInstr(), emitCalleeSavedFrameMovesFullCFA(), emitEpilogue(), llvm::X86AsmPrinter::emitInstruction(), emitPrologue(), enableShrinkWrapping(), ExpandMOVImmSExti8(), llvm::X86RegisterInfo::getFrameRegister(), llvm::X86RegisterInfo::getPointerRegClass(), llvm::X86RegisterInfo::getRegPressureLimit(), llvm::X86RegisterInfo::getReservedRegs(), llvm::X86RegisterInfo::isFixedRegister(), and orderFrameObjects().
|
overridevirtual |
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 eliminates the need for add/sub sp brackets around call sites. Returns true if the call frame is included as part of the stack frame.
Reimplemented from llvm::TargetFrameLowering.
Definition at line 64 of file X86FrameLowering.cpp.
References llvm::MachineFunction::getFrameInfo(), llvm::MachineFunction::getInfo(), and llvm::MachineFrameInfo::hasVarSizedObjects().
Referenced by canSimplifyCallFramePseudos(), eliminateCallFramePseudoInstr(), and getFrameIndexReferencePreferSP().
|
overridevirtual |
Replace a StackProbe inline-stub with the actual probe code inline.
Reimplemented from llvm::TargetFrameLowering.
Definition at line 625 of file X86FrameLowering.cpp.
References DL, llvm::MachineBasicBlock::end(), llvm::find_if(), llvm::MachineBasicBlock::findDebugLoc(), and MI.
int X86FrameLowering::mergeSPUpdates | ( | MachineBasicBlock & | MBB, |
MachineBasicBlock::iterator & | MBBI, | ||
bool | doMergeWithPrevious | ||
) | const |
Check the instruction before/after the passed instruction.
If it is an ADD/SUB/LEA instruction it is deleted argument and the stack adjustment is returned as a positive value for ADD/LEA and a negative for SUB.
Definition at line 385 of file X86FrameLowering.cpp.
References assert(), llvm::MachineBasicBlock::begin(), llvm::MachineBasicBlock::end(), llvm::MachineBasicBlock::erase(), llvm::MachineFunction::getFrameInstructions(), llvm::MCCFIInstruction::getOperation(), llvm::MachineBasicBlock::getParent(), MBB, MBBI, llvm::Offset, llvm::MCCFIInstruction::OpAdjustCfaOffset, llvm::MCCFIInstruction::OpDefCfaOffset, llvm::skipDebugInstructionsBackward(), llvm::skipDebugInstructionsForward(), and StackPtr.
Referenced by eliminateCallFramePseudoInstr(), emitEpilogue(), and emitPrologue().
|
overridevirtual |
Reimplemented from llvm::TargetFrameLowering.
Definition at line 89 of file X86FrameLowering.cpp.
References llvm::MachineFunction::getFrameInfo(), llvm::MachineFunction::getInfo(), and llvm::MachineFrameInfo::hasStackObjects().
|
overridevirtual |
Order the symbols in the local stack.
We want to place the local stack objects in some sort of sensible order. The heuristic we use is to try and pack them according to static number of uses and size in order to minimize code size.
Reimplemented from llvm::TargetFrameLowering.
Definition at line 4054 of file X86FrameLowering.cpp.
References llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::SmallVectorBase< Size_T >::empty(), llvm::SmallVectorTemplateCommon< T, typename >::end(), llvm::MachineFunction::getFrameInfo(), llvm::MachineFrameInfo::getObjectAlign(), llvm::MachineFrameInfo::getObjectIndexEnd(), llvm::MachineFrameInfo::getObjectSize(), hasFP(), MBB, MI, llvm::stable_sort(), and TRI.
|
overridevirtual |
processFunctionBeforeFrameFinalized - This method is called immediately before the specified function's frame layout (MF.getFrameInfo()) is finalized.
Once the frame is finalized, MO_FrameIndex operands are replaced with direct constants. This method is optional.
Reimplemented from llvm::TargetFrameLowering.
Definition at line 4138 of file X86FrameLowering.cpp.
References llvm::RegScavenger::addScavengingFrameIndex(), llvm::classifyEHPersonality(), llvm::MachineFrameInfo::CreateStackObject(), llvm::MachineFrameInfo::ensureMaxAlignment(), llvm::MachineFrameInfo::estimateStackSize(), llvm::MachineFunction::getFrameInfo(), llvm::MachineFunction::getFunction(), llvm::TargetMachine::getMCAsmInfo(), llvm::Function::getPersonalityFn(), llvm::MachineFunction::getTarget(), llvm::MachineFunction::hasEHFunclets(), llvm::MSVC_CXX, llvm::MachineFunction::setHasWinCFI(), SlotSize, STI, and llvm::MCAsmInfo::usesWindowsCFI().
|
overridevirtual |
processFunctionBeforeFrameIndicesReplaced - This method is called immediately before MO_FrameIndex operands are eliminated, but after the frame is finalized.
This method is optional.
Reimplemented from llvm::TargetFrameLowering.
Definition at line 4211 of file X86FrameLowering.cpp.
References llvm::MachineFunction::getInfo(), llvm::X86MachineFunctionInfo::getStackPtrSaveMI(), llvm::MachineFunction::hasEHFunclets(), MI, restoreWinEHStackPointersInParent(), llvm::X86MachineFunctionInfo::setStackPtrSaveMI(), and STI.
|
overridevirtual |
restoreCalleeSavedRegisters - Issues instruction(s) to restore all callee saved registers and returns true if it isn't possible / profitable to do so by issuing a series of load instructions via loadRegToStackSlot().
If it returns true, and any of the registers in CSI is not restored, it sets the corresponding Restored flag in CSI to false. Returns false otherwise.
Reimplemented from llvm::TargetFrameLowering.
Definition at line 3069 of file X86FrameLowering.cpp.
References llvm::MachineInstrBuilder::addReg(), llvm::MutableArrayRef< T >::begin(), llvm::BuildMI(), llvm::classifyEHPersonality(), contains(), llvm::RegState::Define, DL, emitSPUpdate(), llvm::ArrayRef< T >::empty(), llvm::MachineBasicBlock::end(), llvm::MutableArrayRef< T >::end(), F, llvm::MachineBasicBlock::findDebugLoc(), llvm::MachineInstr::FrameDestroy, llvm::MachineFunction::getFunction(), llvm::MachineFunction::getInfo(), llvm::MachineBasicBlock::getParent(), getPOP2Opcode(), getPOPOpcode(), getReg(), llvm::X86MachineFunctionInfo::getRestoreBasePointer(), I, llvm::isAsynchronousEHPersonality(), llvm::X86MachineFunctionInfo::isCandidateForPush2Pop2(), isFuncletReturnInstr(), llvm::X86Subtarget::isOSWindows(), llvm::X86InstrInfo::loadRegFromStackSlot(), MBB, MI, llvm::X86MachineFunctionInfo::padForPush2Pop2(), llvm::MachineInstrBuilder::setMIFlag(), SlotSize, STI, TII, and TRI.
MachineBasicBlock::iterator X86FrameLowering::restoreWin32EHStackPointers | ( | MachineBasicBlock & | MBB, |
MachineBasicBlock::iterator | MBBI, | ||
const DebugLoc & | DL, | ||
bool | RestoreSP = false |
||
) | const |
Sets up EBP and optionally ESI based on the incoming EBP value.
Only needed for 32-bit. Used in funclet prologues and at catchret destinations.
Definition at line 3895 of file X86FrameLowering.cpp.
References llvm::MachineInstrBuilder::addImm(), llvm::MachineInstrBuilder::addReg(), llvm::addRegOffset(), assert(), llvm::BuildMI(), DL, llvm::WinEHFuncInfo::EHRegNodeEndOffset, llvm::WinEHFuncInfo::EHRegNodeFrameIndex, FramePtr, llvm::MachineInstr::FrameSetup, getADDriOpcode(), llvm::X86RegisterInfo::getBaseRegister(), llvm::StackOffset::getFixed(), getFrameIndexReference(), llvm::MachineFunction::getFrameInfo(), llvm::X86RegisterInfo::getFrameRegister(), llvm::X86MachineFunctionInfo::getHasSEHFramePtrSave(), llvm::MachineFunction::getInfo(), llvm::MachineInstr::getOperand(), llvm::MachineBasicBlock::getParent(), llvm::X86MachineFunctionInfo::getSEHFramePtrSaveIndex(), llvm::MachineFunction::getWinEHFuncInfo(), llvm::X86Subtarget::isTargetWin32(), llvm::X86Subtarget::isTargetWindowsMSVC(), llvm_unreachable, MBB, MBBI, llvm::Offset, llvm::MachineOperand::setIsDead(), llvm::MachineInstrBuilder::setMIFlag(), STI, TII, TRI, and Uses64BitFramePtr.
Referenced by emitPrologue(), and restoreWinEHStackPointersInParent().
void X86FrameLowering::restoreWinEHStackPointersInParent | ( | MachineFunction & | MF | ) | const |
Definition at line 4225 of file X86FrameLowering.cpp.
References llvm::MachineBasicBlock::begin(), llvm::classifyEHPersonality(), llvm::MachineFunction::getFunction(), llvm::Function::getPersonalityFn(), llvm::isAsynchronousEHPersonality(), llvm::MachineBasicBlock::isEHFuncletEntry(), llvm::MachineBasicBlock::isEHPad(), MBB, and restoreWin32EHStackPointers().
Referenced by processFunctionBeforeFrameIndicesReplaced().
|
overridevirtual |
spillCalleeSavedRegisters - Issues instruction(s) to spill all callee saved registers and returns true if it isn't possible / profitable to do so by issuing a series of store instructions via storeRegToStackSlot().
Returns false otherwise.
Reimplemented from llvm::TargetFrameLowering.
Definition at line 2949 of file X86FrameLowering.cpp.
References llvm::MachineBasicBlock::addLiveIn(), llvm::MachineInstrBuilder::addReg(), llvm::BuildMI(), contains(), DL, emitSPUpdate(), llvm::MachineBasicBlock::findDebugLoc(), llvm::MachineInstr::FrameSetup, llvm::MachineFunction::getInfo(), llvm::getKillRegState(), llvm::MachineBasicBlock::getParent(), getPUSH2Opcode(), getPUSHOpcode(), getReg(), llvm::MachineFunction::getRegInfo(), llvm::X86MachineFunctionInfo::getRestoreBasePointer(), I, llvm::X86MachineFunctionInfo::isCandidateForPush2Pop2(), llvm::MachineBasicBlock::isEHFuncletEntry(), llvm::X86Subtarget::isOSWindows(), llvm::MCRegAliasIterator::isValid(), MBB, MI, MRI, llvm::X86MachineFunctionInfo::padForPush2Pop2(), llvm::ArrayRef< T >::rbegin(), llvm::ArrayRef< T >::rend(), llvm::reverse(), llvm::MachineInstrBuilder::setMIFlag(), SlotSize, STI, llvm::X86InstrInfo::storeRegToStackSlot(), TII, and TRI.
|
overridevirtual |
If a function uses base pointer and the base pointer is clobbered by inline asm, RA doesn't detect this case, and after the inline asm, the base pointer contains garbage value.
For example if a 32b x86 function uses base pointer esi, and esi is clobbered by following inline asm asm("rep movsb" : "+D"(ptr), "+S"(x), "+c"(c)::"memory"); We need to save esi before the asm and restore it after the asm.
The problem can also occur to frame pointer if there is a function call, and the callee uses a different calling convention and clobbers the fp.
Because normal frame objects (spill slots) are accessed through fp/bp register, so we can't spill fp/bp to normal spill slots.
FIXME: There are 2 possible enhancements:
Reimplemented from llvm::TargetFrameLowering.
Definition at line 4463 of file X86FrameLowering.cpp.
References llvm::MachineBasicBlock::begin(), DefMI, FP, llvm::MachineInstr::FrameDestroy, llvm::MachineInstr::FrameSetup, llvm::X86RegisterInfo::getBaseRegister(), llvm::X86MachineFunctionInfo::getBPClobberedByCall(), llvm::MachineBasicBlock::getFirstTerminator(), llvm::X86MachineFunctionInfo::getFPClobberedByCall(), llvm::TargetSubtargetInfo::getFrameLowering(), llvm::X86RegisterInfo::getFrameRegister(), llvm::MachineFunction::getInfo(), llvm::TargetSubtargetInfo::getInstrInfo(), llvm::MachineFunction::getSubtarget(), llvm::X86RegisterInfo::hasBasePointer(), llvm::TargetFrameLowering::hasFP(), llvm::MachineFunction::hasInlineAsm(), isFPBPAccess(), isInvoke(), MBB, MI, llvm::MachineBasicBlock::rbegin(), llvm::MachineBasicBlock::rend(), TII, and TRI.
|
overridevirtual |
Does the stack probe function call return with a modified stack pointer?
Reimplemented from llvm::TargetFrameLowering.
Definition at line 621 of file X86FrameLowering.cpp.
References llvm::X86Subtarget::isOSWindows(), llvm::X86Subtarget::isTargetWin64(), and STI.
bool llvm::X86FrameLowering::Is64Bit |
Is64Bit implies that x86_64 instructions are available.
Definition at line 41 of file X86FrameLowering.h.
Referenced by adjustForHiPEPrologue(), adjustForSegmentedStacks(), llvm::X86RegisterInfo::eliminateFrameIndex(), emitCalleeSavedFrameMovesFullCFA(), emitEpilogue(), emitPrologue(), emitSPUpdate(), has128ByteRedZone(), and X86FrameLowering().
bool llvm::X86FrameLowering::IsLP64 |
Definition at line 43 of file X86FrameLowering.h.
Referenced by adjustForHiPEPrologue(), adjustForSegmentedStacks(), and X86FrameLowering().
unsigned llvm::X86FrameLowering::SlotSize |
Definition at line 38 of file X86FrameLowering.h.
Referenced by adjustForHiPEPrologue(), assignCalleeSavedSpillSlots(), emitCalleeSavedFrameMoves(), emitEpilogue(), emitPrologue(), emitSPUpdate(), getFrameIndexReference(), getWinEHParentFrameOffset(), processFunctionBeforeFrameFinalized(), restoreCalleeSavedRegisters(), spillCalleeSavedRegisters(), and X86FrameLowering().
unsigned llvm::X86FrameLowering::StackPtr |
Definition at line 50 of file X86FrameLowering.h.
Referenced by emitEpilogue(), emitPrologue(), emitSPUpdate(), getInitialCFARegister(), mergeSPUpdates(), and X86FrameLowering().
const X86Subtarget& llvm::X86FrameLowering::STI |
Definition at line 34 of file X86FrameLowering.h.
Referenced by adjustForHiPEPrologue(), adjustForSegmentedStacks(), assignCalleeSavedSpillSlots(), canUseAsEpilogue(), canUseAsPrologue(), determineCalleeSaves(), emitCalleeSavedFrameMoves(), emitCalleeSavedFrameMovesFullCFA(), emitEpilogue(), emitPrologue(), emitSPUpdate(), emitStackProbe(), getFrameIndexReferencePreferSP(), has128ByteRedZone(), processFunctionBeforeFrameFinalized(), processFunctionBeforeFrameIndicesReplaced(), restoreCalleeSavedRegisters(), restoreWin32EHStackPointers(), spillCalleeSavedRegisters(), stackProbeFunctionModifiesSP(), and X86FrameLowering().
const X86InstrInfo& llvm::X86FrameLowering::TII |
Definition at line 35 of file X86FrameLowering.h.
Referenced by adjustForHiPEPrologue(), adjustForSegmentedStacks(), BuildCFI(), eliminateCallFramePseudoInstr(), emitEpilogue(), emitPrologue(), emitSPUpdate(), emitStackProbe(), restoreCalleeSavedRegisters(), restoreWin32EHStackPointers(), spillCalleeSavedRegisters(), and spillFPBP().
const X86RegisterInfo* llvm::X86FrameLowering::TRI |
Definition at line 36 of file X86FrameLowering.h.
Referenced by assignCalleeSavedSpillSlots(), canSimplifyCallFramePseudos(), canUseAsPrologue(), determineCalleeSaves(), emitCalleeSavedFrameMoves(), emitCalleeSavedFrameMovesFullCFA(), emitEpilogue(), emitPrologue(), emitSPUpdate(), getFrameIndexReference(), getFrameIndexReferencePreferSP(), getFrameIndexReferenceSP(), getInitialCFAOffset(), getWin64EHFrameIndexRef(), hasFP(), orderFrameObjects(), restoreCalleeSavedRegisters(), restoreWin32EHStackPointers(), spillCalleeSavedRegisters(), spillFPBP(), and X86FrameLowering().
bool llvm::X86FrameLowering::Uses64BitFramePtr |
True if the 64-bit frame or stack pointer should be used.
True for most 64-bit targets with the exception of x32. If this is false, 32-bit instruction operands should be used to manipulate StackPtr and FramePtr.
Definition at line 48 of file X86FrameLowering.h.
Referenced by emitCalleeSavedFrameMovesFullCFA(), emitEpilogue(), emitPrologue(), llvm::X86RegisterInfo::getPointerRegClass(), restoreWin32EHStackPointers(), and X86FrameLowering().