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

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Mar 26 14:39:49 PDT 2025


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

Fixes: #132894

>From fff2c53be1c194c7836ba0c9af1faaed73da33f4 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 |  5 +++--
 mlir/test/mlir-opt/print-region.mlir   | 17 +++++++++++++++++
 2 files changed, 20 insertions(+), 2 deletions(-)
 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..815b906d7d0f2 100644
--- a/mlir/lib/Interfaces/CallInterfaces.cpp
+++ b/mlir/lib/Interfaces/CallInterfaces.cpp
@@ -116,9 +116,10 @@ void call_interface_impl::printFunctionSignature(
 
     if (!isExternal) {
       ArrayRef<NamedAttribute> attrs;
-      if (argAttrs)
+      if (argAttrs) {
         attrs = llvm::cast<DictionaryAttr>(argAttrs[i]).getValue();
-      p.printRegionArgument(body->getArgument(i), attrs);
+        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..678457defff57
--- /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
+
+// CHECK: module {
+// CHECK:   spirv.func @f(f32) "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