[flang-commits] [flang] [llvm] [mlir] [flang][OpenMP] Lower target in_reduction for host fallback (PR #199967)
Sairudra More via flang-commits
flang-commits at lists.llvm.org
Tue Jun 30 23:32:52 PDT 2026
================
@@ -2220,12 +2221,25 @@ genTargetClauses(lower::AbstractConverter &converter,
hostEvalInfo->collectValues(clauseOps.hostEvalVars);
}
cp.processIf(llvm::omp::Directive::OMPD_target, clauseOps);
+ cp.processInReduction(loc, clauseOps, inReductionObjects);
+ // The host fallback for `target in_reduction` redirects each list item's
+ // dedicated implicit map entry to the per-task reduction-private storage
+ // returned by the runtime. A COMMON block member is accessed in the target
+ // body through the COMMON block storage map, not through its own member map
+ // entry, so the redirect would rewrite an unused map argument and the body
+ // would accumulate into the mapped original rather than the private copy.
+ // Reject this case until the redirect can target the storage map.
+ for (const Object &object : inReductionObjects)
+ if (const semantics::Symbol *sym = object.sym())
+ if (semantics::FindCommonBlockContaining(sym->GetUltimate()))
----------------
Saieiei wrote:
Thanks, I covered this as well.
I extended the storage-association guard to reject `target in_reduction` list items that are part of an EQUIVALENCE set. This keeps the patch conservative and avoids the case where the runtime-private pointer is produced but the body updates aliased mapped storage instead.
I added a targeted TODO test for the EQUIVALENCE case.
https://github.com/llvm/llvm-project/pull/199967
More information about the flang-commits
mailing list