[flang-commits] [flang] [mlir] [Flang][MLIR][OpenMP] - Add support for firstprivate when translating omp.target ops from MLIR to LLVMIR (PR #131213)

Kareem Ergawy via flang-commits flang-commits at lists.llvm.org
Mon Apr 28 21:14:27 PDT 2025


================
@@ -158,5 +169,50 @@ class MapsForPrivatizedSymbolsPass
       }
     }
   }
+  // As the name suggests, this function examines var to determine if
+  // it has dynamic size. If true, this pass'll have to extract these
+  // bounds from descriptor of var and add the bounds to the resultant
+  // MapInfoOp.
+  bool needsBoundsOps(mlir::Value var) {
+    assert(mlir::isa<omp::PointerLikeType>(var.getType()) &&
+           "needsBoundsOps can deal only with pointer types");
+    mlir::Type t = fir::unwrapRefType(var.getType());
+    // t could be a box, so look inside the box
+    auto innerType = fir::dyn_cast_ptrOrBoxEleTy(t);
+    if (innerType)
+      return fir::hasDynamicSize(innerType);
+    return fir::hasDynamicSize(t);
+  }
+
+  void genBoundsOps(fir::FirOpBuilder &builder, mlir::Value var,
----------------
ergawy wrote:

Apologies for not catching this before, but can we use `fir::factory::genImplicitBoundsOps` instead of introducing a new util? If so, we can do that in a later PR (we can just add a todo here).

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


More information about the flang-commits mailing list