[llvm] 61653f8 - Reland "[InitUndef] handleSubReg should skip artificial subregs. (#116248)"

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 28 01:57:04 PST 2024


Author: Sander de Smalen
Date: 2024-11-28T09:56:11Z
New Revision: 61653f8e39666ea974561fd9ddccd7d473852fad

URL: https://github.com/llvm/llvm-project/commit/61653f8e39666ea974561fd9ddccd7d473852fad
DIFF: https://github.com/llvm/llvm-project/commit/61653f8e39666ea974561fd9ddccd7d473852fad.diff

LOG: Reland "[InitUndef] handleSubReg should skip artificial subregs. (#116248)"

This patch can now reland after 318c69de52b6 relanded #114827.

This reverts commit 1683f84d289348ba6879635c4161979204f75230.

Added: 
    

Modified: 
    llvm/lib/CodeGen/InitUndef.cpp
    llvm/test/CodeGen/AArch64/init-undef.mir

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/InitUndef.cpp b/llvm/lib/CodeGen/InitUndef.cpp
index d4ac131a32a959..d8b3190f31003e 100644
--- a/llvm/lib/CodeGen/InitUndef.cpp
+++ b/llvm/lib/CodeGen/InitUndef.cpp
@@ -164,6 +164,14 @@ bool InitUndef::handleSubReg(MachineFunction &MF, MachineInstr &MI,
     TRI->getCoveringSubRegIndexes(*MRI, TargetRegClass, NeedDef,
                                   SubRegIndexNeedInsert);
 
+    // It's not possible to create the INIT_UNDEF when there is no register
+    // class associated for the subreg. This may happen for artificial subregs
+    // that are not directly addressable.
+    if (any_of(SubRegIndexNeedInsert, [&](unsigned Ind) -> bool {
+          return !TRI->getSubRegisterClass(TargetRegClass, Ind);
+        }))
+      continue;
+
     Register LatestReg = Reg;
     for (auto ind : SubRegIndexNeedInsert) {
       Changed = true;

diff  --git a/llvm/test/CodeGen/AArch64/init-undef.mir b/llvm/test/CodeGen/AArch64/init-undef.mir
index 7935c09d7df5ec..c9d23006d35234 100644
--- a/llvm/test/CodeGen/AArch64/init-undef.mir
+++ b/llvm/test/CodeGen/AArch64/init-undef.mir
@@ -1,5 +1,6 @@
 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5
-# RUN: llc -mtriple=aarch64-- -run-pass=init-undef -o - %s | FileCheck %s
+# RUN: llc -mtriple=aarch64-- -aarch64-enable-subreg-liveness-tracking=false -run-pass=init-undef -o - %s | FileCheck %s
+# RUN: llc -mtriple=aarch64-- -aarch64-enable-subreg-liveness-tracking=true -run-pass=init-undef -o - %s | FileCheck %s
 
 ---
 name:            test_stxp_undef


        


More information about the llvm-commits mailing list