[llvm] [MachineSink] Some more preserving of debug location when rematerialising an instruction to replace a COPY (PR #73155)
Momchil Velikov via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 22 10:08:56 PST 2023
https://github.com/momchil-velikov created https://github.com/llvm/llvm-project/pull/73155
Somewhet 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.
>From 09f5177393ce0634c0a673bd42d08c6aaed31617 Mon Sep 17 00:00:00 2001
From: Momchil Velikov <momchil.velikov at arm.com>
Date: Wed, 22 Nov 2023 17:19:01 +0000
Subject: [PATCH 1/2] [MachineSink] Some more preserving of debug location when
rematerialising an instruction to replace a COPY
Somewhet 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.
---
llvm/lib/CodeGen/MachineSink.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/CodeGen/MachineSink.cpp b/llvm/lib/CodeGen/MachineSink.cpp
index 48f5a21406f08a8..83d775055dfd733 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);
>From 46647c566cb515c618624b3b97daae0a6e52e3f0 Mon Sep 17 00:00:00 2001
From: Momchil Velikov <momchil.velikov at arm.com>
Date: Wed, 22 Nov 2023 17:45:24 +0000
Subject: [PATCH 2/2] Revert "Revert "[MachineSink][AArch64] Enable
sink-and-fold by default (#72132)""
This reverts commit 4ac5b0da8d71b72dc999a462ecfb3695d0803e7c.
---
llvm/lib/Target/AArch64/AArch64TargetMachine.cpp | 2 +-
llvm/test/CodeGen/AArch64/sink-and-fold.ll | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp b/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
index d418a297218eb06..036719be06d83f1 100644
--- a/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
+++ b/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
@@ -200,7 +200,7 @@ static cl::opt<bool> EnableGISelLoadStoreOptPostLegal(
static cl::opt<bool>
EnableSinkFold("aarch64-enable-sink-fold",
cl::desc("Enable sinking and folding of instruction copies"),
- cl::init(false), cl::Hidden);
+ cl::init(true), cl::Hidden);
extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAArch64Target() {
// Register the target.
diff --git a/llvm/test/CodeGen/AArch64/sink-and-fold.ll b/llvm/test/CodeGen/AArch64/sink-and-fold.ll
index 632fdb391053121..52007221e12a7b5 100644
--- a/llvm/test/CodeGen/AArch64/sink-and-fold.ll
+++ b/llvm/test/CodeGen/AArch64/sink-and-fold.ll
@@ -1,5 +1,5 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc -aarch64-enable-sink-fold=true < %s | FileCheck %s
+; RUN: llc < %s | FileCheck %s
target triple = "aarch64-linux"
declare i32 @use(...)
More information about the llvm-commits
mailing list