summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MachineSink.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/MachineSink.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineSink.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/MachineSink.cpp b/llvm/lib/CodeGen/MachineSink.cpp
index 81aaca02a4d..0c29c76309e 100644
--- a/llvm/lib/CodeGen/MachineSink.cpp
+++ b/llvm/lib/CodeGen/MachineSink.cpp
@@ -736,9 +736,19 @@ bool MachineSinking::SinkInstruction(MachineInstr *MI, bool &SawStore) {
++MachineBasicBlock::iterator(DbgMI));
}
- // Conservatively, clear any kill flags, since it's possible that they are no
- // longer correct.
- MI->clearKillInfo();
+ // When sinking the instruction the live time of its operands can be extended
+ // bejond their original last use (marked with a kill flag). Conservatively
+ // clear the kill flag in all instructions that use the same operand
+ // registers.
+ for (auto &MO : MI->uses())
+ if (MO.isReg() && MO.isUse()) {
+ // Preserve the kill flag for this instruction.
+ bool IsKill = MO.isKill();
+ // Clear the kill flag in all instruction that use this operand.
+ MRI->clearKillFlags(MO.getReg());
+ // Restore the kill flag for only this instruction.
+ MO.setIsKill(IsKill);
+ }
return true;
}
OpenPOWER on IntegriCloud