34#define DEBUG_TYPE "ip-regalloc"
37 "Number of functions optimized for callee saved registers");
61 return "Register Usage Information Collector Pass";
74char RegUsageInfoCollectorLegacy::ID = 0;
77 "Register Usage Information Collector",
false,
false)
83 return new RegUsageInfoCollectorLegacy();
112 .getCachedResult<PhysicalRegisterUsageAnalysis>(MFA);
113 assert(PRUI &&
"PhysicalRegisterUsageAnalysis not available");
118bool RegUsageInfoCollectorLegacy::runOnMachineFunction(
MachineFunction &MF) {
120 getAnalysis<PhysicalRegisterUsageInfoWrapperLegacy>().getPRUI();
131 <<
" -------------------- Register Usage Information Collector Pass"
132 <<
" -------------------- \nFunction Name : " << MF.
getName() <<
'\n');
147 std::vector<uint32_t> RegMask;
153 RegMask.resize(RegMaskSize, ~((
uint32_t)0));
162 computeCalleeSavedRegs(SavedRegs, MF);
164 const BitVector &UsedPhysRegsMask =
MRI->getUsedPhysRegsMask();
165 auto SetRegAsDefined = [&RegMask] (
unsigned Reg) {
166 RegMask[
Reg / 32] &= ~(1u <<
Reg % 32);
174 for (
const MCPhysReg Reg :
TRI->getIntraCallClobberedRegs(&MF))
176 SetRegAsDefined(*AI);
181 for (
unsigned PReg = 1, PRegE =
TRI->getNumRegs(); PReg < PRegE; ++PReg) {
183 if (SavedRegs.
test(PReg))
187 if (!
MRI->def_empty(PReg)) {
189 if (!SavedRegs.
test(*AI))
190 SetRegAsDefined(*AI);
196 if (UsedPhysRegsMask.
test(PReg))
197 SetRegAsDefined(PReg);
204 <<
" function optimized for not having CSR.\n");
208 for (
unsigned PReg = 1, PRegE =
TRI->getNumRegs(); PReg < PRegE; ++PReg) {
209 if (MachineOperand::clobbersPhysReg(&(RegMask[0]), PReg))
210 dbgs() << printReg(PReg, TRI) <<
" ";
213 dbgs() <<
" \n----------------------------------------\n";
221void RegUsageInfoCollector::
229 if (SavedRegs.
none())
234 for (
unsigned i = 0; CSRegs[i]; ++i) {
236 if (SavedRegs.
test(Reg)) {
unsigned const MachineRegisterInfo * MRI
unsigned const TargetRegisterInfo * TRI
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Register Usage Information Collector
static bool isCallableFunction(const MachineFunction &MF)
This pass is required to take advantage of the interprocedural register allocation infrastructure.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
A container for analyses that lazily runs them and caches their results.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
void setPreservesAll()
Set by analyses that do not transform their input at all.
bool test(unsigned Idx) const
void clear()
clear - Removes all bits from the bitvector.
bool none() const
none - Returns true if none of the bits are set.
FunctionPass class - This class is used to implement most global optimizations.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
Module * getParent()
Get the module that this global value is contained inside of...
MCRegAliasIterator enumerates all registers aliasing Reg.
static constexpr unsigned NoRegister
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
static unsigned getRegMaskSize(unsigned NumRegs)
Returns number of elements needed for a regmask array.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
A Module instance is used to store all the information related to an LLVM module.
An analysis over an "inner" IR unit that provides access to an analysis manager over a "outer" IR uni...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
void setTargetMachine(const TargetMachine &TM)
Set TargetMachine which is used to print analysis.
void storeUpdateRegUsageInfo(const Function &FP, ArrayRef< uint32_t > RegMask)
To store RegMask for given Function *.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Wrapper class representing virtual and physical registers.
StringRef - Represent a constant reference to a string, i.e.
Information about stack frame layout on the target.
virtual void getCalleeSaves(const MachineFunction &MF, BitVector &SavedRegs) const
Returns the callee-saved registers as computed by determineCalleeSaves in the BitVector SavedRegs.
virtual bool isProfitableForNoCSROpt(const Function &F) const
Check if the no-CSR optimisation is profitable for the given function.
static bool isSafeForNoCSROpt(const Function &F)
Check if given function is safe for not having callee saved registers.
Primary interface to the complete machine description for the target machine.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
virtual const TargetFrameLowering * getFrameLowering() const
@ AMDGPU_CS
Used for Mesa/AMDPAL compute shaders.
@ AMDGPU_VS
Used for Mesa vertex shaders, or AMDPAL last shader stage before rasterization (vertex shader if tess...
@ AMDGPU_KERNEL
Used for AMDGPU code object kernels.
@ AMDGPU_HS
Used for Mesa/AMDPAL hull shaders (= tessellation control shaders).
@ AMDGPU_GS
Used for Mesa/AMDPAL geometry shaders.
@ AMDGPU_PS
Used for Mesa/AMDPAL pixel shaders.
@ AMDGPU_ES
Used for AMDPAL shader stage before geometry shader if geometry is in use.
@ AMDGPU_LS
Used for AMDPAL vertex shader if tessellation is in use.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Reg
All possible values of the reg field in the ModR/M byte.
PointerTypeMap run(const Module &M)
Compute the PointerTypeMap for the module M.
This is an optimization pass for GlobalISel generic memory operations.
FunctionPass * createRegUsageInfoCollector()
This pass is executed POST-RA to collect which physical registers are preserved by given machine func...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void initializeRegUsageInfoCollectorLegacyPass(PassRegistry &)