[Mlir-commits] [mlir] [mlir][spirv] Fix lookup logic `spirv.target_env` for `gpu.module` (PR #147262)

Jakub Kuderski llvmlistbot at llvm.org
Thu Jul 24 07:09:12 PDT 2025


================
@@ -385,6 +385,11 @@ LogicalResult GPUModuleConversion::matchAndRewrite(
   if (auto attr = moduleOp->getAttrOfType<spirv::TargetEnvAttr>(
           spirv::getTargetEnvAttrName()))
     spvModule->setAttr(spirv::getTargetEnvAttrName(), attr);
+  if (ArrayAttr targets = moduleOp.getTargetsAttr()) {
+    for (Attribute targetAttr : targets)
+      if (auto spirvTargetEnvAttr = dyn_cast<spirv::TargetEnvAttr>(targetAttr))
+        spvModule->setAttr(spirv::getTargetEnvAttrName(), spirvTargetEnvAttr);
----------------
kuhar wrote:

What happens when there's more than one target env attribute in the array? IIUC, this will always pick the last one.

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


More information about the Mlir-commits mailing list