Skip to content

Commit edc0355

Browse files
committed
[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.
1 parent 67089a3 commit edc0355

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1863,7 +1863,7 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
18631863
hsa_status_t Status =
18641864
hsa_amd_memory_lock(HstPtr, Size, nullptr, 0, &PinnedPtr);
18651865
if (auto Err = Plugin::check(Status, "Error in hsa_amd_memory_lock: %s\n"))
1866-
return Err;
1866+
return std::move(Err);
18671867

18681868
return PinnedPtr;
18691869
}

openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ Expected<void *> PinnedAllocationMapTy::lockHostBuffer(void *HstPtr,
703703
if (Entry) {
704704
// An already registered intersecting buffer was found. Register a new use.
705705
if (auto Err = registerEntryUse(*Entry, HstPtr, Size))
706-
return Err;
706+
return std::move(Err);
707707

708708
// Return the device accessible pointer with the correct offset.
709709
return advanceVoidPtr(Entry->DevAccessiblePtr,
@@ -718,7 +718,7 @@ Expected<void *> PinnedAllocationMapTy::lockHostBuffer(void *HstPtr,
718718

719719
// Now insert the new entry into the map.
720720
if (auto Err = insertEntry(HstPtr, *DevAccessiblePtrOrErr, Size))
721-
return Err;
721+
return std::move(Err);
722722

723723
// Return the device accessible pointer.
724724
return *DevAccessiblePtrOrErr;
@@ -885,7 +885,7 @@ Expected<void *> GenericDeviceTy::dataAlloc(int64_t Size, void *HostPtr,
885885
// Register allocated buffer as pinned memory if the type is host memory.
886886
if (Kind == TARGET_ALLOC_HOST)
887887
if (auto Err = PinnedAllocs.registerHostBuffer(Alloc, Alloc, Size))
888-
return Err;
888+
return std::move(Err);
889889

890890
return Alloc;
891891
}

0 commit comments

Comments
 (0)