[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
Tue Oct 20 09:59:10 PDT 2026
https://github.com/arsenm updated https://github.com/llvm/llvm-project/pull/233031
>From 1bd734997055bc2673ac8b3ac108728db1c74961 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 | 6 ++--
.../WebAssembly/WebAssemblyTargetMachine.cpp | 2 +-
.../CodeGen/WebAssembly/eh-option-errors.ll | 34 ++++++++++++++++---
3 files changed, 33 insertions(+), 9 deletions(-)
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
index 4e1a66686f39b..5daa4d943a14a 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
@@ -920,17 +920,17 @@ 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");
// You can't mix Wasm EH with Emscripten SjLj.
if (EH == ExceptionHandling::Wasm && EnableEmSjLj)
- report_fatal_error(
+ reportFatalUsageError(
"-exception-model=wasm not allowed with -enable-emscripten-sjlj");
bool Changed = false;
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
index 742c2541a2d58..39e683c3c6d0f 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 baae0b79d1796..c76631e780191 100644
--- a/llvm/test/CodeGen/WebAssembly/eh-option-errors.ll
+++ b/llvm/test/CodeGen/WebAssembly/eh-option-errors.ll
@@ -1,13 +1,37 @@
-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=wasm -enable-emscripten-sjlj 2>&1 | FileCheck %s --check-prefix=WASM_EH_W_EM_SJLJ
+; RUN: not llc < %t/noflag.ll -exception-model=wasm -enable-emscripten-sjlj 2>&1 | FileCheck %s --check-prefix=WASM_EH_W_EM_SJLJ
+; RUN: not opt -passes=wasm-lower-em-ehsjlj -enable-emscripten-sjlj -disable-output %t/wasm.ll 2>&1 | FileCheck %s --check-prefix=WASM_EH_W_EM_SJLJ
; WASM_EH_W_EM_SJLJ: LLVM ERROR: -exception-model=wasm not allowed with -enable-emscripten-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"}
+
+;--- wasm.ll
+target triple = "wasm32-unknown-unknown"
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"exception-model", !"wasm"}
+
+;--- 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