From c738c9651925e67ea3153bb651eebb9105d2bad5 Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Wed, 16 Mar 2011 22:56:13 +0000 Subject: [PATCH] Erase virtual registers that are unused after DCE. llvm-svn: 127773 --- llvm/lib/CodeGen/LiveRangeEdit.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/llvm/lib/CodeGen/LiveRangeEdit.cpp b/llvm/lib/CodeGen/LiveRangeEdit.cpp index 0769f95262dc..e994d8c32d49 100644 --- a/llvm/lib/CodeGen/LiveRangeEdit.cpp +++ b/llvm/lib/CodeGen/LiveRangeEdit.cpp @@ -174,13 +174,21 @@ void LiveRangeEdit::eliminateDeadDefs(SmallVectorImpl &Dead, if (!TargetRegisterInfo::isVirtualRegister(Reg)) continue; LiveInterval &LI = LIS.getInterval(Reg); - // Remove defined value. - if (MOI->isDef()) - if (VNInfo *VNI = LI.getVNInfoAt(Idx)) - LI.removeValNo(VNI); + // Shrink read registers. if (MI->readsVirtualRegister(Reg)) ToShrink.insert(&LI); + + // Remove defined value. + if (MOI->isDef()) { + if (VNInfo *VNI = LI.getVNInfoAt(Idx)) { + LI.removeValNo(VNI); + if (LI.empty()) { + ToShrink.remove(&LI); + eraseVirtReg(Reg, LIS); + } + } + } } if (delegate_)