mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-28 19:25:00 +00:00
LiveRangeEdit: Fix liveranges not shrinking on subrange kill.
If a dead instruction we may not only have a last-use in the main live range but also in a subregister range if subregisters are tracked. We need to partially rebuild live ranges in both cases. The testcase only broke when subregister liveness was enabled. I commited it in the current form because there is currently no flag to enable/disable subregister liveness. This fixes PR23720. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238785 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -218,6 +218,22 @@ bool LiveRangeEdit::foldAsLoad(LiveInterval *LI,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LiveRangeEdit::useIsKill(const LiveInterval &LI,
|
||||
const MachineOperand &MO) const {
|
||||
const MachineInstr *MI = MO.getParent();
|
||||
SlotIndex Idx = LIS.getInstructionIndex(MI).getRegSlot();
|
||||
if (LI.Query(Idx).isKill())
|
||||
return true;
|
||||
const TargetRegisterInfo &TRI = *MRI.getTargetRegisterInfo();
|
||||
unsigned SubReg = MO.getSubReg();
|
||||
unsigned LaneMask = TRI.getSubRegIndexLaneMask(SubReg);
|
||||
for (const LiveInterval::SubRange &S : LI.subranges()) {
|
||||
if ((S.LaneMask & LaneMask) != 0 && S.Query(Idx).isKill())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Find all live intervals that need to shrink, then remove the instruction.
|
||||
void LiveRangeEdit::eliminateDeadDef(MachineInstr *MI, ToShrinkSet &ToShrink) {
|
||||
assert(MI->allDefsAreDead() && "Def isn't really dead");
|
||||
@@ -266,9 +282,8 @@ void LiveRangeEdit::eliminateDeadDef(MachineInstr *MI, ToShrinkSet &ToShrink) {
|
||||
// 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.Query(Idx).isKill()))
|
||||
if ((MI->readsVirtualRegister(Reg) && (MI->isCopy() || MOI->isDef())) ||
|
||||
(MOI->readsReg() && (MRI.hasOneNonDBGUse(Reg) || useIsKill(LI, *MOI))))
|
||||
ToShrink.insert(&LI);
|
||||
|
||||
// Remove defined value.
|
||||
|
Reference in New Issue
Block a user