aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineSink.cpp
diff options
context:
space:
mode:
authorCarl Ritson <carl.ritson@amd.com>2022-06-24 14:02:48 +0900
committerCarl Ritson <carl.ritson@amd.com>2022-06-24 14:02:48 +0900
commit874fbe2cbbe6f548858d0c8e804eb66ca477697c (patch)
tree35a9c6c05e0213a8689890249d5ae0460d9c7cab /llvm/lib/CodeGen/MachineSink.cpp
parentf401dd6f43b3699d95ed1f0def954566a0995b34 (diff)
downloadllvm-874fbe2cbbe6f548858d0c8e804eb66ca477697c.zip
llvm-874fbe2cbbe6f548858d0c8e804eb66ca477697c.tar.gz
llvm-874fbe2cbbe6f548858d0c8e804eb66ca477697c.tar.bz2
[MachineSink] Clear kill flags on operands outside loop
If an instruction is sunk into a loop then any kill flags on operands declared outside the loop must be cleared as these will be live for all loop iterations. Fixes #46827 Reviewed By: MatzeB Differential Revision: https://reviews.llvm.org/D126754
Diffstat (limited to 'llvm/lib/CodeGen/MachineSink.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineSink.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineSink.cpp b/llvm/lib/CodeGen/MachineSink.cpp
index 3f2330b..006ba92 100644
--- a/llvm/lib/CodeGen/MachineSink.cpp
+++ b/llvm/lib/CodeGen/MachineSink.cpp
@@ -1289,6 +1289,12 @@ bool MachineSinking::SinkIntoCycle(MachineCycle *Cycle, MachineInstr &I) {
SinkBlock->splice(SinkBlock->SkipPHIsAndLabels(SinkBlock->begin()), Preheader,
I);
+ // Conservatively clear any kill flags on uses of sunk instruction
+ for (MachineOperand &MO : I.operands()) {
+ if (MO.isReg() && MO.readsReg())
+ RegsToClearKillFlags.insert(MO.getReg());
+ }
+
// The instruction is moved from its basic block, so do not retain the
// debug information.
assert(!I.isDebugInstr() && "Should not sink debug inst");