diff options
author | Dale Johannesen <dalej@apple.com> | 2010-01-27 22:12:36 +0000 |
---|---|---|
committer | Dale Johannesen <dalej@apple.com> | 2010-01-27 22:12:36 +0000 |
commit | 9514fcbae518cfe3e4e4ea1fcc279babbdc38095 (patch) | |
tree | 0bfec902bd9c26914ab18af4f0a789cb7e43a834 /lib | |
parent | 714eb731b2df6b4eb5221e76297d4c691ab91b3e (diff) | |
download | external_llvm-9514fcbae518cfe3e4e4ea1fcc279babbdc38095.zip external_llvm-9514fcbae518cfe3e4e4ea1fcc279babbdc38095.tar.gz external_llvm-9514fcbae518cfe3e4e4ea1fcc279babbdc38095.tar.bz2 |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94694 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/DeadMachineInstructionElim.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/CodeGen/DeadMachineInstructionElim.cpp b/lib/CodeGen/DeadMachineInstructionElim.cpp index 0982eab..9d7ec06 100644 --- a/lib/CodeGen/DeadMachineInstructionElim.cpp +++ b/lib/CodeGen/DeadMachineInstructionElim.cpp @@ -107,6 +107,20 @@ bool DeadMachineInstructionElim::runOnMachineFunction(MachineFunction &MF) { 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); |