LLVM 20.0.0git
Public Member Functions | Public Attributes | List of all members
llvm::X86FrameLowering Class Reference

#include "Target/X86/X86FrameLowering.h"

Inheritance diagram for llvm::X86FrameLowering:
Inheritance graph
[legend]

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 SpillSlotgetCalleeSavedSpillSlots (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 X86SubtargetSTI
 
const X86InstrInfoTII
 
const X86RegisterInfoTRI
 
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.
 

Detailed Description

Definition at line 28 of file X86FrameLowering.h.

Constructor & Destructor Documentation

◆ X86FrameLowering()

X86FrameLowering::X86FrameLowering ( const X86Subtarget STI,
MaybeAlign  StackAlignOverride 
)

Member Function Documentation

◆ adjustForHiPEPrologue()

void X86FrameLowering::adjustForHiPEPrologue ( MachineFunction MF,
MachineBasicBlock PrologueMBB 
) const
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().

◆ adjustForSegmentedStacks()

void X86FrameLowering::adjustForSegmentedStacks ( MachineFunction MF,
MachineBasicBlock PrologueMBB 
) const
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().

◆ assignCalleeSavedSpillSlots()

bool X86FrameLowering::assignCalleeSavedSpillSlots ( MachineFunction MF,
const TargetRegisterInfo TRI,
std::vector< CalleeSavedInfo > &  CSI 
) const
overridevirtual

◆ BuildCFI()

void X86FrameLowering::BuildCFI ( MachineBasicBlock MBB,
MachineBasicBlock::iterator  MBBI,
const DebugLoc DL,
const MCCFIInstruction CFIInst,
MachineInstr::MIFlag  Flag = MachineInstr::NoFlags 
) const

◆ canSimplifyCallFramePseudos()

bool X86FrameLowering::canSimplifyCallFramePseudos ( const MachineFunction MF) const
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.

◆ canUseAsEpilogue()

bool X86FrameLowering::canUseAsEpilogue ( const MachineBasicBlock MBB) const
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().

◆ canUseAsPrologue()

bool X86FrameLowering::canUseAsPrologue ( const MachineBasicBlock MBB) const
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.

◆ canUseLEAForSPInEpilogue()

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().

◆ determineCalleeSaves()

void X86FrameLowering::determineCalleeSaves ( MachineFunction MF,
BitVector SavedRegs,
RegScavenger RS = nullptr 
) const
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.

◆ eliminateCallFramePseudoInstr()

MachineBasicBlock::iterator X86FrameLowering::eliminateCallFramePseudoInstr ( MachineFunction MF,
MachineBasicBlock MBB,
MachineBasicBlock::iterator  MI 
) const
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().

◆ emitCalleeSavedFrameMoves()

void X86FrameLowering::emitCalleeSavedFrameMoves ( MachineBasicBlock MBB,
MachineBasicBlock::iterator  MBBI,
const DebugLoc DL,
bool  IsPrologue 
) const

◆ emitCalleeSavedFrameMovesFullCFA()

void X86FrameLowering::emitCalleeSavedFrameMovesFullCFA ( MachineBasicBlock MBB,
MachineBasicBlock::iterator  MBBI 
) const
overridevirtual

◆ emitEpilogue()

void X86FrameLowering::emitEpilogue ( MachineFunction MF,
MachineBasicBlock MBB 
) const
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().

◆ emitPrologue()

void X86FrameLowering::emitPrologue ( MachineFunction MF,
MachineBasicBlock MBB 
) const
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.

◆ emitSPUpdate()

void X86FrameLowering::emitSPUpdate ( MachineBasicBlock MBB,
MachineBasicBlock::iterator MBBI,
const DebugLoc DL,
int64_t  NumBytes,
bool  InEpilogue 
) const

◆ emitStackProbe()

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().

◆ enableShrinkWrapping()

bool X86FrameLowering::enableShrinkWrapping ( const MachineFunction MF) const
overridevirtual

◆ getDwarfFrameBase()

TargetFrameLowering::DwarfFrameBase X86FrameLowering::getDwarfFrameBase ( const MachineFunction MF) const
overridevirtual

◆ getFrameIndexReference()

StackOffset X86FrameLowering::getFrameIndexReference ( const MachineFunction MF,
int  FI,
Register FrameReg 
) const
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().

◆ getFrameIndexReferencePreferSP()

StackOffset X86FrameLowering::getFrameIndexReferencePreferSP ( const MachineFunction MF,
int  FI,
Register FrameReg,
bool  IgnoreSPUpdates 
) const
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.

◆ getFrameIndexReferenceSP()

StackOffset X86FrameLowering::getFrameIndexReferenceSP ( const MachineFunction MF,
int  FI,
Register SPReg,
int  Adjustment 
) const

◆ getInitialCFAOffset()

int X86FrameLowering::getInitialCFAOffset ( const MachineFunction MF) const
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().

◆ getInitialCFARegister()

Register X86FrameLowering::getInitialCFARegister ( const MachineFunction MF) const
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().

◆ getWin64EHFrameIndexRef()

int X86FrameLowering::getWin64EHFrameIndexRef ( const MachineFunction MF,
int  FI,
Register SPReg 
) const

◆ getWinEHParentFrameOffset()

unsigned X86FrameLowering::getWinEHParentFrameOffset ( const MachineFunction MF) const
overridevirtual

Reimplemented from llvm::TargetFrameLowering.

Definition at line 4126 of file X86FrameLowering.cpp.

References llvm::MachineFunction::getInfo(), llvm::Offset, and SlotSize.

◆ has128ByteRedZone()

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().

◆ hasFP()

bool X86FrameLowering::hasFP ( const MachineFunction MF) const
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().

◆ hasReservedCallFrame()

bool X86FrameLowering::hasReservedCallFrame ( const MachineFunction MF) const
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().

◆ inlineStackProbe()

void X86FrameLowering::inlineStackProbe ( MachineFunction MF,
MachineBasicBlock PrologMBB 
) const
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.

◆ mergeSPUpdates()

int X86FrameLowering::mergeSPUpdates ( MachineBasicBlock MBB,
MachineBasicBlock::iterator MBBI,
bool  doMergeWithPrevious 
) const

◆ needsFrameIndexResolution()

bool X86FrameLowering::needsFrameIndexResolution ( const MachineFunction MF) const
overridevirtual

◆ orderFrameObjects()

void X86FrameLowering::orderFrameObjects ( const MachineFunction MF,
SmallVectorImpl< int > &  ObjectsToAllocate 
) const
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.

◆ processFunctionBeforeFrameFinalized()

void X86FrameLowering::processFunctionBeforeFrameFinalized ( MachineFunction MF,
RegScavenger RS 
) const
overridevirtual

◆ processFunctionBeforeFrameIndicesReplaced()

void X86FrameLowering::processFunctionBeforeFrameIndicesReplaced ( MachineFunction MF,
RegScavenger RS 
) const
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.

◆ restoreCalleeSavedRegisters()

bool X86FrameLowering::restoreCalleeSavedRegisters ( MachineBasicBlock MBB,
MachineBasicBlock::iterator  MI,
MutableArrayRef< CalleeSavedInfo CSI,
const TargetRegisterInfo TRI 
) const
overridevirtual

◆ restoreWin32EHStackPointers()

MachineBasicBlock::iterator X86FrameLowering::restoreWin32EHStackPointers ( MachineBasicBlock MBB,
MachineBasicBlock::iterator  MBBI,
const DebugLoc DL,
bool  RestoreSP = false 
) const

◆ restoreWinEHStackPointersInParent()

void X86FrameLowering::restoreWinEHStackPointersInParent ( MachineFunction MF) const

◆ spillCalleeSavedRegisters()

bool X86FrameLowering::spillCalleeSavedRegisters ( MachineBasicBlock MBB,
MachineBasicBlock::iterator  MI,
ArrayRef< CalleeSavedInfo CSI,
const TargetRegisterInfo TRI 
) const
overridevirtual

◆ spillFPBP()

void X86FrameLowering::spillFPBP ( MachineFunction MF) const
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:

  1. In many cases there are different physical registers not clobbered by inline asm, we can use one of them as base pointer. Or use a virtual register as base pointer and let RA allocate a physical register to it.
  2. If there is no other instructions access stack with fp/bp from the inline asm to the epilog, and no cfi requirement for a correct fp, we can skip the save and restore operations.

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.

◆ stackProbeFunctionModifiesSP()

bool X86FrameLowering::stackProbeFunctionModifiesSP ( ) const
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.

Member Data Documentation

◆ Is64Bit

bool llvm::X86FrameLowering::Is64Bit

◆ IsLP64

bool llvm::X86FrameLowering::IsLP64

◆ SlotSize

unsigned llvm::X86FrameLowering::SlotSize

◆ StackPtr

unsigned llvm::X86FrameLowering::StackPtr

◆ STI

const X86Subtarget& llvm::X86FrameLowering::STI

◆ TII

const X86InstrInfo& llvm::X86FrameLowering::TII

◆ TRI

const X86RegisterInfo* llvm::X86FrameLowering::TRI

◆ Uses64BitFramePtr

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().


The documentation for this class was generated from the following files: