[Mlir-commits] [mlir] [mlir][gpu-to-spirv] Add support for `gpu.func` workgroup attributions (PR #189744)

Igor Wodiany llvmlistbot at llvm.org
Thu Apr 9 13:20:06 PDT 2026


================
@@ -265,10 +265,26 @@ lowerAsEntryFunction(gpu::GPUFuncOp funcOp, const TypeConverter &typeConverter,
         "or none of them");
     return nullptr;
   }
+
+  // Collect workgroup attribution types before inlining moves the body.
+  unsigned numFuncArgs = fnType.getNumInputs();
+  unsigned numWorkgroupAttrs = funcOp.getNumWorkgroupAttributions();
+  SmallVector<Type> workgroupTypes;
+  for (auto wgAttr : funcOp.getWorkgroupAttributions()) {
+    auto convertedType = typeConverter.convertType(wgAttr.getType());
+    if (!convertedType) {
+      funcOp.emitError("unable to convert workgroup attribution type");
+      return nullptr;
+    }
+    workgroupTypes.push_back(convertedType);
+  }
+
   // Update the signature to valid SPIR-V types and add the ABI
   // attributes. These will be "materialized" by using the
-  // LowerABIAttributesPass.
-  TypeConverter::SignatureConversion signatureConverter(fnType.getNumInputs());
+  // LowerABIAttributesPass. The signature conversion covers both regular
+  // function arguments and workgroup attributions.
+  TypeConverter::SignatureConversion signatureConverter(numFuncArgs +
----------------
IgWod wrote:

We probably should move definitions of `numFuncArgs` and `numWorkgroupAttrs` just before this line.

https://github.com/llvm/llvm-project/pull/189744


More information about the Mlir-commits mailing list