[llvm] [Offload] Fix Error checking (PR #141939)
via llvm-commits
llvm-commits at lists.llvm.org
Thu May 29 06:05:26 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-offload
Author: Ross Brunton (RossBrunton)
<details>
<summary>Changes</summary>
All errors must be checked - this includes the local variable we were
using to increase the lifetime of `Res`. As we were not explicitly
checking it, it resulted in an `abort` in debug builds.
---
Full diff: https://github.com/llvm/llvm-project/pull/141939.diff
1 Files Affected:
- (modified) offload/liboffload/src/OffloadImpl.cpp (+9-7)
``````````diff
diff --git a/offload/liboffload/src/OffloadImpl.cpp b/offload/liboffload/src/OffloadImpl.cpp
index a5935a7e5b318..7b67cbba43e68 100644
--- a/offload/liboffload/src/OffloadImpl.cpp
+++ b/offload/liboffload/src/OffloadImpl.cpp
@@ -416,18 +416,20 @@ Error olMemcpy_impl(ol_queue_handle_t Queue, void *DstPtr,
// If no queue is given the memcpy will be synchronous
auto QueueImpl = Queue ? Queue->AsyncInfo : nullptr;
- Error Res = Error::success();
if (DstDevice == HostDevice()) {
- Res = SrcDevice->Device->dataRetrieve(DstPtr, SrcPtr, Size, QueueImpl);
+ if (auto Res =
+ SrcDevice->Device->dataRetrieve(DstPtr, SrcPtr, Size, QueueImpl))
+ return Res;
} else if (SrcDevice == HostDevice()) {
- Res = DstDevice->Device->dataSubmit(DstPtr, SrcPtr, Size, QueueImpl);
+ if (auto Res =
+ DstDevice->Device->dataSubmit(DstPtr, SrcPtr, Size, QueueImpl))
+ return Res;
} else {
- Res = SrcDevice->Device->dataExchange(SrcPtr, *DstDevice->Device, DstPtr,
- Size, QueueImpl);
+ if (auto Res = SrcDevice->Device->dataExchange(SrcPtr, *DstDevice->Device,
+ DstPtr, Size, QueueImpl))
+ return Res;
}
- if (Res)
- return Res;
if (EventOut)
*EventOut = makeEvent(Queue);
``````````
</details>
https://github.com/llvm/llvm-project/pull/141939
More information about the llvm-commits
mailing list