[Offload] Properly report errors when jit compiling (#145498)

Previously, if a binary failed to load due to failures when jit
compiling, the function would return success with nullptr. Now it
returns a new plugin error, `COMPILE_FAILURE`.
This commit is contained in:
Ross Brunton
2025-06-24 16:27:12 +01:00
committed by GitHub
parent b0ef912534
commit 4359e55838
3 changed files with 5 additions and 2 deletions

View File

@@ -104,6 +104,7 @@ def ErrorCode : Enum {
Etor<"UNIMPLEMENTED", "generic error code for features currently unimplemented by the device/backend">,
Etor<"UNSUPPORTED", "generic error code for features unsupported by the device/backend">,
Etor<"ASSEMBLE_FAILURE", "assembler failure while processing binary image">,
Etor<"COMPILE_FAILURE", "jit compile failure while processing binary image">,
Etor<"LINK_FAILURE", "linker failure while processing binary image">,
Etor<"BACKEND_FAILURE", "the plugin backend is in an invalid or unsupported state">,
Etor<"UNINITIALIZED", "not initialized">,

View File

@@ -471,6 +471,7 @@ Error olCreateProgram_impl(ol_device_handle_t Device, const void *ProgData,
delete Prog;
return Res.takeError();
}
assert(*Res != nullptr && "loadBinary returned nullptr");
Prog->Image = *Res;
*Program = Prog;

View File

@@ -909,8 +909,9 @@ GenericDeviceTy::loadBinary(GenericPluginTy &Plugin,
if (!PostJITImageOrErr) {
auto Err = PostJITImageOrErr.takeError();
REPORT("Failure to jit IR image %p on device %d: %s\n", InputTgtImage,
DeviceId, toString(std::move(Err)).data());
return nullptr;
DeviceId, toStringWithoutConsuming(Err).data());
return Plugin::error(ErrorCode::COMPILE_FAILURE, std::move(Err),
"failure to jit IR image");
}
// Load the binary and allocate the image object. Use the next available id