aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineSink.cpp
diff options
context:
space:
mode:
authorMomchil Velikov <momchil.velikov@arm.com>2023-11-24 09:46:03 +0000
committerGitHub <noreply@github.com>2023-11-24 09:46:03 +0000
commit6b87d84ff45d03c244e7511fba9359776ce27977 (patch)
tree383ee70bf0d34f7c8e5e5186089d0ed95d8023cc /llvm/lib/CodeGen/MachineSink.cpp
parent59edb432256064ee4f66c3a30fd4875030c5166b (diff)
downloadllvm-6b87d84ff45d03c244e7511fba9359776ce27977.zip
llvm-6b87d84ff45d03c244e7511fba9359776ce27977.tar.gz
llvm-6b87d84ff45d03c244e7511fba9359776ce27977.tar.bz2
[MachineSink] Some more preserving of debug location when rematerialising an instruction to replace a COPY (#73155)
Somewhat similar to ef9bcace834e63f25bbbc5e8e2b615f89d85fb2f ([MachineSink][AArch64] Preserve debug location when rematerialising an instruction to replace a COPY (#72685)) reuse the debug location of the COPY, iff the rematerialised instruction did not have a location. Fixes a regression in `DebugInfo/AArch64/constant-dbgloc.ll` after enabling sink-and-fold.
Diffstat (limited to 'llvm/lib/CodeGen/MachineSink.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineSink.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/MachineSink.cpp b/llvm/lib/CodeGen/MachineSink.cpp
index 48f5a21..83d7750 100644
--- a/llvm/lib/CodeGen/MachineSink.cpp
+++ b/llvm/lib/CodeGen/MachineSink.cpp
@@ -506,7 +506,7 @@ bool MachineSinking::PerformSinkAndFold(MachineInstr &MI,
MRI->clearKillFlags(UsedRegB);
for (auto &[SinkDst, MaybeAM] : SinkInto) {
- [[maybe_unused]] MachineInstr *New = nullptr;
+ MachineInstr *New = nullptr;
LLVM_DEBUG(dbgs() << "Sinking copy of"; MI.dump(); dbgs() << "into";
SinkDst->dump());
if (SinkDst->isCopy()) {
@@ -525,6 +525,8 @@ bool MachineSinking::PerformSinkAndFold(MachineInstr &MI,
Register DstReg = SinkDst->getOperand(0).getReg();
TII->reMaterialize(*SinkDst->getParent(), InsertPt, DstReg, 0, MI, *TRI);
New = &*std::prev(InsertPt);
+ if (!New->getDebugLoc())
+ New->setDebugLoc(SinkDst->getDebugLoc());
} else {
// Fold instruction into the addressing mode of a memory instruction.
New = TII->emitLdStWithAddr(*SinkDst, MaybeAM);