29 #define DEBUG_TYPE "aarch64-dead-defs" 31 STATISTIC(NumDeadDefsReplaced,
"Number of dead definitions replaced");
33 #define AARCH64_DEAD_REG_DEF_NAME "AArch64 Dead register definitions" 80 #define CASE_AARCH64_ATOMIC_(PREFIX) \ 81 case AArch64::PREFIX##X: \ 82 case AArch64::PREFIX##W: \ 83 case AArch64::PREFIX##H: \ 84 case AArch64::PREFIX##B 87 if (MMO->isAtomic()) {
126 #undef CASE_AARCH64_ATOMIC_ 131 void AArch64DeadRegisterDefinitions::processMachineBasicBlock(
135 if (usesFrameIndex(MI)) {
147 <<
" Ignoring, XZR or WZR already used by the instruction\n");
151 if (shouldSkip(MI, MF)) {
152 LLVM_DEBUG(
dbgs() <<
" Ignoring, Atomic instruction with acquire " 153 "semantics using WZR/XZR\n");
166 (!MO.
isDead() && !
MRI->use_nodbg_empty(Reg)))
181 }
else if (RC->
contains(AArch64::WZR))
182 NewReg = AArch64::WZR;
183 else if (RC->
contains(AArch64::XZR))
184 NewReg = AArch64::XZR;
193 ++NumDeadDefsReplaced;
203 bool AArch64DeadRegisterDefinitions::runOnMachineFunction(
MachineFunction &MF) {
210 LLVM_DEBUG(
dbgs() <<
"***** AArch64DeadRegisterDefinitions *****\n");
213 processMachineBasicBlock(MBB);
218 return new AArch64DeadRegisterDefinitions();
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
bool contains(unsigned Reg) const
Return true if the specified register is included in this register class.
This class represents lattice values for constants.
#define CASE_AARCH64_ATOMIC_(PREFIX)
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
Describe properties that are true of each instruction in the target description file.
unsigned getReg() const
getReg - Returns the register number.
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
STATISTIC(NumFunctions, "Total number of functions")
unsigned const TargetRegisterInfo * TRI
void setIsDead(bool Val=true)
A description of a memory reference used in the backend.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const HexagonInstrInfo * TII
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
virtual const TargetInstrInfo * getInstrInfo() const
TargetInstrInfo - Interface to description of machine instruction set.
unsigned const MachineRegisterInfo * MRI
ArrayRef< MachineMemOperand * > memoperands() const
Access to memory operands of the instruction.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
bool definesRegister(unsigned Reg, const TargetRegisterInfo *TRI=nullptr) const
Return true if the MachineInstr fully defines the specified register.
void print(raw_ostream &OS, bool IsStandalone=true, bool SkipOpers=false, bool SkipDebugLoc=false, bool AddNewLine=true, const TargetInstrInfo *TII=nullptr) const
Print this MI to OS.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
MachineOperand class - Representation of each machine instruction operand.
unsigned getNumDefs() const
Return the number of MachineOperands that are register definitions.
void setPreservesCFG()
This function should be called by the pass, iff they do not:
const Function & getFunction() const
Return the LLVM function that this machine code represents.
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.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
INITIALIZE_PASS(AArch64DeadRegisterDefinitions, "aarch64-dead-defs", AARCH64_DEAD_REG_DEF_NAME, false, false) static bool usesFrameIndex(const MachineInstr &MI)
void setReg(unsigned Reg)
Change the register this operand corresponds to.
bool isRegTiedToUseOperand(unsigned DefOpIdx, unsigned *UseOpIdx=nullptr) const
Given the index of a register def operand, check if the register def is tied to a source operand...
bool isReg() const
isReg - Tests if this is a MO_Register operand.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void initializeAArch64DeadRegisterDefinitionsPass(PassRegistry &)
FunctionPass * createAArch64DeadRegisterDefinitions()
StringRef - Represent a constant reference to a string, i.e.
const MachineOperand & getOperand(unsigned i) const