[flang-commits] [flang] [flang][OpenMP] Lower `target .. private(..)` to `omp.private` ops (PR #94195)

Kiran Chandramohan via flang-commits flang-commits at lists.llvm.org
Tue Jun 4 06:53:24 PDT 2024


================
@@ -758,15 +758,33 @@ genBodyOfTargetOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
                   llvm::ArrayRef<const semantics::Symbol *> mapSyms,
                   llvm::ArrayRef<mlir::Location> mapSymLocs,
                   llvm::ArrayRef<mlir::Type> mapSymTypes,
+                  DataSharingProcessor &dsp,
                   const mlir::Location &currentLocation,
                   const ConstructQueue &queue, ConstructQueue::iterator item) {
   assert(mapSymTypes.size() == mapSymLocs.size());
 
   fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
   mlir::Region &region = targetOp.getRegion();
-
-  auto *regionBlock =
-      firOpBuilder.createBlock(&region, {}, mapSymTypes, mapSymLocs);
+  mlir::OperandRange privateVars = targetOp.getPrivateVars();
+
+  llvm::SmallVector<mlir::Type> allRegionArgTypes;
+  allRegionArgTypes.reserve(mapSymTypes.size() +
+                            targetOp.getPrivateVars().size());
+  llvm::transform(mapSymTypes, std::back_inserter(allRegionArgTypes),
+                  [](mlir::Type t) { return t; });
+  llvm::transform(privateVars, std::back_inserter(allRegionArgTypes),
+                  [](mlir::Value v) { return v.getType(); });
+
+  llvm::SmallVector<mlir::Location> allRegionArgLocs;
+  allRegionArgTypes.reserve(mapSymTypes.size() +
+                            targetOp.getPrivateVars().size());
+  llvm::transform(mapSymLocs, std::back_inserter(allRegionArgLocs),
+                  [](mlir::Location l) { return l; });
+  llvm::transform(privateVars, std::back_inserter(allRegionArgLocs),
+                  [](mlir::Value v) { return v.getLoc(); });
+
+  auto *regionBlock = firOpBuilder.createBlock(&region, {}, allRegionArgTypes,
+                                               allRegionArgLocs);
----------------
kiranchandramohan wrote:

Add a comment for this block of code. Is it possible to share any of it with the parallel operation? Or is it not possible due to the isolated from above nature of target?

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


More information about the flang-commits mailing list