LLVM 20.0.0git
|
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineDominators.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineLoopInfo.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/MachineOptimizationRemarkEmitter.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/RegisterScavenging.h"
#include "llvm/CodeGen/TargetFrameLowering.h"
#include "llvm/CodeGen/TargetInstrInfo.h"
#include "llvm/CodeGen/TargetOpcodes.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/DebugInfoMetadata.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <limits>
#include <utility>
#include <vector>
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "prologepilog" |
Typedefs | |
using | MBBVector = SmallVector< MachineBasicBlock *, 4 > |
using | StackObjSet = SmallSetVector< int, 8 > |
StackObjSet - A set of stack object indexes. | |
using | SavedDbgValuesMap = SmallDenseMap< MachineBasicBlock *, SmallVector< MachineInstr *, 4 >, 4 > |
Functions | |
STATISTIC (NumLeafFuncWithSpills, "Number of leaf functions with CSRs") | |
STATISTIC (NumFuncSeen, "Number of functions seen in PEI") | |
INITIALIZE_PASS_BEGIN (PEI, DEBUG_TYPE, "Prologue/Epilogue Insertion", false, false) INITIALIZE_PASS_END(PEI | |
STATISTIC (NumBytesStackSpace, "Number of bytes used for stack in all functions") | |
static void | stashEntryDbgValues (MachineBasicBlock &MBB, SavedDbgValuesMap &EntryDbgValues) |
Stash DBG_VALUEs that describe parameters and which are placed at the start of the block. | |
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. | |
static void | insertCSRSaves (MachineBasicBlock &SaveBlock, ArrayRef< CalleeSavedInfo > CSI) |
Insert spill code for the callee-saved registers used in the function. | |
static void | insertCSRRestores (MachineBasicBlock &RestoreBlock, std::vector< CalleeSavedInfo > &CSI) |
Insert restore code for the callee-saved registers used in the function. | |
static void | AdjustStackOffset (MachineFrameInfo &MFI, int FrameIdx, bool StackGrowsDown, int64_t &Offset, Align &MaxAlign) |
AdjustStackOffset - Helper function used to adjust the stack frame offset. | |
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. | |
static bool | scavengeStackSlot (MachineFrameInfo &MFI, int FrameIdx, bool StackGrowsDown, Align MaxAlign, BitVector &StackBytesFree) |
Assign frame object to an unused portion of the stack in the fixed stack object range. | |
static void | AssignProtectedObjSet (const StackObjSet &UnassignedObjs, SmallSet< int, 16 > &ProtectedObjs, MachineFrameInfo &MFI, bool StackGrowsDown, int64_t &Offset, Align &MaxAlign) |
AssignProtectedObjSet - Helper function to assign large stack objects (i.e., those required to be close to the Stack Protector) to stack offsets. | |
Variables | |
DEBUG_TYPE | |
Prologue Epilogue Insertion &Frame | Finalization |
Prologue Epilogue Insertion &Frame | false |
#define DEBUG_TYPE "prologepilog" |
Definition at line 70 of file PrologEpilogInserter.cpp.
using MBBVector = SmallVector<MachineBasicBlock *, 4> |
Definition at line 72 of file PrologEpilogInserter.cpp.
using SavedDbgValuesMap = SmallDenseMap<MachineBasicBlock *, SmallVector<MachineInstr *, 4>, 4> |
Definition at line 175 of file PrologEpilogInserter.cpp.
using StackObjSet = SmallSetVector<int, 8> |
StackObjSet - A set of stack object indexes.
Definition at line 173 of file PrologEpilogInserter.cpp.
|
inlinestatic |
AdjustStackOffset - Helper function used to adjust the stack frame offset.
Definition at line 698 of file PrologEpilogInserter.cpp.
References llvm::alignTo(), llvm::dbgs(), llvm::MachineFrameInfo::getObjectAlign(), llvm::MachineFrameInfo::getObjectSize(), LLVM_DEBUG, llvm::Offset, and llvm::MachineFrameInfo::setObjectOffset().
Referenced by AssignProtectedObjSet().
|
static |
Definition at line 430 of file PrologEpilogInserter.cpp.
References llvm::TargetFrameLowering::assignCalleeSavedSpillSlots(), llvm::MachineFrameInfo::CreateFixedSpillStackObject(), llvm::MachineFrameInfo::CreateStackObject(), llvm::BitVector::empty(), F, llvm::TargetFrameLowering::getCalleeSavedSpillSlots(), llvm::TargetFrameLowering::getStackAlign(), llvm::TargetFrameLowering::SpillSlot::Offset, llvm::TargetFrameLowering::SpillSlot::Reg, llvm::BitVector::set(), llvm::MachineFrameInfo::setCalleeSavedInfo(), llvm::BitVector::size(), Size, and llvm::BitVector::test().
|
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 833 of file PrologEpilogInserter.cpp.
References AdjustStackOffset(), llvm::SmallSet< T, N, C >::insert(), and llvm::Offset.
|
inlinestatic |
Compute which bytes of fixed and callee-save stack area are unused and keep track of them in StackBytesFree.
Definition at line 729 of file PrologEpilogInserter.cpp.
References llvm::TargetStackID::Default, llvm::MachineFrameInfo::getObjectIndexBegin(), llvm::MachineFrameInfo::getObjectOffset(), llvm::MachineFrameInfo::getObjectSize(), llvm::MachineFrameInfo::getStackID(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::BitVector::reset(), and llvm::BitVector::resize().
INITIALIZE_PASS_BEGIN | ( | PEI | , |
DEBUG_TYPE | , | ||
"Prologue/Epilogue Insertion" | , | ||
false | , | ||
false | |||
) |
|
static |
Insert restore code for the callee-saved registers used in the function.
Definition at line 624 of file PrologEpilogInserter.cpp.
References llvm::MachineInstrBuilder::addReg(), assert(), llvm::MachineBasicBlock::begin(), llvm::BuildMI(), llvm::MachineBasicBlock::getFirstTerminator(), llvm::TargetSubtargetInfo::getFrameLowering(), llvm::TargetSubtargetInfo::getInstrInfo(), llvm::getKillRegState(), llvm::MachineBasicBlock::getParent(), llvm::TargetSubtargetInfo::getRegisterInfo(), llvm::MachineFunction::getSubtarget(), I, llvm::HexagonInstrInfo::loadRegFromStackSlot(), llvm::TargetFrameLowering::restoreCalleeSavedRegisters(), llvm::reverse(), TII, and TRI.
|
static |
Insert spill code for the callee-saved registers used in the function.
Definition at line 597 of file PrologEpilogInserter.cpp.
References llvm::MachineInstrBuilder::addReg(), llvm::MachineBasicBlock::begin(), llvm::BuildMI(), llvm::TargetSubtargetInfo::getFrameLowering(), llvm::TargetSubtargetInfo::getInstrInfo(), llvm::getKillRegState(), llvm::MachineBasicBlock::getParent(), llvm::TargetSubtargetInfo::getRegisterInfo(), llvm::MachineFunction::getSubtarget(), I, llvm::TargetFrameLowering::spillCalleeSavedRegisters(), llvm::HexagonInstrInfo::storeRegToStackSlot(), TII, and TRI.
|
inlinestatic |
Assign frame object to an unused portion of the stack in the fixed stack object range.
Return true if the allocation was successful.
Definition at line 773 of file PrologEpilogInserter.cpp.
References llvm::alignTo(), llvm::BitVector::clear(), llvm::dbgs(), llvm::BitVector::find_first(), llvm::BitVector::find_next(), llvm::MachineFrameInfo::getObjectAlign(), llvm::MachineFrameInfo::getObjectSize(), llvm::MachineFrameInfo::isVariableSizedObjectIndex(), LLVM_DEBUG, llvm::BitVector::none(), llvm::BitVector::reset(), llvm::MachineFrameInfo::setObjectOffset(), llvm::BitVector::size(), and llvm::BitVector::test().
|
static |
Stash DBG_VALUEs that describe parameters and which are placed at the start of the block.
Later on, after the prologue code has been emitted, the stashed DBG_VALUEs will be reinserted at the start of the block.
Definition at line 181 of file PrologEpilogInserter.cpp.
References llvm::any_of(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::count(), llvm::DIExpression::fragmentsOverlap(), MBB, MI, llvm::none_of(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().
STATISTIC | ( | NumBytesStackSpace | , |
"Number of bytes used for stack in all functions" | |||
) |
STATISTIC | ( | NumFuncSeen | , |
"Number of functions seen in PEI" | |||
) |
STATISTIC | ( | NumLeafFuncWithSpills | , |
"Number of leaf functions with CSRs" | |||
) |
|
static |
Helper function to update the liveness information for the callee-saved registers.
Definition at line 525 of file PrologEpilogInserter.cpp.
References llvm::MachineBasicBlock::addLiveIn(), llvm::SmallVectorBase< Size_T >::empty(), llvm::MachineFunction::front(), llvm::MachineFrameInfo::getCalleeSavedInfo(), llvm::MachineFunction::getFrameInfo(), llvm::MachineFunction::getRegInfo(), llvm::MachineFrameInfo::getRestorePoint(), llvm::MachineFrameInfo::getSavePoint(), I, llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::MachineBasicBlock::isLiveIn(), MBB, MRI, llvm::SmallVectorImpl< T >::pop_back_val(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::MachineBasicBlock::successors().
DEBUG_TYPE |
Definition at line 153 of file PrologEpilogInserter.cpp.
Prologue Epilogue Insertion& Frame false |
Definition at line 154 of file PrologEpilogInserter.cpp.
Prologue Epilogue Insertion& Frame Finalization |
Definition at line 154 of file PrologEpilogInserter.cpp.