[flang-commits] [flang] [flang][OpenMP][DoConcurrent] Emit declare mapper for records (PR #179936)

Pranav Bhandarkar via flang-commits flang-commits at lists.llvm.org
Sun Feb 8 15:24:48 PST 2026


================
@@ -583,12 +584,46 @@ class DoConcurrentConversion
     llvm::SmallVector<mlir::Value> boundsOps;
     genBoundsOps(builder, liveIn, rawAddr, boundsOps);
 
+    auto asRecordType = [&](mlir::Type eleType) {
+      fir::RecordType recordType = mlir::dyn_cast<fir::RecordType>(eleType);
+
+      if (auto seqType = mlir::dyn_cast<fir::SequenceType>(eleType))
+        recordType = mlir::dyn_cast<fir::RecordType>(seqType.getElementType());
+
+      return recordType;
+    };
+
+    fir::RecordType recordType = asRecordType(eleType);
+
+    bool requiresImplcitMapper = [&]() {
+      if (!recordType)
+        return false;
+
+      for (auto [fieldName, fieldType] : recordType.getTypeList()) {
+        if (fir::isAllocatableType(fieldType))
+          return true;
+
+        if (asRecordType(fieldType))
+          TODO(liveIn.getLoc(), "Nested record types are not supported yet.");
+      }
+
+      return false;
+    }();
+
+    mlir::FlatSymbolRefAttr mapperId;
+    if (requiresImplcitMapper) {
+      std::string mapperIdName =
+          recordType.getName().str() + llvm::omp::OmpDefaultMapperName;
+      mapperId = Fortran::utils::openmp::getOrGenImplicitDefaultDeclareMapper(
----------------
bhandarkar-pranav wrote:

< nit > : I know that right now this pass does not support nested records, but `getOrGenImplicitDefaultDeclareMapper` unconditionally calls the mangler if dealing with nested records. So, may be you should put a future/TODO comment here that reminds you to provide a mangler once you enable nested records

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


More information about the flang-commits mailing list