[Openmp-commits] [PATCH] D104382: [OpenMP][Offloading] Refined return value of `DeviceTy::getOrAllocTgtPtr`

George Rokos via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Thu Jun 17 00:47:27 PDT 2021


grokos added inline comments.


================
Comment at: openmp/libomptarget/src/device.cpp:191
 // Used by targetDataBegin
-// Return the target pointer begin (where the data will be moved).
+// Return a struct contains target pointer begin (where the data will be moved).
 // Allocate memory if this is the first occurrence of this mapping.
----------------
contains --> containing


================
Comment at: openmp/libomptarget/src/device.cpp:275
          (HstPtrName) ? getNameFromMapping(HstPtrName).c_str() : "unknown");
-    HostDataToTargetMap.emplace(
-        HostDataToTargetTy((uintptr_t)HstPtrBase, (uintptr_t)HstPtrBegin,
-                           (uintptr_t)HstPtrBegin + Size, tp, HstPtrName));
-    rc = (void *)tp;
+    HostDataToTargetMap.emplace((uintptr_t)HstPtrBase, (uintptr_t)HstPtrBegin,
+                                (uintptr_t)HstPtrBegin + Size, Ptr, HstPtrName);
----------------
I think `emplace` returns an iterator to the newly emplaced element. You can set `Entry` equal to the return value of this `emplace`, thus sparing a lookup a couple of lines below.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104382/new/

https://reviews.llvm.org/D104382



More information about the Openmp-commits mailing list