From caa8bfd13b8e0477d5c5256170408ac24cd2e1e5 Mon Sep 17 00:00:00 2001 From: Gerolf Hoflehner Date: Wed, 13 Aug 2014 21:15:23 +0000 Subject: [Cleanup] Utility function to erase instruction and mark DBG_Values New function to erase a machine instruction and mark DBG_VALUE for removal. A DBG_VALUE is marked for removal when it references an operand defined in the instruction. Use the new function to cleanup code in dead machine instruction removal pass. llvm-svn: 215580 --- llvm/lib/CodeGen/DeadMachineInstructionElim.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'llvm/lib/CodeGen/DeadMachineInstructionElim.cpp') diff --git a/llvm/lib/CodeGen/DeadMachineInstructionElim.cpp b/llvm/lib/CodeGen/DeadMachineInstructionElim.cpp index 535477de788..f3be2abacd7 100644 --- a/llvm/lib/CodeGen/DeadMachineInstructionElim.cpp +++ b/llvm/lib/CodeGen/DeadMachineInstructionElim.cpp @@ -124,19 +124,10 @@ bool DeadMachineInstructionElim::runOnMachineFunction(MachineFunction &MF) { if (isDead(MI)) { DEBUG(dbgs() << "DeadMachineInstructionElim: DELETING: " << *MI); // It is possible that some DBG_VALUE instructions refer to this - // instruction. Examine each def operand for such references; - // if found, mark the DBG_VALUE as undef (but don't delete it). - for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { - const MachineOperand &MO = MI->getOperand(i); - if (!MO.isReg() || !MO.isDef()) - continue; - unsigned Reg = MO.getReg(); - if (!TargetRegisterInfo::isVirtualRegister(Reg)) - continue; - MRI->markUsesInDebugValueAsUndef(Reg); - } + // instruction. They get marked as undef and will be deleted + // in the live debug variable analysis. + MI->eraseFromParentAndMarkDBGValuesForRemoval(); AnyChanges = true; - MI->eraseFromParent(); ++NumDeletes; MIE = MBB->rend(); // MII is now pointing to the next instruction to process, -- cgit v1.2.3