[PATCH] D151314: [RegisterCoalescer] Fix updating LiveIntervals in joinReservedPhysReg

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 24 07:21:43 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0ea5eb143c7a: [RegisterCoalescer] Fix updating LiveIntervals in joinReservedPhysReg (authored by foad).

Changed prior to commit:
  https://reviews.llvm.org/D151314?vs=525104&id=525170#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151314/new/

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,8 @@
-# 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
+
+# FIXME: Second run of the pass is a workaround for a bug in
+# -run-pass. The verifier doesn't detect broken LiveIntervals, see bug
+# 46873
 --- |
   declare void @f2()
 
Index: llvm/lib/CodeGen/RegisterCoalescer.cpp
===================================================================
--- llvm/lib/CodeGen/RegisterCoalescer.cpp
+++ llvm/lib/CodeGen/RegisterCoalescer.cpp
@@ -2196,6 +2196,7 @@
     //   ...
     //   use %physreg_x
     CopyMI = MRI->getVRegDef(SrcReg);
+    deleteInstr(CopyMI);
   } else {
     // VReg is copied into physreg:
     //   %y = def
@@ -2240,6 +2241,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 +2250,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.525170.patch
Type: text/x-patch
Size: 1592 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230524/ca6cd318/attachment.bin>


More information about the llvm-commits mailing list