Skip to content

Commit 4359e55

Browse files
authored
[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`.
1 parent b0ef912 commit 4359e55

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

offload/liboffload/API/Common.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def ErrorCode : Enum {
104104
Etor<"UNIMPLEMENTED", "generic error code for features currently unimplemented by the device/backend">,
105105
Etor<"UNSUPPORTED", "generic error code for features unsupported by the device/backend">,
106106
Etor<"ASSEMBLE_FAILURE", "assembler failure while processing binary image">,
107+
Etor<"COMPILE_FAILURE", "jit compile failure while processing binary image">,
107108
Etor<"LINK_FAILURE", "linker failure while processing binary image">,
108109
Etor<"BACKEND_FAILURE", "the plugin backend is in an invalid or unsupported state">,
109110
Etor<"UNINITIALIZED", "not initialized">,

offload/liboffload/src/OffloadImpl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,7 @@ Error olCreateProgram_impl(ol_device_handle_t Device, const void *ProgData,
471471
delete Prog;
472472
return Res.takeError();
473473
}
474+
assert(*Res != nullptr && "loadBinary returned nullptr");
474475

475476
Prog->Image = *Res;
476477
*Program = Prog;

offload/plugins-nextgen/common/src/PluginInterface.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -909,8 +909,9 @@ GenericDeviceTy::loadBinary(GenericPluginTy &Plugin,
909909
if (!PostJITImageOrErr) {
910910
auto Err = PostJITImageOrErr.takeError();
911911
REPORT("Failure to jit IR image %p on device %d: %s\n", InputTgtImage,
912-
DeviceId, toString(std::move(Err)).data());
913-
return nullptr;
912+
DeviceId, toStringWithoutConsuming(Err).data());
913+
return Plugin::error(ErrorCode::COMPILE_FAILURE, std::move(Err),
914+
"failure to jit IR image");
914915
}
915916

916917
// Load the binary and allocate the image object. Use the next available id

0 commit comments

Comments
 (0)