[llvm] [SystemZ] Add check for INIT_UNDEF in getInstSizeInBytes (PR #134661)

via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 7 07:58:34 PDT 2025


https://github.com/tltao updated https://github.com/llvm/llvm-project/pull/134661

>From 0769f5ca156045986654ca3209f4c7183716d483 Mon Sep 17 00:00:00 2001
From: Tony Tao <tonytao at ca.ibm.com>
Date: Mon, 7 Apr 2025 10:37:14 -0400
Subject: [PATCH 1/3] Add check for INIT_UNDEF in getInstSizeInBytes

---
 llvm/include/llvm/CodeGen/MachineInstr.h      | 1 +
 llvm/lib/Target/SystemZ/SystemZLongBranch.cpp | 1 +
 2 files changed, 2 insertions(+)

diff --git a/llvm/include/llvm/CodeGen/MachineInstr.h b/llvm/include/llvm/CodeGen/MachineInstr.h
index 102b1eb07358e..cd7b3055ad722 100644
--- a/llvm/include/llvm/CodeGen/MachineInstr.h
+++ b/llvm/include/llvm/CodeGen/MachineInstr.h
@@ -1409,6 +1409,7 @@ class MachineInstr
   }
   bool isKill() const { return getOpcode() == TargetOpcode::KILL; }
   bool isImplicitDef() const { return getOpcode()==TargetOpcode::IMPLICIT_DEF; }
+  bool isInitUndef() const { return getOpcode()==TargetOpcode::INIT_UNDEF; }
   bool isInlineAsm() const {
     return getOpcode() == TargetOpcode::INLINEASM ||
            getOpcode() == TargetOpcode::INLINEASM_BR;
diff --git a/llvm/lib/Target/SystemZ/SystemZLongBranch.cpp b/llvm/lib/Target/SystemZ/SystemZLongBranch.cpp
index f19b932f3c731..f0f33c960d822 100644
--- a/llvm/lib/Target/SystemZ/SystemZLongBranch.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZLongBranch.cpp
@@ -218,6 +218,7 @@ static unsigned getInstSizeInBytes(const MachineInstr &MI,
           // These do not have a size:
           MI.isDebugOrPseudoInstr() || MI.isPosition() || MI.isKill() ||
           MI.isImplicitDef() || MI.getOpcode() == TargetOpcode::MEMBARRIER ||
+          MI.isInitUndef() ||
           // These have a size that may be zero:
           MI.isInlineAsm() || MI.getOpcode() == SystemZ::STACKMAP ||
           MI.getOpcode() == SystemZ::PATCHPOINT ||

>From 51066169099b5e57c35c05538db83eeea8dc5dc5 Mon Sep 17 00:00:00 2001
From: Tony Tao <tonytao at ca.ibm.com>
Date: Mon, 7 Apr 2025 10:54:59 -0400
Subject: [PATCH 2/3] syntax fix

---
 llvm/include/llvm/CodeGen/MachineInstr.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/include/llvm/CodeGen/MachineInstr.h b/llvm/include/llvm/CodeGen/MachineInstr.h
index cd7b3055ad722..f68fd924e014f 100644
--- a/llvm/include/llvm/CodeGen/MachineInstr.h
+++ b/llvm/include/llvm/CodeGen/MachineInstr.h
@@ -1408,8 +1408,8 @@ class MachineInstr
            getOpcode() == TargetOpcode::G_PHI;
   }
   bool isKill() const { return getOpcode() == TargetOpcode::KILL; }
-  bool isImplicitDef() const { return getOpcode()==TargetOpcode::IMPLICIT_DEF; }
-  bool isInitUndef() const { return getOpcode()==TargetOpcode::INIT_UNDEF; }
+  bool isImplicitDef() const { return getOpcode() == TargetOpcode::IMPLICIT_DEF; }
+  bool isInitUndef() const { return getOpcode() == TargetOpcode::INIT_UNDEF; }
   bool isInlineAsm() const {
     return getOpcode() == TargetOpcode::INLINEASM ||
            getOpcode() == TargetOpcode::INLINEASM_BR;

>From c080f6bdf1a0e1401d53e064cb242735f8ef9d44 Mon Sep 17 00:00:00 2001
From: Tony Tao <tonytao at ca.ibm.com>
Date: Mon, 7 Apr 2025 10:58:23 -0400
Subject: [PATCH 3/3] undo syntax fix

---
 llvm/include/llvm/CodeGen/MachineInstr.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/include/llvm/CodeGen/MachineInstr.h b/llvm/include/llvm/CodeGen/MachineInstr.h
index f68fd924e014f..5d4ce8431a9c7 100644
--- a/llvm/include/llvm/CodeGen/MachineInstr.h
+++ b/llvm/include/llvm/CodeGen/MachineInstr.h
@@ -1408,7 +1408,7 @@ class MachineInstr
            getOpcode() == TargetOpcode::G_PHI;
   }
   bool isKill() const { return getOpcode() == TargetOpcode::KILL; }
-  bool isImplicitDef() const { return getOpcode() == TargetOpcode::IMPLICIT_DEF; }
+  bool isImplicitDef() const { return getOpcode()==TargetOpcode::IMPLICIT_DEF; }
   bool isInitUndef() const { return getOpcode() == TargetOpcode::INIT_UNDEF; }
   bool isInlineAsm() const {
     return getOpcode() == TargetOpcode::INLINEASM ||



More information about the llvm-commits mailing list