[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
Mon Jul 27 08:14:20 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:
Could dropping `deconstructed.kinds` cause PDTs such as `pdt(4)` and `pdt(8)` to reuse the same mapper symbol? Since mapper reuse is name-based without a type check, could you add a regression test for this case?
https://github.com/llvm/llvm-project/pull/212251
More information about the flang-commits
mailing list