-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[WebAssembly] Add tests for EH/SjLj option errors #93583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This adds tests for EH/SjLj option errors and swaps the error checking order for unimportant cosmetic reasons (I think checking EH/SjLj conflicts is more important than the model checking)
@llvm/pr-subscribers-backend-webassembly Author: Heejin Ahn (aheejin) ChangesThis adds tests for EH/SjLj option errors and swaps the error checking order for unimportant cosmetic reasons (I think checking EH/SjLj conflicts is more important than the model checking) Full diff: https://github.com/llvm/llvm-project/pull/93583.diff 3 Files Affected:
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
index de342e8965736..68126992ddcd7 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
@@ -388,15 +388,29 @@ using WebAssembly::WasmEnableEmSjLj;
using WebAssembly::WasmEnableSjLj;
static void basicCheckForEHAndSjLj(TargetMachine *TM) {
- // Before checking, we make sure TargetOptions.ExceptionModel is the same as
+
+ // You can't enable two modes of EH at the same time
+ if (WasmEnableEmEH && WasmEnableEH)
+ report_fatal_error(
+ "-enable-emscripten-cxx-exceptions not allowed with -wasm-enable-eh");
+ // You can't enable two modes of SjLj at the same time
+ if (WasmEnableEmSjLj && WasmEnableSjLj)
+ report_fatal_error(
+ "-enable-emscripten-sjlj not allowed with -wasm-enable-sjlj");
+ // You can't mix Emscripten EH with Wasm SjLj.
+ if (WasmEnableEmEH && WasmEnableSjLj)
+ report_fatal_error(
+ "-enable-emscripten-cxx-exceptions not allowed with -wasm-enable-sjlj");
+
+ // Here we make sure TargetOptions.ExceptionModel is the same as
// MCAsmInfo.ExceptionsType. Normally these have to be the same, because clang
// stores the exception model info in LangOptions, which is later transferred
// to TargetOptions and MCAsmInfo. But when clang compiles bitcode directly,
// clang's LangOptions is not used and thus the exception model info is not
// correctly transferred to TargetOptions and MCAsmInfo, so we make sure we
- // have the correct exception model in WebAssemblyMCAsmInfo constructor.
- // But in this case TargetOptions is still not updated, so we make sure they
- // are the same.
+ // have the correct exception model in WebAssemblyMCAsmInfo constructor. But
+ // in this case TargetOptions is still not updated, so we make sure they are
+ // the same.
TM->Options.ExceptionModel = TM->getMCAsmInfo()->getExceptionHandlingType();
// Basic Correctness checking related to -exception-model
@@ -418,18 +432,6 @@ static void basicCheckForEHAndSjLj(TargetMachine *TM) {
"-exception-model=wasm only allowed with at least one of "
"-wasm-enable-eh or -wasm-enable-sjlj");
- // You can't enable two modes of EH at the same time
- if (WasmEnableEmEH && WasmEnableEH)
- report_fatal_error(
- "-enable-emscripten-cxx-exceptions not allowed with -wasm-enable-eh");
- // You can't enable two modes of SjLj at the same time
- if (WasmEnableEmSjLj && WasmEnableSjLj)
- report_fatal_error(
- "-enable-emscripten-sjlj not allowed with -wasm-enable-sjlj");
- // You can't mix Emscripten EH with Wasm SjLj.
- if (WasmEnableEmEH && WasmEnableSjLj)
- report_fatal_error(
- "-enable-emscripten-cxx-exceptions not allowed with -wasm-enable-sjlj");
// Currently it is allowed to mix Wasm EH with Emscripten SjLj as an interim
// measure, but some code will error out at compile time in this combination.
// See WebAssemblyLowerEmscriptenEHSjLj pass for details.
diff --git a/llvm/test/CodeGen/WebAssembly/eh-option-errors.ll b/llvm/test/CodeGen/WebAssembly/eh-option-errors.ll
new file mode 100644
index 0000000000000..74d02ddc405d3
--- /dev/null
+++ b/llvm/test/CodeGen/WebAssembly/eh-option-errors.ll
@@ -0,0 +1,19 @@
+target triple = "wasm32-unknown-unknown"
+
+; RUN: not --crash llc < %s -enable-emscripten-cxx-exceptions -wasm-enable-eh 2>&1 | FileCheck %s --check-prefix=EM_EH_W_WASM_EH
+; EM_EH_W_WASM_EH: LLVM ERROR: -enable-emscripten-cxx-exceptions not allowed with -wasm-enable-eh
+
+; RUN: not --crash llc < %s -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 -enable-emscripten-cxx-exceptions -wasm-enable-sjlj 2>&1 | FileCheck %s --check-prefix=EM_EH_W_WASM_SJLJ
+; EM_EH_W_WASM_SJLJ: LLVM ERROR: -enable-emscripten-cxx-exceptions not allowed with -wasm-enable-sjlj
+
+; RUN: not --crash llc < %s -wasm-enable-eh -exception-model=dwarf 2>&1 | FileCheck %s --check-prefix=EH_MODEL_DWARF
+; EH_MODEL_DWARF: LLVM ERROR: -exception-model should be either 'none' or 'wasm'
+
+; RUN: not --crash llc < %s -enable-emscripten-cxx-exceptions -exception-model=wasm 2>&1 | FileCheck %s --check-prefix=EM_EH_W_MODEL_WASM
+; EM_EH_W_MODEL_WASM: LLVM ERROR: -exception-model=wasm not allowed with -enable-emscripten-cxx-exceptions
+
+; RUN: not --crash llc < %s -exception-model=wasm 2>&1 | FileCheck %s --check-prefix=MODEL_WASM_WO_WASM_EH_SJLJ
+; MODEL_WASM_WO_WASM_EH_SJLJ: LLVM ERROR: -exception-model=wasm only allowed with at least one of -wasm-enable-eh or -wasm-enable-sjlj
diff --git a/llvm/test/CodeGen/WebAssembly/lower-em-ehsjlj-options.ll b/llvm/test/CodeGen/WebAssembly/lower-em-ehsjlj-options.ll
index 4a63c812d6ae9..66872a5422986 100644
--- a/llvm/test/CodeGen/WebAssembly/lower-em-ehsjlj-options.ll
+++ b/llvm/test/CodeGen/WebAssembly/lower-em-ehsjlj-options.ll
@@ -1,7 +1,6 @@
; RUN: llc < %s -enable-emscripten-cxx-exceptions | FileCheck %s --check-prefix=EH
; RUN: llc < %s -enable-emscripten-sjlj | FileCheck %s --check-prefix=SJLJ
; RUN: llc < %s | FileCheck %s --check-prefix=NONE
-; RUN: not --crash llc < %s -enable-emscripten-cxx-exceptions -exception-model=wasm 2>&1 | FileCheck %s --check-prefix=WASM-EH-EM-EH
target triple = "wasm32-unknown-unknown"
@@ -97,5 +96,3 @@ declare void @free(ptr)
attributes #0 = { returns_twice }
attributes #1 = { noreturn }
attributes #2 = { nounwind }
-
-; WASM-EH-EM-EH: LLVM ERROR: -exception-model=wasm not allowed with -enable-emscripten-cxx-exceptions
|
// You can't enable two modes of EH at the same time | ||
if (WasmEnableEmEH && WasmEnableEH) | ||
report_fatal_error( | ||
"-enable-emscripten-cxx-exceptions not allowed with -wasm-enable-eh"); | ||
// You can't enable two modes of SjLj at the same time | ||
if (WasmEnableEmSjLj && WasmEnableSjLj) | ||
report_fatal_error( | ||
"-enable-emscripten-sjlj not allowed with -wasm-enable-sjlj"); | ||
// You can't mix Emscripten EH with Wasm SjLj. | ||
if (WasmEnableEmEH && WasmEnableSjLj) | ||
report_fatal_error( | ||
"-enable-emscripten-cxx-exceptions not allowed with -wasm-enable-sjlj"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was just moved from below
@@ -1,7 +1,6 @@ | |||
; RUN: llc < %s -enable-emscripten-cxx-exceptions | FileCheck %s --check-prefix=EH | |||
; RUN: llc < %s -enable-emscripten-sjlj | FileCheck %s --check-prefix=SJLJ | |||
; RUN: llc < %s | FileCheck %s --check-prefix=NONE | |||
; RUN: not --crash llc < %s -enable-emscripten-cxx-exceptions -exception-model=wasm 2>&1 | FileCheck %s --check-prefix=WASM-EH-EM-EH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test was moved to eh-option-errors.ll
The CI failure doesn't seem to be related. Merging. |
This adds tests for EH/SjLj option errors and swaps the error checking order for unimportant cosmetic reasons (I think checking EH/SjLj conflicts is more important than the model checking)
This adds tests for EH/SjLj option errors and swaps the error checking order for unimportant cosmetic reasons (I think checking EH/SjLj conflicts is more important than the model checking)