[Openmp-commits] [openmp] edc0355 - [Libomptarget] Add missing explicit moves on llvm::Error

Joseph Huber via Openmp-commits openmp-commits at lists.llvm.org
Mon Mar 20 09:50:10 PDT 2023


Author: Joseph Huber
Date: 2023-03-20T11:49:59-05:00
New Revision: edc03550063ce1c39bb47bf94937cf036359b487

URL: https://github.com/llvm/llvm-project/commit/edc03550063ce1c39bb47bf94937cf036359b487
DIFF: https://github.com/llvm/llvm-project/commit/edc03550063ce1c39bb47bf94937cf036359b487.diff

LOG: [Libomptarget] Add missing explicit moves on llvm::Error

Summary:
Some older compilers, which we still support, have problems handling the
copy elision that allows us to directly move an `Error` to an
`Expected`. This patch adds explicit moves to remove the error.

Added: 
    

Modified: 
    openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
    openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp b/openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
index e03825651286d..5a31c5362265c 100644
--- a/openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
+++ b/openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
@@ -1863,7 +1863,7 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
     hsa_status_t Status =
         hsa_amd_memory_lock(HstPtr, Size, nullptr, 0, &PinnedPtr);
     if (auto Err = Plugin::check(Status, "Error in hsa_amd_memory_lock: %s\n"))
-      return Err;
+      return std::move(Err);
 
     return PinnedPtr;
   }

diff  --git a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
index 65983577f08fd..0b90d250b762b 100644
--- a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
+++ b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
@@ -703,7 +703,7 @@ Expected<void *> PinnedAllocationMapTy::lockHostBuffer(void *HstPtr,
   if (Entry) {
     // An already registered intersecting buffer was found. Register a new use.
     if (auto Err = registerEntryUse(*Entry, HstPtr, Size))
-      return Err;
+      return std::move(Err);
 
     // Return the device accessible pointer with the correct offset.
     return advanceVoidPtr(Entry->DevAccessiblePtr,
@@ -718,7 +718,7 @@ Expected<void *> PinnedAllocationMapTy::lockHostBuffer(void *HstPtr,
 
   // Now insert the new entry into the map.
   if (auto Err = insertEntry(HstPtr, *DevAccessiblePtrOrErr, Size))
-    return Err;
+    return std::move(Err);
 
   // Return the device accessible pointer.
   return *DevAccessiblePtrOrErr;
@@ -885,7 +885,7 @@ Expected<void *> GenericDeviceTy::dataAlloc(int64_t Size, void *HostPtr,
   // Register allocated buffer as pinned memory if the type is host memory.
   if (Kind == TARGET_ALLOC_HOST)
     if (auto Err = PinnedAllocs.registerHostBuffer(Alloc, Alloc, Size))
-      return Err;
+      return std::move(Err);
 
   return Alloc;
 }


        


More information about the Openmp-commits mailing list