[llvm] Use reportFatalUsageError in llvm-omp-kernel-replay (PR #178371)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 27 23:04:39 PST 2026


https://github.com/sladyn98 created https://github.com/llvm/llvm-project/pull/178371

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.

>From 18929213410a9930ec8e85278a53fa36135d24a8 Mon Sep 17 00:00:00 2001
From: sladynnunes <snunes at usc.edu>
Date: Tue, 27 Jan 2026 00:46:29 -0800
Subject: [PATCH] offload: use reportFatalUsageError in llvm-omp-kernel-replay

---
 .../kernelreplay/llvm-omp-kernel-replay.cpp      | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

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();



More information about the llvm-commits mailing list