[flang-commits] [flang] [flang][OpenMP] Fix use_device_addr handling for COMMON blocks in target data (PR #217105)

via flang-commits flang-commits at lists.llvm.org
Mon Aug 24 07:51:41 PDT 2026


================
@@ -2212,14 +2204,37 @@ bool ClauseProcessor::processEnter(
 bool ClauseProcessor::processUseDeviceAddr(
     lower::StatementContext &stmtCtx, mlir::omp::UseDeviceAddrClauseOps &result,
     llvm::SmallVectorImpl<Object> &useDeviceObjects) const {
+  llvm::SmallPtrSet<const semantics::Symbol *, 4> mappedCommonBlocks;
+  findRepeatableClause<omp::clause::Map>(
+      [&](const omp::clause::Map &clause, const parser::CharBlock &) {
+        for (const Object &object : std::get<ObjectList>(clause.t)) {
+          if (object.sym()->has<semantics::CommonBlockDetails>())
+            mappedCommonBlocks.insert(&object.sym()->GetUltimate());
+        }
+      });
+
   std::map<Object, OmpMapParentAndMemberData> parentMemberIndices;
   bool clauseFound = findRepeatableClause<omp::clause::UseDeviceAddr>(
       [&](const omp::clause::UseDeviceAddr &clause,
           const parser::CharBlock &source) {
         mlir::Location location = converter.genLocation(source);
         mlir::omp::ClauseMapFlags mapTypeBits =
             mlir::omp::ClauseMapFlags::return_param;
-        processMapObjects(stmtCtx, location, clause.v, mapTypeBits,
+        ObjectList objects;
+        // Keep the aggregate only when it pairs with a whole-COMMON map on
+        // this directive; otherwise preserve named-COMMON member equivalence.
+        for (const Object &object : clause.v) {
----------------
agozillon wrote:

Could perhaps move this deeper into processMapObjects if it's behaviour you think is relevant elsewhere for common block handling or verify that processMapObjects doesn't handle this in someway already (I think map expands it currently but you'd have to double check that it does and where it does it, it's been a little bit since I checked the common block handling). 

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


More information about the flang-commits mailing list