diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2023-09-02 21:17:18 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2023-12-08 17:34:50 +0000 |
commit | 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e (patch) | |
tree | 62f873df87c7c675557a179e0c4c83fe9f3087bc /contrib/llvm-project/llvm/lib/CodeGen/DeadMachineInstructionElim.cpp | |
parent | cf037972ea8863e2bab7461d77345367d2c1e054 (diff) | |
parent | 7fa27ce4a07f19b07799a767fc29416f3b625afb (diff) |
Diffstat (limited to 'contrib/llvm-project/llvm/lib/CodeGen/DeadMachineInstructionElim.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/lib/CodeGen/DeadMachineInstructionElim.cpp | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/contrib/llvm-project/llvm/lib/CodeGen/DeadMachineInstructionElim.cpp b/contrib/llvm-project/llvm/lib/CodeGen/DeadMachineInstructionElim.cpp index e36db43567c5..6a7de3b241fe 100644 --- a/contrib/llvm-project/llvm/lib/CodeGen/DeadMachineInstructionElim.cpp +++ b/contrib/llvm-project/llvm/lib/CodeGen/DeadMachineInstructionElim.cpp @@ -31,8 +31,8 @@ namespace { class DeadMachineInstructionElim : public MachineFunctionPass { bool runOnMachineFunction(MachineFunction &MF) override; - const MachineRegisterInfo *MRI; - const TargetInstrInfo *TII; + const MachineRegisterInfo *MRI = nullptr; + const TargetInstrInfo *TII = nullptr; LiveRegUnits LivePhysRegs; public: @@ -75,27 +75,25 @@ bool DeadMachineInstructionElim::isDead(const MachineInstr *MI) const { return false; // Examine each operand. - for (const MachineOperand &MO : MI->operands()) { - if (MO.isReg() && MO.isDef()) { - Register Reg = MO.getReg(); - if (Reg.isPhysical()) { - // Don't delete live physreg defs, or any reserved register defs. - if (!LivePhysRegs.available(Reg) || MRI->isReserved(Reg)) - return false; - } else { - if (MO.isDead()) { + for (const MachineOperand &MO : MI->all_defs()) { + Register Reg = MO.getReg(); + if (Reg.isPhysical()) { + // Don't delete live physreg defs, or any reserved register defs. + if (!LivePhysRegs.available(Reg) || MRI->isReserved(Reg)) + return false; + } else { + if (MO.isDead()) { #ifndef NDEBUG - // Basic check on the register. All of them should be 'undef'. - for (auto &U : MRI->use_nodbg_operands(Reg)) - assert(U.isUndef() && "'Undef' use on a 'dead' register is found!"); + // Basic check on the register. All of them should be 'undef'. + for (auto &U : MRI->use_nodbg_operands(Reg)) + assert(U.isUndef() && "'Undef' use on a 'dead' register is found!"); #endif - continue; - } - for (const MachineInstr &Use : MRI->use_nodbg_instructions(Reg)) { - if (&Use != MI) - // This def has a non-debug use. Don't delete the instruction! - return false; - } + continue; + } + for (const MachineInstr &Use : MRI->use_nodbg_instructions(Reg)) { + if (&Use != MI) + // This def has a non-debug use. Don't delete the instruction! + return false; } } } |