[Mlir-commits] [mlir] Print region argument only when argAttrs are present (PR #133167)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Mar 26 16:46:18 PDT 2025


https://github.com/hiraditya updated https://github.com/llvm/llvm-project/pull/133167

>From 30187f5dd0d52f3591adca490e39581a680d0b5e Mon Sep 17 00:00:00 2001
From: AdityaK <hiraditya at msn.com>
Date: Wed, 26 Mar 2025 14:38:25 -0700
Subject: [PATCH] Print region argument only when argAttrs are present

Fixes: #132894
---
 mlir/lib/Interfaces/CallInterfaces.cpp |  3 ++-
 mlir/test/mlir-opt/print-region.mlir   | 17 +++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)
 create mode 100644 mlir/test/mlir-opt/print-region.mlir

diff --git a/mlir/lib/Interfaces/CallInterfaces.cpp b/mlir/lib/Interfaces/CallInterfaces.cpp
index e8ed4b339a0cb..f93f9766d196c 100644
--- a/mlir/lib/Interfaces/CallInterfaces.cpp
+++ b/mlir/lib/Interfaces/CallInterfaces.cpp
@@ -118,7 +118,8 @@ void call_interface_impl::printFunctionSignature(
       ArrayRef<NamedAttribute> attrs;
       if (argAttrs)
         attrs = llvm::cast<DictionaryAttr>(argAttrs[i]).getValue();
-      p.printRegionArgument(body->getArgument(i), attrs);
+      if (body->getNumArguments() > i)
+        p.printRegionArgument(body->getArgument(i), attrs);
     } else {
       p.printType(argTypes[i]);
       if (argAttrs)
diff --git a/mlir/test/mlir-opt/print-region.mlir b/mlir/test/mlir-opt/print-region.mlir
new file mode 100644
index 0000000000000..2a69462260394
--- /dev/null
+++ b/mlir/test/mlir-opt/print-region.mlir
@@ -0,0 +1,17 @@
+// Bug: https://github.com/llvm/llvm-project/issues/132894
+
+// RUN: mlir-opt %s | FileCheck %s
+
+// CHECK: module {
+// CHECK:   spirv.func @f() "None" {
+// CHECK:     %c0 = arith.constant 0 : index
+// CHECK:     spirv.Return
+// CHECK:   }
+// CHECK: }
+
+module {
+  spirv.func @f(f32) "None" {
+    %c0 = arith.constant 0 : index
+    spirv.Return
+  }
+}



More information about the Mlir-commits mailing list