LLVM  4.0.0
Macros | Typedefs | Functions | Variables
PrologEpilogInserter.cpp File Reference
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/CodeGen/MachineDominators.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineLoopInfo.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/RegisterScavenging.h"
#include "llvm/CodeGen/StackProtector.h"
#include "llvm/CodeGen/WinEHFuncInfo.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/InlineAsm.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetFrameLowering.h"
#include "llvm/Target/TargetInstrInfo.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetRegisterInfo.h"
#include "llvm/Target/TargetSubtargetInfo.h"
#include <climits>
Include dependency graph for PrologEpilogInserter.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "pei"
 

Typedefs

typedef SmallVector
< MachineBasicBlock *, 4 > 
MBBVector
 
typedef SmallSetVector< int, 8 > StackObjSet
 StackObjSet - A set of stack object indexes. More...
 

Functions

static void doSpillCalleeSavedRegs (MachineFunction &MF, RegScavenger *RS, unsigned &MinCSFrameIndex, unsigned &MaxCXFrameIndex, const MBBVector &SaveBlocks, const MBBVector &RestoreBlocks)
 
static void doScavengeFrameVirtualRegs (MachineFunction &MF, RegScavenger *RS)
 doScavengeFrameVirtualRegs - Replace all frame index virtual registers with physical registers. More...
 
 INITIALIZE_TM_PASS_BEGIN (PEI,"prologepilog","Prologue/Epilogue Insertion", false, false) INITIALIZE_TM_PASS_END(PEI
 
 STATISTIC (NumScavengedRegs,"Number of frame index regs scavenged")
 
 STATISTIC (NumBytesStackSpace,"Number of bytes used for stack in all functions")
 
static void assignCalleeSavedSpillSlots (MachineFunction &F, const BitVector &SavedRegs, unsigned &MinCSFrameIndex, unsigned &MaxCSFrameIndex)
 
static void updateLiveness (MachineFunction &MF)
 Helper function to update the liveness information for the callee-saved registers. More...
 
static void insertCSRSpillsAndRestores (MachineFunction &Fn, const MBBVector &SaveBlocks, const MBBVector &RestoreBlocks)
 insertCSRSpillsAndRestores - Insert spill and restore code for callee saved registers used in the function. More...
 
static void AdjustStackOffset (MachineFrameInfo &MFI, int FrameIdx, bool StackGrowsDown, int64_t &Offset, unsigned &MaxAlign, unsigned Skew)
 AdjustStackOffset - Helper function used to adjust the stack frame offset. More...
 
static void computeFreeStackSlots (MachineFrameInfo &MFI, bool StackGrowsDown, unsigned MinCSFrameIndex, unsigned MaxCSFrameIndex, int64_t FixedCSEnd, BitVector &StackBytesFree)
 Compute which bytes of fixed and callee-save stack area are unused and keep track of them in StackBytesFree. More...
 
static bool scavengeStackSlot (MachineFrameInfo &MFI, int FrameIdx, bool StackGrowsDown, unsigned MaxAlign, BitVector &StackBytesFree)
 Assign frame object to an unused portion of the stack in the fixed stack object range. More...
 
static void AssignProtectedObjSet (const StackObjSet &UnassignedObjs, SmallSet< int, 16 > &ProtectedObjs, MachineFrameInfo &MFI, bool StackGrowsDown, int64_t &Offset, unsigned &MaxAlign, unsigned Skew)
 AssignProtectedObjSet - Helper function to assign large stack objects (i.e., those required to be close to the Stack Protector) to stack offsets. More...
 

Variables

static cl::opt< unsignedWarnStackSize ("warn-stack-size", cl::Hidden, cl::init((unsigned)-1), cl::desc("Warn for stack size bigger than the given"" number"))
 
 prologepilog
 
Prologue Epilogue Insertion &Frame Finalization
 
Prologue Epilogue Insertion &Frame false
 

Macro Definition Documentation

#define DEBUG_TYPE   "pei"

Definition at line 48 of file PrologEpilogInserter.cpp.

Typedef Documentation

Definition at line 50 of file PrologEpilogInserter.cpp.

typedef SmallSetVector<int, 8> StackObjSet

StackObjSet - A set of stack object indexes.

Definition at line 171 of file PrologEpilogInserter.cpp.

Function Documentation

static void AdjustStackOffset ( MachineFrameInfo MFI,
int  FrameIdx,
bool  StackGrowsDown,
int64_t &  Offset,
unsigned MaxAlign,
unsigned  Skew 
)
inlinestatic

AdjustStackOffset - Helper function used to adjust the stack frame offset.

Definition at line 560 of file PrologEpilogInserter.cpp.

References llvm::alignTo(), llvm::dbgs(), DEBUG, llvm::MachineFrameInfo::getObjectAlignment(), llvm::MachineFrameInfo::getObjectSize(), and llvm::MachineFrameInfo::setObjectOffset().

Referenced by AssignProtectedObjSet().

static void assignCalleeSavedSpillSlots ( MachineFunction F,
const BitVector SavedRegs,
unsigned MinCSFrameIndex,
unsigned MaxCSFrameIndex 
)
static
static void AssignProtectedObjSet ( const StackObjSet UnassignedObjs,
SmallSet< int, 16 > &  ProtectedObjs,
MachineFrameInfo MFI,
bool  StackGrowsDown,
int64_t &  Offset,
unsigned MaxAlign,
unsigned  Skew 
)
static

AssignProtectedObjSet - Helper function to assign large stack objects (i.e., those required to be close to the Stack Protector) to stack offsets.

Definition at line 691 of file PrologEpilogInserter.cpp.

References AdjustStackOffset(), llvm::SetVector< T, Vector, Set >::begin(), E, llvm::SetVector< T, Vector, Set >::end(), I, i, and llvm::SmallSet< T, N, C >::insert().

static void computeFreeStackSlots ( MachineFrameInfo MFI,
bool  StackGrowsDown,
unsigned  MinCSFrameIndex,
unsigned  MaxCSFrameIndex,
int64_t  FixedCSEnd,
BitVector StackBytesFree 
)
inlinestatic
static void doScavengeFrameVirtualRegs ( MachineFunction MF,
RegScavenger RS 
)
static

doScavengeFrameVirtualRegs - Replace all frame index virtual registers with physical registers.

Use the register scavenger to find an appropriate register to use.

FIXME: Iterating over the instruction stream is unnecessary. We can simply iterate over the vreg use list, which at this point only contains machine operands for which eliminateFrameIndex need a new scratch reg.

Definition at line 1163 of file PrologEpilogInserter.cpp.

References assert(), llvm::MachineBasicBlock::begin(), llvm::MachineBasicBlock::end(), llvm::RegScavenger::enterBasicBlock(), llvm::RegScavenger::forward(), llvm::RegScavenger::getCurrentPosition(), llvm::MachineRegisterInfo::getRegClass(), llvm::MachineFunction::getRegInfo(), I, llvm::TargetRegisterInfo::isVirtualRegister(), MBB, MRI, llvm::MachineInstr::operands(), P, llvm::MachineRegisterInfo::replaceRegWith(), llvm::RegScavenger::scavengeRegister(), llvm::RegScavenger::setRegUsed(), llvm::MachineBasicBlock::splice(), and llvm::RegScavenger::unprocess().

static void doSpillCalleeSavedRegs ( MachineFunction MF,
RegScavenger RS,
unsigned MinCSFrameIndex,
unsigned MaxCXFrameIndex,
const MBBVector SaveBlocks,
const MBBVector RestoreBlocks 
)
static
INITIALIZE_TM_PASS_BEGIN ( PEI  ,
"prologepilog"  ,
"Prologue/Epilogue Insertion"  ,
false  ,
false   
)
static void insertCSRSpillsAndRestores ( MachineFunction Fn,
const MBBVector SaveBlocks,
const MBBVector RestoreBlocks 
)
static
static bool scavengeStackSlot ( MachineFrameInfo MFI,
int  FrameIdx,
bool  StackGrowsDown,
unsigned  MaxAlign,
BitVector StackBytesFree 
)
inlinestatic
STATISTIC ( NumScavengedRegs  ,
"Number of frame index regs scavenged"   
)
STATISTIC ( NumBytesStackSpace  ,
"Number of bytes used for stack in all functions  
)
static void updateLiveness ( MachineFunction MF)
static

Variable Documentation

Prologue Epilogue Insertion& Frame false

Definition at line 148 of file PrologEpilogInserter.cpp.

Prologue Epilogue Insertion& Frame Finalization

Definition at line 148 of file PrologEpilogInserter.cpp.

prologepilog

Definition at line 148 of file PrologEpilogInserter.cpp.

cl::opt<unsigned> WarnStackSize("warn-stack-size", cl::Hidden, cl::init((unsigned)-1), cl::desc("Warn for stack size bigger than the given"" number"))
static