[llvm-commits] [llvm] r94694 - /llvm/trunk/lib/CodeGen/DeadMachineInstructionElim.cpp
Dale Johannesen
dalej at apple.com
Wed Jan 27 14:12:36 PST 2010
Author: johannes
Date: Wed Jan 27 16:12:36 2010
New Revision: 94694
URL: http://llvm.org/viewvc/llvm-project?rev=94694&view=rev
Log:
If the only use of something is a DEBUG_VALUE, don't
let that stop it from being deleted, and change the
DEBUG_VALUE value to undef.
Modified:
llvm/trunk/lib/CodeGen/DeadMachineInstructionElim.cpp
Modified: llvm/trunk/lib/CodeGen/DeadMachineInstructionElim.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/DeadMachineInstructionElim.cpp?rev=94694&r1=94693&r2=94694&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/DeadMachineInstructionElim.cpp (original)
+++ llvm/trunk/lib/CodeGen/DeadMachineInstructionElim.cpp Wed Jan 27 16:12:36 2010
@@ -107,6 +107,20 @@
MIE = MBB->rend(); MII != MIE; ) {
MachineInstr *MI = &*MII;
+ if (MI->getOpcode()==TargetInstrInfo::DEBUG_VALUE) {
+ // Don't delete the DEBUG_VALUE itself, but if its Value operand is
+ // a vreg and this is the only use, substitute an undef operand;
+ // the former operand will then be deleted normally.
+ if (MI->getNumOperands()==3 && MI->getOperand(0).isReg()) {
+ unsigned Reg = MI->getOperand(0).getReg();
+ MachineRegisterInfo::use_iterator I = MRI->use_begin(Reg);
+ assert(I != MRI->use_end());
+ if (++I == MRI->use_end())
+ // only one use, which must be this DEBUG_VALUE.
+ MI->getOperand(0).setReg(0U);
+ }
+ }
+
// If the instruction is dead, delete it!
if (isDead(MI)) {
DEBUG(dbgs() << "DeadMachineInstructionElim: DELETING: " << *MI);
More information about the llvm-commits
mailing list