27 #define DEBUG_TYPE "aarch64-dead-defs"
29 STATISTIC(NumDeadDefsReplaced,
"Number of dead definitions replaced");
31 #define AARCH64_DEAD_REG_DEF_NAME "AArch64 Dead register definitions"
70 void AArch64DeadRegisterDefinitions::processMachineBasicBlock(
74 if (usesFrameIndex(
MI)) {
78 DEBUG(
dbgs() <<
" Ignoring, operand is frame index\n");
81 if (
MI.definesRegister(AArch64::XZR) ||
MI.definesRegister(AArch64::WZR)) {
84 DEBUG(
dbgs() <<
" Ignoring, XZR or WZR already used by the instruction\n");
96 (!MO.
isDead() && !
MRI->use_nodbg_empty(Reg)))
99 DEBUG(
dbgs() <<
" Dead def operand #" <<
I <<
" in:\n ";
102 if (
MI.isRegTiedToUseOperand(
I)) {
103 DEBUG(
dbgs() <<
" Ignoring, def is tied operand.\n");
109 DEBUG(
dbgs() <<
" Ignoring, register is not a GPR.\n");
111 }
else if (RC->
contains(AArch64::WZR))
112 NewReg = AArch64::WZR;
113 else if (RC->
contains(AArch64::XZR))
114 NewReg = AArch64::XZR;
116 DEBUG(
dbgs() <<
" Ignoring, register is not a GPR.\n");
119 DEBUG(
dbgs() <<
" Replacing with zero register. New:\n ");
123 ++NumDeadDefsReplaced;
133 bool AArch64DeadRegisterDefinitions::runOnMachineFunction(
MachineFunction &MF) {
140 DEBUG(
dbgs() <<
"***** AArch64DeadRegisterDefinitions *****\n");
143 processMachineBasicBlock(MBB);
148 return new AArch64DeadRegisterDefinitions();
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
STATISTIC(NumFunctions,"Total number of functions")
unsigned getNumDefs() const
Return the number of MachineOperands that are register definitions.
Describe properties that are true of each instruction in the target description file.
MachineInstrBuilder MachineInstrBuilder &DefMI const MCInstrDesc & Desc
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
void setIsDead(bool Val=true)
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const HexagonInstrInfo * TII
INITIALIZE_PASS(AArch64DeadRegisterDefinitions,"aarch64-dead-defs", AARCH64_DEAD_REG_DEF_NAME, false, false) static bool usesFrameIndex(const MachineInstr &MI)
bool isReg() const
isReg - Tests if this is a MO_Register operand.
Reg
All possible values of the reg field in the ModR/M byte.
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
TargetInstrInfo - Interface to description of machine instruction set.
unsigned const MachineRegisterInfo * MRI
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
MachineOperand class - Representation of each machine instruction operand.
void setPreservesCFG()
This function should be called by the pass, iff they do not:
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
#define AARCH64_DEAD_REG_DEF_NAME
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
Representation of each machine instruction.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
void setReg(unsigned Reg)
Change the register this operand corresponds to.
unsigned getReg() const
getReg - Returns the register number.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
virtual const TargetInstrInfo * getInstrInfo() const
void initializeAArch64DeadRegisterDefinitionsPass(PassRegistry &)
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
FunctionPass * createAArch64DeadRegisterDefinitions()
virtual void print(raw_ostream &O, const Module *M) const
print - Print out the internal state of the pass.
StringRef - Represent a constant reference to a string, i.e.
bool contains(unsigned Reg) const
Return true if the specified register is included in this register class.