[flang-commits] [flang] [Flang][OpenMP] Fix nested OpenMP mapper composition (PR #215639)
Akash Banerjee via flang-commits
flang-commits at lists.llvm.org
Wed Aug 12 09:55:19 PDT 2026
================
@@ -138,6 +138,75 @@ class MapInfoFinalizationPass
return findMemberByIndexPath(op, indexPath) != nullptr;
}
+ static bool mapperCoversIndexPath(
+ mlir::Operation *symbolTableAnchor, mlir::FlatSymbolRefAttr mapperId,
+ llvm::ArrayRef<int64_t> indexPath,
+ llvm::SmallPtrSetImpl<mlir::Operation *> &visitedMappers) {
+ mlir::omp::DeclareMapperOp symbol =
+ mlir::SymbolTable::lookupNearestSymbolFrom<mlir::omp::DeclareMapperOp>(
+ symbolTableAnchor, mapperId);
+ if (!symbol || !visitedMappers.insert(symbol.getOperation()).second)
+ return false;
+
+ mlir::omp::DeclareMapperInfoOp mapperInfo = symbol.getDeclareMapperInfo();
+ if (!mapperInfo)
+ return false;
+
+ return llvm::any_of(mapperInfo.getMapVars(), [&](mlir::Value v) {
+ mlir::omp::MapInfoOp map =
+ mlir::dyn_cast_if_present<mlir::omp::MapInfoOp>(v.getDefiningOp());
+ return map && !map.getMembers().empty() &&
+ map.getMembersIndexAttr() &&
+ mapInfoCoversIndexPath(map, indexPath, visitedMappers);
+ });
+ }
+
+ static bool mapInfoCoversIndexPath(
+ mlir::omp::MapInfoOp map, llvm::ArrayRef<int64_t> indexPath,
+ llvm::SmallPtrSetImpl<mlir::Operation *> &visitedMappers) {
+ if (mappedIndexPathExists(map, indexPath))
+ return true;
+
+ mlir::ArrayAttr memberIndices = map.getMembersIndexAttr();
+ if (!memberIndices)
+ return false;
+
+ for (auto [memberIdx, memberIndexAttr] : llvm::enumerate(memberIndices)) {
----------------
TIFitis wrote:
Thanks for the suggestion, I've added a comment.
https://github.com/llvm/llvm-project/pull/215639
More information about the flang-commits
mailing list