[llvm-branch-commits] [llvm] WebAssembly: Use reportFatalUsageError for eh option errors (PR #233031)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Oct 16 23:43:21 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-webassembly

Author: Matt Arsenault (arsenm)

<details>
<summary>Changes</summary>

Avoid using the deprecated report_fatal_error, and add missing
error test coverage.

Co-authored-by: Claude Opus 5.5 <noreply@<!-- -->anthropic.com>

---
Full diff: https://github.com/llvm/llvm-project/pull/233031.diff


3 Files Affected:

- (modified) llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp (+2-2) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp (+1-1) 
- (modified) llvm/test/CodeGen/WebAssembly/eh-option-errors.ll (+21-4) 


``````````diff
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
index e8ac89570741f1..7ad8d2ba7800f3 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
@@ -920,13 +920,13 @@ bool WebAssemblyLowerEmscriptenEHSjLjImpl::runOnModule(Module &M) {
   ExceptionHandling EH = M.getExceptionModel();
   if (EH != ExceptionHandling::None && EH != ExceptionHandling::Wasm &&
       EH != ExceptionHandling::Emscripten)
-    report_fatal_error(
+    reportFatalUsageError(
         "-exception-model should be either 'none', 'wasm', or 'emscripten'");
 
   EnableEmEH = EH == ExceptionHandling::Emscripten;
   // You can't mix Emscripten EH with Wasm SjLj.
   if (EnableEmEH && EnableWasmSjLj)
-    report_fatal_error(
+    reportFatalUsageError(
         "-exception-model=emscripten not allowed with -wasm-enable-sjlj");
 
   bool Changed = false;
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
index 742c2541a2d58e..39e683c3c6d0fb 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
@@ -131,7 +131,7 @@ using WebAssembly::WasmEnableSjLj;
 static void basicCheckForEHAndSjLj() {
   // You can't enable two modes of SjLj at the same time
   if (WasmEnableEmSjLj && WasmEnableSjLj)
-    report_fatal_error(
+    reportFatalUsageError(
         "-enable-emscripten-sjlj not allowed with -wasm-enable-sjlj");
 }
 
diff --git a/llvm/test/CodeGen/WebAssembly/eh-option-errors.ll b/llvm/test/CodeGen/WebAssembly/eh-option-errors.ll
index b78b2d32918f75..12ed2897cc53b4 100644
--- a/llvm/test/CodeGen/WebAssembly/eh-option-errors.ll
+++ b/llvm/test/CodeGen/WebAssembly/eh-option-errors.ll
@@ -1,10 +1,27 @@
-target triple = "wasm32-unknown-unknown"
+; RUN: split-file %s %t
 
-; RUN: not --crash llc < %s -enable-emscripten-sjlj -wasm-enable-sjlj 2>&1 | FileCheck %s --check-prefix=EM_SJLJ_W_WASM_SJLJ
+; RUN: not llc < %t/noflag.ll -enable-emscripten-sjlj -wasm-enable-sjlj 2>&1 | FileCheck %s --check-prefix=EM_SJLJ_W_WASM_SJLJ
 ; EM_SJLJ_W_WASM_SJLJ: LLVM ERROR: -enable-emscripten-sjlj not allowed with -wasm-enable-sjlj
 
-; RUN: not --crash llc < %s -exception-model=emscripten -wasm-enable-sjlj 2>&1 | FileCheck %s --check-prefix=EM_EH_W_WASM_SJLJ
+; RUN: not llc < %t/noflag.ll -exception-model=emscripten -wasm-enable-sjlj 2>&1 | FileCheck %s --check-prefix=EM_EH_W_WASM_SJLJ
+; RUN: not opt -passes=wasm-lower-em-ehsjlj -wasm-enable-sjlj -disable-output %t/emscripten.ll 2>&1 | FileCheck %s --check-prefix=EM_EH_W_WASM_SJLJ
 ; EM_EH_W_WASM_SJLJ: LLVM ERROR: -exception-model=emscripten not allowed with -wasm-enable-sjlj
 
-; RUN: not --crash llc < %s -exception-model=dwarf 2>&1 | FileCheck %s --check-prefix=EH_MODEL_DWARF
+; RUN: not llc < %t/noflag.ll -exception-model=dwarf 2>&1 | FileCheck %s --check-prefix=EH_MODEL_DWARF
+; RUN: not opt -passes=wasm-lower-em-ehsjlj -disable-output %t/dwarf.ll 2>&1 | FileCheck %s --check-prefix=EH_MODEL_DWARF
 ; EH_MODEL_DWARF: LLVM ERROR: -exception-model should be either 'none', 'wasm', or 'emscripten'
+
+;--- noflag.ll
+target triple = "wasm32-unknown-unknown"
+
+;--- emscripten.ll
+target triple = "wasm32-unknown-emscripten"
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"exception-model", !"emscripten"}
+
+;--- dwarf.ll
+target triple = "wasm32-unknown-unknown"
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"exception-model", !"dwarf"}

``````````

</details>


https://github.com/llvm/llvm-project/pull/233031


More information about the llvm-branch-commits mailing list