LLVM  10.0.0
Macros | Functions | Variables
AArch64FrameLowering.cpp File Reference
#include "AArch64FrameLowering.h"
#include "AArch64InstrInfo.h"
#include "AArch64MachineFunctionInfo.h"
#include "AArch64RegisterInfo.h"
#include "AArch64StackOffset.h"
#include "AArch64Subtarget.h"
#include "AArch64TargetMachine.h"
#include "MCTargetDesc/AArch64AddressingModes.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/CodeGen/LivePhysRegs.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineMemOperand.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/RegisterScavenging.h"
#include "llvm/CodeGen/TargetInstrInfo.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/CodeGen/WinEHFuncInfo.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/CallingConv.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/IR/Function.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCDwarf.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
#include <cassert>
#include <cstdint>
#include <iterator>
#include <vector>
Include dependency graph for AArch64FrameLowering.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "frame-info"
 

Functions

 STATISTIC (NumRedZoneFunctions, "Number of functions using red zone")
 
static unsigned estimateRSStackSizeLimit (MachineFunction &MF)
 Look at each instruction that references stack frames and return the stack size limit beyond which some of these instructions will require a scratch register during their expansion later. More...
 
static StackOffset getSVEStackSize (const MachineFunction &MF)
 Returns the size of the entire SVE stackframe (calleesaves + spills). More...
 
static bool ShouldSignReturnAddress (MachineFunction &MF)
 
static unsigned findScratchNonCalleeSaveRegister (MachineBasicBlock *MBB)
 
static bool windowsRequiresStackProbe (MachineFunction &MF, uint64_t StackSizeInBytes)
 
static MachineBasicBlock::iterator InsertSEH (MachineBasicBlock::iterator MBBI, const TargetInstrInfo &TII, MachineInstr::MIFlag Flag)
 
static void fixupSEHOpcode (MachineBasicBlock::iterator MBBI, unsigned LocalStackSize)
 
static MachineBasicBlock::iterator convertCalleeSaveRestoreToSPPrePostIncDec (MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, const TargetInstrInfo *TII, int CSStackSizeInc, bool NeedsWinCFI, bool *HasWinCFI, bool InProlog=true)
 
static void fixupCalleeSaveRestoreStackOffset (MachineInstr &MI, uint64_t LocalStackSize, bool NeedsWinCFI, bool *HasWinCFI)
 
static void adaptForLdStOpt (MachineBasicBlock &MBB, MachineBasicBlock::iterator FirstSPPopI, MachineBasicBlock::iterator LastPopI)
 
static bool ShouldSignWithAKey (MachineFunction &MF)
 
static bool needsWinCFI (const MachineFunction &MF)
 
static bool isTargetDarwin (const MachineFunction &MF)
 
static bool isTargetWindows (const MachineFunction &MF)
 
static bool IsSVECalleeSave (MachineBasicBlock::iterator I)
 
static void InsertReturnAddressAuth (MachineFunction &MF, MachineBasicBlock &MBB)
 
static bool isFuncletReturnInstr (const MachineInstr &MI)
 
static StackOffset getFPOffset (const MachineFunction &MF, int64_t ObjectOffset)
 
static StackOffset getStackOffset (const MachineFunction &MF, int64_t ObjectOffset)
 
static unsigned getPrologueDeath (MachineFunction &MF, unsigned Reg)
 
static bool produceCompactUnwindFrame (MachineFunction &MF)
 
static bool invalidateWindowsRegisterPairing (unsigned Reg1, unsigned Reg2, bool NeedsWinCFI)
 
static bool invalidateRegisterPairing (unsigned Reg1, unsigned Reg2, bool UsesWinAAPCS, bool NeedsWinCFI, bool NeedsFrameRecord)
 Returns true if Reg1 and Reg2 cannot be paired using a ldp/stp instruction. More...
 
static void computeCalleeSaveRegisterPairs (MachineFunction &MF, const std::vector< CalleeSavedInfo > &CSI, const TargetRegisterInfo *TRI, SmallVectorImpl< RegPairInfo > &RegPairs, bool &NeedShadowCallStackProlog, bool NeedsFrameRecord)
 
static bool getSVECalleeSaveSlotRange (const MachineFrameInfo &MFI, int &Min, int &Max)
 returns true if there are any SVE callee saves. More...
 
static int64_t determineSVEStackObjectOffsets (MachineFrameInfo &MFI, int &MinCSFrameIndex, int &MaxCSFrameIndex, bool AssignOffsets)
 

Variables

static cl::opt< bool > EnableRedZone ("aarch64-redzone", cl::desc("enable use of redzone on AArch64"), cl::init(false), cl::Hidden)
 
static cl::opt< bool > ReverseCSRRestoreSeq ("reverse-csr-restore-seq", cl::desc("reverse the CSR restore sequence"), cl::init(false), cl::Hidden)
 
static const unsigned DefaultSafeSPDisplacement = 255
 This is the biggest offset to the stack pointer we can encode in aarch64 instructions (without using a separate calculation and a temp register). More...
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "frame-info"

Definition at line 162 of file AArch64FrameLowering.cpp.

Function Documentation

◆ adaptForLdStOpt()

static void adaptForLdStOpt ( MachineBasicBlock &  MBB,
MachineBasicBlock::iterator  FirstSPPopI,
MachineBasicBlock::iterator  LastPopI 
)
static

◆ computeCalleeSaveRegisterPairs()

static void computeCalleeSaveRegisterPairs ( MachineFunction &  MF,
const std::vector< CalleeSavedInfo > &  CSI,
const TargetRegisterInfo *  TRI,
SmallVectorImpl< RegPairInfo > &  RegPairs,
bool &  NeedShadowCallStackProlog,
bool  NeedsFrameRecord 
)
static

◆ convertCalleeSaveRestoreToSPPrePostIncDec()

static MachineBasicBlock::iterator convertCalleeSaveRestoreToSPPrePostIncDec ( MachineBasicBlock &  MBB,
MachineBasicBlock::iterator  MBBI,
const DebugLoc &  DL,
const TargetInstrInfo *  TII,
int  CSStackSizeInc,
bool  NeedsWinCFI,
bool *  HasWinCFI,
bool  InProlog = true 
)
static

◆ determineSVEStackObjectOffsets()

static int64_t determineSVEStackObjectOffsets ( MachineFrameInfo &  MFI,
int &  MinCSFrameIndex,
int &  MaxCSFrameIndex,
bool  AssignOffsets 
)
static

◆ estimateRSStackSizeLimit()

static unsigned estimateRSStackSizeLimit ( MachineFunction &  MF)
static

Look at each instruction that references stack frames and return the stack size limit beyond which some of these instructions will require a scratch register during their expansion later.

Definition at line 184 of file AArch64FrameLowering.cpp.

References llvm::AArch64FrameOffsetCannotUpdate, DefaultSafeSPDisplacement, llvm::isAArch64FrameOffsetLegal(), and MI.

Referenced by llvm::AArch64FrameLowering::determineCalleeSaves().

◆ findScratchNonCalleeSaveRegister()

static unsigned findScratchNonCalleeSaveRegister ( MachineBasicBlock *  MBB)
static

◆ fixupCalleeSaveRestoreStackOffset()

static void fixupCalleeSaveRestoreStackOffset ( MachineInstr &  MI,
uint64_t  LocalStackSize,
bool  NeedsWinCFI,
bool *  HasWinCFI 
)
static

◆ fixupSEHOpcode()

static void fixupSEHOpcode ( MachineBasicBlock::iterator  MBBI,
unsigned  LocalStackSize 
)
static

◆ getFPOffset()

static StackOffset getFPOffset ( const MachineFunction &  MF,
int64_t  ObjectOffset 
)
static

◆ getPrologueDeath()

static unsigned getPrologueDeath ( MachineFunction &  MF,
unsigned  Reg 
)
static

◆ getStackOffset()

static StackOffset getStackOffset ( const MachineFunction &  MF,
int64_t  ObjectOffset 
)
static

◆ getSVECalleeSaveSlotRange()

static bool getSVECalleeSaveSlotRange ( const MachineFrameInfo &  MFI,
int &  Min,
int &  Max 
)
static

◆ getSVEStackSize()

static StackOffset getSVEStackSize ( const MachineFunction &  MF)
static

◆ InsertReturnAddressAuth()

static void InsertReturnAddressAuth ( MachineFunction &  MF,
MachineBasicBlock &  MBB 
)
static

◆ InsertSEH()

◆ invalidateRegisterPairing()

static bool invalidateRegisterPairing ( unsigned  Reg1,
unsigned  Reg2,
bool  UsesWinAAPCS,
bool  NeedsWinCFI,
bool  NeedsFrameRecord 
)
static

Returns true if Reg1 and Reg2 cannot be paired using a ldp/stp instruction.

WindowsCFI requires that only consecutive registers can be paired. LR and FP need to be allocated together when the frame needs to save the frame-record. This means any other register pairing with LR is invalid.

Definition at line 1890 of file AArch64FrameLowering.cpp.

References llvm::GPR, invalidateWindowsRegisterPairing(), and llvm_unreachable.

Referenced by computeCalleeSaveRegisterPairs().

◆ invalidateWindowsRegisterPairing()

static bool invalidateWindowsRegisterPairing ( unsigned  Reg1,
unsigned  Reg2,
bool  NeedsWinCFI 
)
static

◆ isFuncletReturnInstr()

static bool isFuncletReturnInstr ( const MachineInstr &  MI)
static

◆ IsSVECalleeSave()

static bool IsSVECalleeSave ( MachineBasicBlock::iterator  I)
static

◆ isTargetDarwin()

static bool isTargetDarwin ( const MachineFunction &  MF)
static

◆ isTargetWindows()

static bool isTargetWindows ( const MachineFunction &  MF)
static

◆ needsWinCFI()

static bool needsWinCFI ( const MachineFunction &  MF)
static

◆ produceCompactUnwindFrame()

static bool produceCompactUnwindFrame ( MachineFunction &  MF)
static

◆ ShouldSignReturnAddress()

static bool ShouldSignReturnAddress ( MachineFunction &  MF)
static

◆ ShouldSignWithAKey()

static bool ShouldSignWithAKey ( MachineFunction &  MF)
static

◆ STATISTIC()

STATISTIC ( NumRedZoneFunctions  ,
"Number of functions using red zone"   
)

◆ windowsRequiresStackProbe()

static bool windowsRequiresStackProbe ( MachineFunction &  MF,
uint64_t  StackSizeInBytes 
)
static

Variable Documentation

◆ DefaultSafeSPDisplacement

const unsigned DefaultSafeSPDisplacement = 255
static

This is the biggest offset to the stack pointer we can encode in aarch64 instructions (without using a separate calculation and a temp register).

Note that the exception here are vector stores/loads which cannot encode any displacements (see estimateRSStackSizeLimit(), isAArch64FrameOffsetLegal()).

Definition at line 179 of file AArch64FrameLowering.cpp.

Referenced by estimateRSStackSizeLimit(), and llvm::AArch64FrameLowering::hasFP().

◆ EnableRedZone

cl::opt<bool> EnableRedZone("aarch64-redzone", cl::desc("enable use of redzone on AArch64"), cl::init(false), cl::Hidden)
static

◆ ReverseCSRRestoreSeq

cl::opt<bool> ReverseCSRRestoreSeq("reverse-csr-restore-seq", cl::desc("reverse the CSR restore sequence"), cl::init(false), cl::Hidden)
static