[llvm-branch-commits] [flang] [mlir] [mlir][OpenMP][flang] make private variable allocation implicit in omp.private (PR #124019)

Kareem Ergawy via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Jan 23 03:33:43 PST 2025


================
@@ -468,15 +505,49 @@ void DataSharingProcessor::doPrivatize(const semantics::Symbol *sym,
   lower::SymbolBox hsb = converter.lookupOneLevelUpSymbol(*sym);
   assert(hsb && "Host symbol box not found");
 
-  mlir::Type symType = hsb.getAddr().getType();
+  mlir::Value privVal = hsb.getAddr();
+  mlir::Type allocType;
+  if (mlir::isa<fir::PointerType>(privVal.getType()))
+    allocType = privVal.getType();
+  else
+    allocType = fir::unwrapRefType(privVal.getType());
+
   mlir::Location symLoc = hsb.getAddr().getLoc();
   std::string privatizerName = sym->name().ToString() + ".privatizer";
   bool isFirstPrivate = sym->test(semantics::Symbol::Flag::OmpFirstPrivate);
 
+  if (auto poly = mlir::dyn_cast<fir::ClassType>(allocType)) {
+    if (!mlir::isa<fir::PointerType>(poly.getEleTy()) && isFirstPrivate)
+      TODO(symLoc, "create polymorphic host associated copy");
+  }
----------------
ergawy wrote:

nit: move above closer to where we initialize `allocType`. Same for the next 2 if conditions as well as the declaration of `argType`. Just keeps all type handling in one visual block instead of being interrupted by privatizer stuff.

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


More information about the llvm-branch-commits mailing list