[flang] [llvm] [mlir] [Flang][OpenMP] Update MapInfoFinalization to use BlockArgs Interface and modify use_device_ptr/addr to be order independent (PR #113919)

Sergio Afonso via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 31 07:24:15 PDT 2024


================
@@ -2327,21 +2327,20 @@ static void collectMapDataFromMapOperands(
     mapData.IsAMember.push_back(checkIsAMember(mapVars, mapOp));
   }
 
-  auto findMapInfo = [&mapData](llvm::Value *val,
-                                llvm::OpenMPIRBuilder::DeviceInfoTy devInfoTy) {
-    unsigned index = 0;
-    bool found = false;
-    for (llvm::Value *basePtr : mapData.OriginalValue) {
-      if (basePtr == val && mapData.IsAMapping[index]) {
-        found = true;
-        mapData.Types[index] |=
-            llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_RETURN_PARAM;
-        mapData.DevicePointers[index] = devInfoTy;
-      }
-      index++;
-    }
-    return found;
-  };
+  // This function alters the original mapped pointers type if it was present in
+  // a map clause as well as being present in a useDevAddr/Ptr clause.
+  auto alterAndCreateUseDevMapType =
+      [&mapData](llvm::Value *val,
+                 llvm::OpenMPIRBuilder::DeviceInfoTy devInfoTy) {
+        for (auto [i, origVal] : llvm::enumerate(mapData.OriginalValue)) {
----------------
skatrak wrote:

Nit: Consider using `zip_equal` instead, if possible (not sure if assignments below are possible using this approach):
```suggestion
        for (auto [origVal, isMapping, type, devicePointer] : llvm::zip_equal(mapData.OriginalValue, mapData.IsAMapping, mapData.Types, mapData.DevicePointers)) {
```

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


More information about the llvm-commits mailing list