[llvm] 1818943 - [SystemZ] Add check for INIT_UNDEF in getInstSizeInBytes (#134661)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 10 13:16:24 PDT 2025
Author: tltao
Date: 2025-04-10T16:16:20-04:00
New Revision: 18189430abbbc13b055d029683413e992a3eac2d
URL: https://github.com/llvm/llvm-project/commit/18189430abbbc13b055d029683413e992a3eac2d
DIFF: https://github.com/llvm/llvm-project/commit/18189430abbbc13b055d029683413e992a3eac2d.diff
LOG: [SystemZ] Add check for INIT_UNDEF in getInstSizeInBytes (#134661)
Due to some optimization changes, INIT_UNDEF is making its way to
`getInstSizeInBytes` in `llvm/lib/Target/SystemZ/SystemZLongBranch.cpp`
but we do not have an exception there in the assert. Since INIT_UNDEF is
described as being similar to IMPLICIT_DEF and there is a check for
IMPLICIT_DEF, it seems logical to also add a check for INIT_UNDEF.
---------
Co-authored-by: Tony Tao <tonytao at ca.ibm.com>
Added:
llvm/test/CodeGen/SystemZ/init-undef.mir
Modified:
llvm/lib/Target/SystemZ/SystemZLongBranch.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/SystemZ/SystemZLongBranch.cpp b/llvm/lib/Target/SystemZ/SystemZLongBranch.cpp
index d50d7e419faeb..b327c1be69d15 100644
--- a/llvm/lib/Target/SystemZ/SystemZLongBranch.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZLongBranch.cpp
@@ -216,6 +216,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.getOpcode() == TargetOpcode::INIT_UNDEF ||
// These have a size that may be zero:
MI.isInlineAsm() || MI.getOpcode() == SystemZ::STACKMAP ||
MI.getOpcode() == SystemZ::PATCHPOINT ||
diff --git a/llvm/test/CodeGen/SystemZ/init-undef.mir b/llvm/test/CodeGen/SystemZ/init-undef.mir
new file mode 100644
index 0000000000000..101dc6ebf8fd5
--- /dev/null
+++ b/llvm/test/CodeGen/SystemZ/init-undef.mir
@@ -0,0 +1,17 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5
+# REQUIRES: asserts
+# RUN: llc -run-pass systemz-long-branch -mtriple=s390x-ibm-zos -o - %s | FileCheck %s
+
+# Makes sure INIT_UNDEF does not crash the compiler in systemz-long-branch
+---
+name: func0
+body: |
+ bb.0.entry:
+ ; CHECK-LABEL: name: func0
+ ; CHECK: renamable $r0l = INIT_UNDEF
+ ; CHECK-NEXT: renamable $r3d = LGFR killed renamable $r0l
+ ; CHECK-NEXT: frame-destroy Return_XPLINK implicit $r3d
+ renamable $r0l = INIT_UNDEF
+ renamable $r3d = LGFR killed renamable $r0l
+ frame-destroy Return_XPLINK implicit $r3d
+...
More information about the llvm-commits
mailing list