[llvm] Use reportFatalUsageError in llvm-omp-kernel-replay (PR #178371)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 27 23:05:27 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-offload
Author: Sladyn (sladyn98)
<details>
<summary>Changes</summary>
All error cases in this tool are usage errors (bad user input, missing files, malformed JSON) rather than internal LLVM bugs, so `reportFatalUsageError` is the appropriate replacement.
---
Full diff: https://github.com/llvm/llvm-project/pull/178371.diff
1 Files Affected:
- (modified) offload/tools/kernelreplay/llvm-omp-kernel-replay.cpp (+9-7)
``````````diff
diff --git a/offload/tools/kernelreplay/llvm-omp-kernel-replay.cpp b/offload/tools/kernelreplay/llvm-omp-kernel-replay.cpp
index 47a299f0ab557..718e9e78304e8 100644
--- a/offload/tools/kernelreplay/llvm-omp-kernel-replay.cpp
+++ b/offload/tools/kernelreplay/llvm-omp-kernel-replay.cpp
@@ -15,6 +15,7 @@
#include "llvm/Frontend/Offloading/Utility.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/JSON.h"
#include "llvm/Support/MemoryBuffer.h"
@@ -60,11 +61,11 @@ int main(int argc, char **argv) {
MemoryBuffer::getFile(InputFilename, /*isText=*/true,
/*RequiresNullTerminator=*/true);
if (!KernelInfoMB)
- report_fatal_error("Error reading the kernel info json file");
+ reportFatalUsageError("Error reading the kernel info json file");
Expected<json::Value> JsonKernelInfo =
json::parse(KernelInfoMB.get()->getBuffer());
if (auto Err = JsonKernelInfo.takeError())
- report_fatal_error("Cannot parse the kernel info json file");
+ reportFatalUsageError("Cannot parse the kernel info json file");
auto NumTeamsJson =
JsonKernelInfo->getAsObject()->getInteger("NumTeamsClause");
@@ -104,7 +105,7 @@ int main(int argc, char **argv) {
MemoryBuffer::getFile(KernelEntryName + ".image", /*isText=*/false,
/*RequiresNullTerminator=*/false);
if (!ImageMB)
- report_fatal_error("Error reading the kernel image.");
+ reportFatalUsageError("Error reading the kernel image.");
__tgt_device_image DeviceImage;
DeviceImage.ImageStart = const_cast<char *>(ImageMB.get()->getBufferStart());
@@ -145,7 +146,7 @@ int main(int argc, char **argv) {
/*RequiresNullTerminator=*/false);
if (!DeviceMemoryMB)
- report_fatal_error("Error reading the kernel input device memory.");
+ reportFatalUsageError("Error reading the kernel input device memory.");
// On AMD for currently unknown reasons we cannot copy memory mapped data to
// device. This is a work-around.
@@ -178,14 +179,15 @@ int main(int argc, char **argv) {
/*isText=*/false,
/*RequiresNullTerminator=*/false);
if (!OriginalOutputMB)
- report_fatal_error("Error reading the kernel original output file, make "
- "sure LIBOMPTARGET_SAVE_OUTPUT is set when recording");
+ reportFatalUsageError(
+ "Error reading the kernel original output file, make sure "
+ "LIBOMPTARGET_SAVE_OUTPUT is set when recording");
ErrorOr<std::unique_ptr<MemoryBuffer>> ReplayOutputMB =
MemoryBuffer::getFile(KernelEntryName + ".replay.output",
/*isText=*/false,
/*RequiresNullTerminator=*/false);
if (!ReplayOutputMB)
- report_fatal_error("Error reading the kernel replay output file");
+ reportFatalUsageError("Error reading the kernel replay output file");
StringRef OriginalOutput = OriginalOutputMB.get()->getBuffer();
StringRef ReplayOutput = ReplayOutputMB.get()->getBuffer();
``````````
</details>
https://github.com/llvm/llvm-project/pull/178371
More information about the llvm-commits
mailing list