[llvm-branch-commits] [llvm] WebAssembly: Use reportFatalUsageError for eh option errors (PR #233031)
Matt Arsenault via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Oct 16 23:42:49 PDT 2026
https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/233031
Avoid using the deprecated report_fatal_error, and add missing
error test coverage.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
>From 003a95e2facd660ed696524db4acfd0c10dd67b5 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Thu, 15 Oct 2026 09:45:12 +0200
Subject: [PATCH] WebAssembly: Use reportFatalUsageError for eh option errors
Avoid using the deprecated report_fatal_error, and add missing
error test coverage.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
---
.../WebAssemblyLowerEmscriptenEHSjLj.cpp | 4 +--
.../WebAssembly/WebAssemblyTargetMachine.cpp | 2 +-
.../CodeGen/WebAssembly/eh-option-errors.ll | 25 ++++++++++++++++---
3 files changed, 24 insertions(+), 7 deletions(-)
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"}
More information about the llvm-branch-commits
mailing list