summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MachineSink.cpp
diff options
context:
space:
mode:
authorJuergen Ributzka <juergen@apple.com>2014-08-29 23:48:03 +0000
committerJuergen Ributzka <juergen@apple.com>2014-08-29 23:48:03 +0000
commit00d78221abd6c97b70e6db4b0d7b5d7d727283e9 (patch)
tree6870b4a5c6568c197865ff2af68528f017cbd376 /llvm/lib/CodeGen/MachineSink.cpp
parent2321920b61335cc834fea8f13d5006eb1e84ab1f (diff)
downloadbcm5719-llvm-00d78221abd6c97b70e6db4b0d7b5d7d727283e9.tar.gz
bcm5719-llvm-00d78221abd6c97b70e6db4b0d7b5d7d727283e9.zip
[MachineSinking] Clear kill flag of all operands at all their uses.
When sinking an instruction it might be moved past the original last use of one of its operands. This last use has the kill flag set and the verifier will obviously complain about this. Before Machine Sinking (AArch64): %vreg3<def> = ASRVXr %vreg1, %vreg2<kill> %XZR<def> = SUBSXrs %vreg4, %vreg1<kill>, 160, %NZCV<imp-def> ... After Machine Sinking: %XZR<def> = SUBSXrs %vreg4, %vreg1<kill>, 160, %NZCV<imp-def> ... %vreg3<def> = ASRVXr %vreg1, %vreg2<kill> This fix clears all the kill flags in all instruction that use the same operands as the instruction that is being sunk. This fixes rdar://problem/18180996. llvm-svn: 216803
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