27#define DEBUG_TYPE "aarch64-dead-defs"
29STATISTIC(NumDeadDefsReplaced,
"Number of dead definitions replaced");
31#define AARCH64_DEAD_REG_DEF_NAME "AArch64 Dead register definitions"
57char AArch64DeadRegisterDefinitions::ID = 0;
78 case AArch64::LDADDB:
case AArch64::LDADDH:
79 case AArch64::LDADDW:
case AArch64::LDADDX:
80 case AArch64::LDADDLB:
case AArch64::LDADDLH:
81 case AArch64::LDADDLW:
case AArch64::LDADDLX:
82 case AArch64::LDCLRB:
case AArch64::LDCLRH:
83 case AArch64::LDCLRW:
case AArch64::LDCLRX:
84 case AArch64::LDCLRLB:
case AArch64::LDCLRLH:
85 case AArch64::LDCLRLW:
case AArch64::LDCLRLX:
86 case AArch64::LDEORB:
case AArch64::LDEORH:
87 case AArch64::LDEORW:
case AArch64::LDEORX:
88 case AArch64::LDEORLB:
case AArch64::LDEORLH:
89 case AArch64::LDEORLW:
case AArch64::LDEORLX:
90 case AArch64::LDSETB:
case AArch64::LDSETH:
91 case AArch64::LDSETW:
case AArch64::LDSETX:
92 case AArch64::LDSETLB:
case AArch64::LDSETLH:
93 case AArch64::LDSETLW:
case AArch64::LDSETLX:
94 case AArch64::LDSMAXB:
case AArch64::LDSMAXH:
95 case AArch64::LDSMAXW:
case AArch64::LDSMAXX:
96 case AArch64::LDSMAXLB:
case AArch64::LDSMAXLH:
97 case AArch64::LDSMAXLW:
case AArch64::LDSMAXLX:
98 case AArch64::LDSMINB:
case AArch64::LDSMINH:
99 case AArch64::LDSMINW:
case AArch64::LDSMINX:
100 case AArch64::LDSMINLB:
case AArch64::LDSMINLH:
101 case AArch64::LDSMINLW:
case AArch64::LDSMINLX:
102 case AArch64::LDUMAXB:
case AArch64::LDUMAXH:
103 case AArch64::LDUMAXW:
case AArch64::LDUMAXX:
104 case AArch64::LDUMAXLB:
case AArch64::LDUMAXLH:
105 case AArch64::LDUMAXLW:
case AArch64::LDUMAXLX:
106 case AArch64::LDUMINB:
case AArch64::LDUMINH:
107 case AArch64::LDUMINW:
case AArch64::LDUMINX:
108 case AArch64::LDUMINLB:
case AArch64::LDUMINLH:
109 case AArch64::LDUMINLW:
case AArch64::LDUMINLX:
110 case AArch64::SWPB:
case AArch64::SWPH:
111 case AArch64::SWPW:
case AArch64::SWPX:
112 case AArch64::SWPLB:
case AArch64::SWPLH:
113 case AArch64::SWPLW:
case AArch64::SWPLX:
119void AArch64DeadRegisterDefinitions::processMachineBasicBlock(
123 if (usesFrameIndex(
MI)) {
130 if (
MI.definesRegister(AArch64::XZR,
nullptr) ||
131 MI.definesRegister(AArch64::WZR,
nullptr)) {
136 <<
" Ignoring, XZR or WZR already used by the instruction\n");
141 LLVM_DEBUG(
dbgs() <<
" Ignoring, semantics change with xzr/wzr.\n");
146 for (
int I = 0, E =
Desc.getNumDefs();
I != E; ++
I) {
153 if (!
Reg.isVirtual() || (!MO.
isDead() && !
MRI->use_nodbg_empty(Reg)))
159 if (
MI.isRegTiedToUseOperand(
I)) {
168 }
else if (RC->
contains(AArch64::WZR))
169 NewReg = AArch64::WZR;
170 else if (RC->
contains(AArch64::XZR))
171 NewReg = AArch64::XZR;
180 ++NumDeadDefsReplaced;
190bool AArch64DeadRegisterDefinitions::runOnMachineFunction(
MachineFunction &MF) {
197 LLVM_DEBUG(
dbgs() <<
"***** AArch64DeadRegisterDefinitions *****\n");
200 processMachineBasicBlock(
MBB);
205 return new AArch64DeadRegisterDefinitions();
unsigned const MachineRegisterInfo * MRI
static bool atomicReadDroppedOnZero(unsigned Opcode)
#define AARCH64_DEAD_REG_DEF_NAME
const HexagonInstrInfo * TII
unsigned const TargetRegisterInfo * TRI
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
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)
Represent the analysis usage information of a pass.
void setPreservesCFG()
This function should be called by the pass, iff they do not:
FunctionPass class - This class is used to implement most global optimizations.
Describe properties that are true of each instruction in the target description file.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
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.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
void setIsDead(bool Val=true)
void setReg(Register Reg)
Change the register this operand corresponds to.
Register getReg() const
getReg - Returns the register number.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
virtual void print(raw_ostream &OS, const Module *M) const
print - Print out the internal state of the pass.
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
Wrapper class representing virtual and physical registers.
StringRef - Represent a constant reference to a string, i.e.
TargetInstrInfo - Interface to description of machine instruction set.
bool contains(Register Reg) const
Return true if the specified register is included in this register class.
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 TargetInstrInfo * getInstrInfo() const
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.
This is an optimization pass for GlobalISel generic memory operations.
FunctionPass * createAArch64DeadRegisterDefinitions()
void initializeAArch64DeadRegisterDefinitionsPass(PassRegistry &)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
static bool atomicBarrierDroppedOnZero(unsigned Opcode)
Description of the encoding of one expression Op.