[llvm] [RA] Fix the live range for early-clobber (PR #152895)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 10 00:10:36 PDT 2025
https://github.com/LuoYuanke updated https://github.com/llvm/llvm-project/pull/152895
>From 447fec6e03690f0cea59050891b659b21829a6b8 Mon Sep 17 00:00:00 2001
From: Yuanke Luo <ykluo at birentech.com>
Date: Sun, 10 Aug 2025 10:40:51 +0800
Subject: [PATCH] [RA] Fix the live range for early-clobber
When rematerialize a virtual register the register may be early clobbered.
However rematerializeAt(...) just return the slot index of Slot_Register
which cause mis-calculating live range for the register
---
llvm/lib/CodeGen/LiveRangeEdit.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/CodeGen/LiveRangeEdit.cpp b/llvm/lib/CodeGen/LiveRangeEdit.cpp
index a3858efbdc5e1..bd388b97cbcd4 100644
--- a/llvm/lib/CodeGen/LiveRangeEdit.cpp
+++ b/llvm/lib/CodeGen/LiveRangeEdit.cpp
@@ -192,7 +192,9 @@ SlotIndex LiveRangeEdit::rematerializeAt(MachineBasicBlock &MBB,
if (ReplaceIndexMI)
return LIS.ReplaceMachineInstrInMaps(*ReplaceIndexMI, *MI).getRegSlot();
- return LIS.getSlotIndexes()->insertMachineInstrInMaps(*MI, Late).getRegSlot();
+ bool EarlyClobber = MI->getOperand(0).isEarlyClobber();
+ return LIS.getSlotIndexes()->insertMachineInstrInMaps(*MI, Late).getRegSlot(
+ EarlyClobber);
}
void LiveRangeEdit::eraseVirtReg(Register Reg) {
More information about the llvm-commits
mailing list