[flang-commits] [flang] [flang][OpenMP] Reuse canonical default mapper names for nested mappings - fix issue #210402 (PR #212251)

Sairudra More via flang-commits flang-commits at lists.llvm.org
Wed Jul 29 02:24:19 PDT 2026


================
@@ -13,11 +13,33 @@
 #include "flang/Optimizer/Builder/FIRBuilder.h"
 #include "flang/Optimizer/Dialect/FIROps.h"
 #include "flang/Optimizer/Dialect/FIRType.h"
+#include "flang/Optimizer/Support/InternalNames.h"
 
 #include "mlir/Dialect/OpenMP/OpenMPDialect.h"
 #include "mlir/Transforms/RegionUtils.h"
 
 namespace Fortran::utils::openmp {
+std::string getCanonicalDefaultDeclareMapperName(fir::RecordType recordType) {
+  auto [kind, deconstructed] =
+      fir::NameUniquer::deconstruct(recordType.getName());
+  if (kind != fir::NameUniquer::NameKind::DERIVED_TYPE)
+    return recordType.getName().str() + llvm::omp::OmpDefaultMapperName;
+
+  llvm::SmallVector<llvm::StringRef> modules;
+  llvm::SmallVector<llvm::StringRef> procs;
+  modules.reserve(deconstructed.modules.size());
+  procs.reserve(deconstructed.procs.size());
+  for (const std::string &module : deconstructed.modules)
+    modules.emplace_back(module);
+  for (const std::string &proc : deconstructed.procs) {
+    procs.emplace_back(proc);
+  }
+
+  std::string mapperName = deconstructed.name + llvm::omp::OmpDefaultMapperName;
----------------
Saieiei wrote:

Thanks for the update. Since explicit `declare mapper(default:)` names still omit PDT kinds, could this new spelling miss the explicit mapper? Can both paths use the same canonical naming and add a regression test?

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


More information about the flang-commits mailing list