1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

Don't shrink live ranges after dead code elimination unless it is going to help.

In particular, don't repeatedly recompute the PIC base live range after rematerialization.

llvm-svn: 129275
This commit is contained in:
Jakob Stoklund Olesen 2011-04-11 15:00:39 +00:00
parent a9744b8476
commit 5d6e68454e

View File

@ -203,6 +203,7 @@ void LiveRangeEdit::eliminateDeadDefs(SmallVectorImpl<MachineInstr*> &Dead,
SetVector<LiveInterval*, SetVector<LiveInterval*,
SmallVector<LiveInterval*, 8>, SmallVector<LiveInterval*, 8>,
SmallPtrSet<LiveInterval*, 8> > ToShrink; SmallPtrSet<LiveInterval*, 8> > ToShrink;
MachineRegisterInfo &MRI = VRM.getRegInfo();
for (;;) { for (;;) {
// Erase all dead defs. // Erase all dead defs.
@ -236,8 +237,13 @@ void LiveRangeEdit::eliminateDeadDefs(SmallVectorImpl<MachineInstr*> &Dead,
continue; continue;
LiveInterval &LI = LIS.getInterval(Reg); LiveInterval &LI = LIS.getInterval(Reg);
// Shrink read registers. // Shrink read registers, unless it is likely to be expensive and
if (MI->readsVirtualRegister(Reg)) // unlikely to change anything. We typically don't want to shrink the
// PIC base register that has lots of uses everywhere.
// Always shrink COPY uses that probably come from live range splitting.
if (MI->readsVirtualRegister(Reg) &&
(MI->isCopy() || MOI->isDef() || MRI.hasOneNonDBGUse(Reg) ||
LI.killedAt(Idx)))
ToShrink.insert(&LI); ToShrink.insert(&LI);
// Remove defined value. // Remove defined value.
@ -266,7 +272,7 @@ void LiveRangeEdit::eliminateDeadDefs(SmallVectorImpl<MachineInstr*> &Dead,
// Shrink just one live interval. Then delete new dead defs. // Shrink just one live interval. Then delete new dead defs.
LiveInterval *LI = ToShrink.back(); LiveInterval *LI = ToShrink.back();
ToShrink.pop_back(); ToShrink.pop_back();
if (foldAsLoad(LI, Dead, VRM.getRegInfo(), LIS, TII)) if (foldAsLoad(LI, Dead, MRI, LIS, TII))
continue; continue;
if (delegate_) if (delegate_)
delegate_->LRE_WillShrinkVirtReg(LI->reg); delegate_->LRE_WillShrinkVirtReg(LI->reg);
@ -286,7 +292,7 @@ void LiveRangeEdit::eliminateDeadDefs(SmallVectorImpl<MachineInstr*> &Dead,
if (delegate_) if (delegate_)
delegate_->LRE_DidCloneVirtReg(Dups.back()->reg, LI->reg); delegate_->LRE_DidCloneVirtReg(Dups.back()->reg, LI->reg);
} }
ConEQ.Distribute(&Dups[0], VRM.getRegInfo()); ConEQ.Distribute(&Dups[0], MRI);
} }
} }