[PATCH] D151314: [RegisterCoalescer] Fix updating LiveIntervals in joinReservedPhysReg
Jay Foad via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 24 04:04:19 PDT 2023
foad created this revision.
Herald added subscribers: StephenFan, tpr, hiraditya, qcolombet, MatzeB.
Herald added a project: All.
foad requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Live intervals for physical registers are calculated lazily on demand.
In a case like this:
16B %0:gpr32 = IMPLICIT_DEF
32B $wzr = COPY %0
if the live interval for $wzr did not already exist then the update code
in joinReservedPhysReg would create it with a definition at 32B, which
would remain even after the COPY was deleted.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D151314
Files:
llvm/lib/CodeGen/RegisterCoalescer.cpp
llvm/test/CodeGen/AArch64/regcoal-physreg.mir
Index: llvm/test/CodeGen/AArch64/regcoal-physreg.mir
===================================================================
--- llvm/test/CodeGen/AArch64/regcoal-physreg.mir
+++ llvm/test/CodeGen/AArch64/regcoal-physreg.mir
@@ -1,4 +1,4 @@
-# RUN: llc -mtriple=aarch64-apple-ios -run-pass=simple-register-coalescing -verify-machineinstrs %s -o - | FileCheck %s
+# RUN: llc -mtriple=aarch64-apple-ios -run-pass=simple-register-coalescing,simple-register-coalescing -verify-machineinstrs %s -o - | FileCheck %s
--- |
declare void @f2()
Index: llvm/lib/CodeGen/RegisterCoalescer.cpp
===================================================================
--- llvm/lib/CodeGen/RegisterCoalescer.cpp
+++ llvm/lib/CodeGen/RegisterCoalescer.cpp
@@ -2196,6 +2196,8 @@
// ...
// use %physreg_x
CopyMI = MRI->getVRegDef(SrcReg);
+
+ deleteInstr(CopyMI);
} else {
// VReg is copied into physreg:
// %y = def
@@ -2240,6 +2242,8 @@
<< printReg(DstReg, TRI) << " at " << CopyRegIdx << "\n");
LIS->removePhysRegDefAt(DstReg.asMCReg(), CopyRegIdx);
+ deleteInstr(CopyMI);
+
// Create a new dead def at the new def location.
for (MCRegUnitIterator UI(DstReg, TRI); UI.isValid(); ++UI) {
LiveRange &LR = LIS->getRegUnit(*UI);
@@ -2247,8 +2251,6 @@
}
}
- deleteInstr(CopyMI);
-
// We don't track kills for reserved registers.
MRI->clearKillFlags(CP.getSrcReg());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151314.525102.patch
Type: text/x-patch
Size: 1449 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230524/7f4fb89d/attachment.bin>
More information about the llvm-commits
mailing list