Skip to content

Commit cc3d634

Browse files
committed
Print region argument only when argAttrs are present
Fixes: #132894
1 parent d724bab commit cc3d634

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

mlir/lib/Interfaces/CallInterfaces.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ void call_interface_impl::printFunctionSignature(
118118
ArrayRef<NamedAttribute> attrs;
119119
if (argAttrs)
120120
attrs = llvm::cast<DictionaryAttr>(argAttrs[i]).getValue();
121-
p.printRegionArgument(body->getArgument(i), attrs);
121+
if (body->getNumArguments() > i)
122+
p.printRegionArgument(body->getArgument(i), attrs);
122123
} else {
123124
p.printType(argTypes[i]);
124125
if (argAttrs)

mlir/test/mlir-opt/print-region.mlir

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Bug: https://github.com/llvm/llvm-project/issues/132894
2+
3+
// RUN: mlir-opt %s | FileCheck
4+
5+
// CHECK: module {
6+
// CHECK: spirv.func @f(f32) "None" {
7+
// CHECK: %c0 = arith.constant 0 : index
8+
// CHECK: spirv.Return
9+
// CHECK: }
10+
// CHECK: }
11+
12+
module {
13+
spirv.func @f(f32) "None" {
14+
%c0 = arith.constant 0 : index
15+
spirv.Return
16+
}
17+
}

0 commit comments

Comments
 (0)