[flang-commits] [flang] [llvm] [mlir] [Flang][OpenMP] Fix Fortran automap handling (PR #162501)

via flang-commits flang-commits at lists.llvm.org
Tue Jun 2 00:09:49 PDT 2026


================
@@ -932,6 +932,34 @@ class MapInfoFinalizationPass
     return false;
   }
 
+  static bool isAttachMap(mlir::omp::MapInfoOp op) {
+    return (op.getMapType() & mlir::omp::ClauseMapFlags::attach) ==
+           mlir::omp::ClauseMapFlags::attach;
+  }
+
+  static bool isDescriptorOnlyMap(mlir::omp::MapInfoOp op) {
+    // A descriptor-only map keeps the descriptor object present so that a
+    // subsequent attach map can update its base address. It intentionally does
+    // not map the descriptor's pointee data, so descriptor member expansion
+    // must leave it alone.
+    if (!op.getPartialMap() || !op.getMembers().empty() ||
+        !op.getBounds().empty() || op.getVarPtrPtr() ||
+        op.getMapCaptureType() != mlir::omp::VariableCaptureKind::ByRef)
----------------
agozillon wrote:

Please rebase and see if defining a map inside of AutomapToTargetData.cpp that utilises a ref_ptr map does what you want in this case, and perhaps it would be feasible to avoid the changes to this file, as in theory, the right combination of ref_ptr + other maps should get you what you want. 

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


More information about the flang-commits mailing list