[Mlir-commits] [mlir] [MLIR][OpenMP] Prevent openmp-device attribute being added to the host (PR #207719)
Sergio Afonso
llvmlistbot at llvm.org
Mon Jul 6 05:36:21 PDT 2026
https://github.com/skatrak created https://github.com/llvm/llvm-project/pull/207719
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.
>From 9dcf1794d48fc95be8eb37141a3b1417cf5938a2 Mon Sep 17 00:00:00 2001
From: Sergio Afonso <Sergio.AfonsoFumero at amd.com>
Date: Mon, 6 Jul 2026 13:31:56 +0100
Subject: [PATCH] [MLIR][OpenMP] Prevent openmp-device attribute being added to
the host
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.
---
.../LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
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();
More information about the Mlir-commits
mailing list