[flang-commits] [flang] [mlir] [Flang][OpenMP] Add lowering support for is_device_ptr clause (PR #169331)
Kareem Ergawy via flang-commits
flang-commits at lists.llvm.org
Mon Dec 1 00:04:01 PST 2025
================
@@ -2531,6 +2533,41 @@ genTargetOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
loc, clauseOps, defaultMaps, hasDeviceAddrSyms,
isDevicePtrSyms, mapSyms);
+ if (!isDevicePtrSyms.empty()) {
+ // is_device_ptr maps get duplicated so the clause and synthesized
+ // has_device_addr entry each own a unique MapInfoOp user, keeping
+ // MapInfoFinalization happy while still wiring the symbol into
+ // has_device_addr when the user didn’t spell it explicitly.
+ fir::FirOpBuilder &builder = converter.getFirOpBuilder();
+ auto insertionPt = builder.saveInsertionPoint();
+ auto alreadyPresent = [&](const semantics::Symbol *sym) {
+ return llvm::any_of(hasDeviceAddrSyms, [&](const semantics::Symbol *s) {
+ return s && sym && s->GetUltimate() == sym->GetUltimate();
+ });
+ };
+
+ for (auto [idx, sym] : llvm::enumerate(isDevicePtrSyms)) {
+ mlir::Value mapVal = clauseOps.isDevicePtrVars[idx];
+ if (!sym || !mapVal)
+ continue;
+ auto mapInfo = mapVal.getDefiningOp<mlir::omp::MapInfoOp>();
+ if (!mapInfo)
----------------
ergawy wrote:
Same question as above.
https://github.com/llvm/llvm-project/pull/169331
More information about the flang-commits
mailing list