summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/LiveDebugValues.cpp
diff options
context:
space:
mode:
authorPetar Jovanovic <petar.jovanovic@mips.com>2018-01-16 14:46:05 +0000
committerPetar Jovanovic <petar.jovanovic@mips.com>2018-01-16 14:46:05 +0000
commit0b464e4f0e725162322db7f082e5372feeaabe1e (patch)
tree912fd37f3667a1b5c54ba3abb91649030737d29b /llvm/lib/CodeGen/LiveDebugValues.cpp
parent85e613963372beb6f5af39592b16bcee748bb0c3 (diff)
downloadbcm5719-llvm-0b464e4f0e725162322db7f082e5372feeaabe1e.tar.gz
bcm5719-llvm-0b464e4f0e725162322db7f082e5372feeaabe1e.zip
[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 llvm-svn: 322554
Diffstat (limited to 'llvm/lib/CodeGen/LiveDebugValues.cpp')
-rw-r--r--llvm/lib/CodeGen/LiveDebugValues.cpp37
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
OpenPOWER on IntegriCloud