[Mlir-commits] [mlir] [MLIR][OpenMP] Prevent openmp-device attribute being added to the host (PR #207719)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Jul 6 05:36:56 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir-llvm

Author: Sergio Afonso (skatrak)

<details>
<summary>Changes</summary>

This attribute is only intended for an OpenMP target device but a recent patch started causing it to appear on the host. This causes the OpenMPOpt pass to treat the LLVM IR module as an OpenMP offloading target, potentially introducing invalid modifications.

Intended to fix #<!-- -->207423.

---
Full diff: https://github.com/llvm/llvm-project/pull/207719.diff


1 Files Affected:

- (modified) mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp (+3-3) 


``````````diff
diff --git a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
index a287644207724..27493bfedadeb 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -7796,13 +7796,13 @@ convertFlagsAttr(Operation *op, mlir::omp::FlagsAttr attribute,
 
   llvm::OpenMPIRBuilder *ompBuilder = moduleTranslation.getOpenMPBuilder();
 
-  ompBuilder->M.addModuleFlag(llvm::Module::Max, "openmp-device",
-                              attribute.getOpenmpDeviceVersion());
-
   // The flags below are only intended to be emitted for GPU offload targets.
   if (!offloadMod.getIsGPU())
     return success();
 
+  ompBuilder->M.addModuleFlag(llvm::Module::Max, "openmp-device",
+                              attribute.getOpenmpDeviceVersion());
+
   if (attribute.getNoGpuLib())
     return success();
 

``````````

</details>


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


More information about the Mlir-commits mailing list