[llvm] [SandboxIR][Region] Replace exit() with reportFatalUsageError() (PR #182134)

via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 18 12:49:59 PST 2026


https://github.com/vporpo created https://github.com/llvm/llvm-project/pull/182134

`Region::createRegionsFromMD()` parses the IR and the corresponding metadata and forms one or more Regions. If an instruction is tagged as being part of the "auxiliary" vector of the region, then a check enforces that it should also be part of a region, i.e., it should have both `!sandboxaux` and `!sandboxvec` metadata, not just `!sandboxaux`.

The check used to `exit(1)` after printing an error, but it's better to abort using LLVM's error handling functions. Since the user can write the IR by hand I think it makes sense to report this as a usage error with `reportFatalUsageError()`, and not as an internal error.

>From c882b27f8f833fc52eaae09c5ea3ed7b9127caf3 Mon Sep 17 00:00:00 2001
From: Vasileios Porpodas <vasileios.porpodas at amd.com>
Date: Wed, 18 Feb 2026 18:48:54 +0000
Subject: [PATCH] [SandboxIR][Region] Replace exit() with
 reportFatalUsageError()

Since the user can write the IR by hand I think it makes sense to report this
as a usage error and not as an internal error.
---
 llvm/lib/SandboxIR/Region.cpp           | 2 +-
 llvm/unittests/SandboxIR/RegionTest.cpp | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/SandboxIR/Region.cpp b/llvm/lib/SandboxIR/Region.cpp
index bd79a97cdd0a9..7326e57248c1b 100644
--- a/llvm/lib/SandboxIR/Region.cpp
+++ b/llvm/lib/SandboxIR/Region.cpp
@@ -174,7 +174,7 @@ Region::createRegionsFromMD(Function &F, TargetTransformInfo &TTI) {
         auto Idx = cast<llvm::ConstantInt>(IdxC)->getSExtValue();
         if (R == nullptr) {
           errs() << "No region specified for Aux: '" << *LLVMI << "'\n";
-          exit(1);
+          reportFatalUsageError("No region specified for Aux!");
         }
         R->setAux(Idx, &Inst);
       }
diff --git a/llvm/unittests/SandboxIR/RegionTest.cpp b/llvm/unittests/SandboxIR/RegionTest.cpp
index 5d7283fa1024f..1f98e1127524a 100644
--- a/llvm/unittests/SandboxIR/RegionTest.cpp
+++ b/llvm/unittests/SandboxIR/RegionTest.cpp
@@ -443,6 +443,8 @@ define void @foo(i8 %v) {
   auto *F = Ctx.createFunction(LLVMF);
   EXPECT_DEATH(sandboxir::Region::createRegionsFromMD(*F, *TTI), "No region.*");
 #endif
+  EXPECT_DEATH(sandboxir::Region::createRegionsFromMD(*F, *TTI),
+               "No region specified for Aux!");
 }
 
 TEST_F(RegionTest, AuxRoundTrip) {



More information about the llvm-commits mailing list