[LiveDebugValues] recognize spilled reg killed in instruction after spill

Current condition for spill instruction recognition in LiveDebugValues does
not recognize case when register is spilled and killed in next instruction.

Patch by Nikola Prica.

Differential Revision: https://reviews.llvm.org/D41226


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@322554 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Petar Jovanovic
2018-01-16 14:46:05 +00:00
parent 8c341debfd
commit 18704c2df5
2 changed files with 417 additions and 7 deletions
+30 -7
View File
@@ -426,16 +426,39 @@ bool LiveDebugValues::isSpillInstruction(const MachineInstr &MI,
FrameInfo.isSpillSlotObjectIndex(FI)))
return false;
// In a spill instruction generated by the InlineSpiller the spilled register
// has its kill flag set. Return false if we don't find such a register.
Reg = 0;
auto isKilledReg = [&](const MachineOperand MO, unsigned &Reg) {
if (!MO.isReg() || !MO.isUse()) {
Reg = 0;
return false;
}
Reg = MO.getReg();
return MO.isKill();
};
for (const MachineOperand &MO : MI.operands()) {
if (MO.isReg() && MO.isUse() && MO.isKill()) {
Reg = MO.getReg();
break;
// In a spill instruction generated by the InlineSpiller the spilled
// register has its kill flag set.
if (isKilledReg(MO, Reg))
return true;
if (Reg != 0) {
// Check whether next instruction kills the spilled register.
// FIXME: Current solution does not cover search for killed register in
// bundles and instructions further down the chain.
auto NextI = std::next(MI.getIterator());
// Skip next instruction that points to basic block end iterator.
if (MI.getParent()->end() == NextI)
continue;
unsigned RegNext;
for (const MachineOperand &MONext : NextI->operands()) {
// Return true if we came across the register from the
// previous spill instruction that is killed in NextI.
if (isKilledReg(MONext, RegNext) && RegNext == Reg)
return true;
}
}
}
return Reg != 0;
// Return false if we didn't find spilled register.
return false;
}
/// A spilled register may indicate that we have to end the current range of