[llvm] [Offload] Ensure all `llvm::Error`s are handled (PR #137339)
Callum Fare via llvm-commits
llvm-commits at lists.llvm.org
Thu May 1 08:02:18 PDT 2025
================
@@ -308,9 +308,11 @@ ol_impl_result_t olMemAlloc_impl(ol_device_handle_t Device,
void **AllocationOut) {
auto Alloc =
Device->Device->dataAlloc(Size, nullptr, convertOlToPluginAllocTy(Type));
- if (!Alloc)
+ if (!Alloc) {
+ llvm::consumeError(Alloc.takeError());
return {OL_ERRC_OUT_OF_RESOURCES,
formatv("Could not create allocation on device {0}", Device).str()};
+ }
----------------
callumfare wrote:
I added that type so that we could simply return `OL_ERRC_FOO` or `{OL_ERRC_FOO, "Detail string"}` from the implementation functions without having to explicit type out the error conversion each time. It hides the details of how that works from people implementing new entry points. You can see from the definition of `ol_impl_result_t` that handling the lifetime of the strings and error pointers is a bit ugly. But yeah I wouldn't object to having the impl functions return the `llvm::Error` and have the handling happen in the wrapper/entry point functions.
https://github.com/llvm/llvm-project/pull/137339
More information about the llvm-commits
mailing list