[flang-commits] [flang] [llvm] [Flang][OpenMP] Defer descriptor mapping for assumed dummy argument types (PR #154349)
Kareem Ergawy via flang-commits
flang-commits at lists.llvm.org
Thu Aug 21 02:28:04 PDT 2025
================
@@ -593,6 +656,125 @@ class MapInfoFinalizationPass
return nullptr;
}
+ void addImplictDescriptorMapToTargetDataOp(mlir::omp::MapInfoOp op,
+ fir::FirOpBuilder &builder,
+ mlir::Operation *target) {
+ // Checks if the map is present as an explicit map already on the target
+ // data directive, and not just present on a use_device_addr/ptr, as if
+ // that's the case, we should not need to add an implicit map for the
+ // descriptor.
+ auto explicitMappingPresent = [](mlir::omp::MapInfoOp op,
+ mlir::omp::TargetDataOp tarData) {
+ // Verify top-level descriptor mapping is at least equal with same
+ // varPtr, the map type should always be To for a descriptor, which is
+ // all we really care about for this mapping as we aim to make sure the
+ // descriptor is always present on device if we're expecting to access
+ // the underlying data.
+ if (tarData.getMapVars().empty())
+ return false;
+
+ for (mlir::Value mapVar : tarData.getMapVars()) {
+ auto mapOp =
+ llvm::dyn_cast<mlir::omp::MapInfoOp>(mapVar.getDefiningOp());
----------------
ergawy wrote:
```suggestion
llvm::cast<mlir::omp::MapInfoOp>(mapVar.getDefiningOp());
```
https://github.com/llvm/llvm-project/pull/154349
More information about the flang-commits
mailing list