diff options
Diffstat (limited to 'llvm/lib/CodeGen/LiveDebugValues.cpp')
-rw-r--r-- | llvm/lib/CodeGen/LiveDebugValues.cpp | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/LiveDebugValues.cpp b/llvm/lib/CodeGen/LiveDebugValues.cpp index abd863f20b9..d18703803d3 100644 --- a/llvm/lib/CodeGen/LiveDebugValues.cpp +++ b/llvm/lib/CodeGen/LiveDebugValues.cpp @@ -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 |