[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.
This commit is contained in:
Joseph Huber 2023-03-20 11:49:10 -05:00
parent 67089a39a2
commit edc0355006
2 changed files with 4 additions and 4 deletions

View File

@ -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;
}

View File

@ -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;
}