[llvm-branch-commits] [Flang][OpenMP][MLIR] Extend derived (record) type map support in Flang OpenMP by adding some initial support for explicit member mapping (PR #81511)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Feb 14 08:33:12 PST 2024


================
@@ -1906,8 +2036,22 @@ bool ClauseProcessor::processMap(
 
         for (const Fortran::parser::OmpObject &ompObject :
              std::get<Fortran::parser::OmpObjectList>(mapClause->v.t).v) {
+          llvm::omp::OpenMPOffloadMappingFlags objectsMapTypeBits = mapTypeBits;
+          checkAndApplyDeclTargetMapFlags(converter, objectsMapTypeBits,
+                                          getOmpObjectSymbol(ompObject));
+
           llvm::SmallVector<mlir::Value> bounds;
           std::stringstream asFortran;
+          const Fortran::semantics::Symbol *parentSym = nullptr;
+
+          if (getOmpObjectSymbol(ompObject)->owner().IsDerivedType()) {
+            memberPlacementIndices.push_back(
+                firOpBuilder.getI64IntegerAttr(findComponenetMemberPlacement(
+                    getOmpObjectSymbol(ompObject)->owner().symbol(),
----------------
agozillon wrote:

Not a dumb question at all (no question is imo!), and someone else may be able to shine further light on it if my assumptions are wrong (still learning my away around the derived types myself).

I believe the way `getOmpObjParentSymbol `is currently set up so that it will retrieve the first symbol in the list (as it uses `getLastName`), e.g. if we had some kind of nested derived type mapping like below:

`map(to: dtype1%dtype2%scalar)`

>From my understanding we'd get `dtype1`, in the case of `getOmpObjectSymbol(ompObject)->owner().symbol()`, we would get `dtype2`, the difference between one up and the first effectively! And in the above case we would like to get the index of the member in its direct parent I believe. 

However, for the currently covered set of cases by this PR using either should result in the same result I believe, so perhaps I was getting a little ahead of myself with this line!

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


More information about the llvm-branch-commits mailing list