[llvm] b4a5dd4 - [WebAssembly] Error when wasm EH is used with Emscripten EH/SjLj
Heejin Ahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 27 16:08:02 PDT 2021
Author: Heejin Ahn
Date: 2021-04-27T16:07:53-07:00
New Revision: b4a5dd4da99a301608830769e9a0dbd76c075180
URL: https://github.com/llvm/llvm-project/commit/b4a5dd4da99a301608830769e9a0dbd76c075180
DIFF: https://github.com/llvm/llvm-project/commit/b4a5dd4da99a301608830769e9a0dbd76c075180.diff
LOG: [WebAssembly] Error when wasm EH is used with Emscripten EH/SjLj
- Error out when both Emscripten EH and wasm EH are used together, i.e.,
both `-enable-emscripten-cxx-exceptions` and `-exception-model=wasm`
are given together. This will not happen if you use Emscripten, but
this can happen when you call `llc` manually with wrong set of
arguments.
- Currently we don't yet support using wasm EH with Emscripten SjLj.
Unlike `-enable-emscripten-cxx-exceptions` which is turned on only
when you use `emcc -s DISABLE_EXCEPTION_CATCHING=0`,
`-enable-emscripten-sjlj` is turned on by Emscripten by default. So we
error out only when it is turned on and `setjmp` or `longjmp` is
actually used.
Reviewed By: tlively
Differential Revision: https://reviews.llvm.org/D101403
Added:
Modified:
llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
llvm/test/CodeGen/WebAssembly/lower-em-ehsjlj-options.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
index d3bbadf27478..2429f654ea0e 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
@@ -681,14 +681,19 @@ bool WebAssemblyLowerEmscriptenEHSjLj::runOnModule(Module &M) {
bool LongjmpUsed = LongjmpF && !LongjmpF->use_empty();
bool DoSjLj = EnableSjLj && (SetjmpUsed || LongjmpUsed);
- if ((EnableEH || DoSjLj) &&
- Triple(M.getTargetTriple()).getArch() == Triple::wasm64)
- report_fatal_error("Emscripten EH/SjLj is not supported with wasm64 yet");
-
auto *TPC = getAnalysisIfAvailable<TargetPassConfig>();
assert(TPC && "Expected a TargetPassConfig");
auto &TM = TPC->getTM<WebAssemblyTargetMachine>();
+ if ((EnableEH || DoSjLj) &&
+ Triple(M.getTargetTriple()).getArch() == Triple::wasm64)
+ report_fatal_error("Emscripten EH/SjLj is not supported with wasm64 yet");
+ if (EnableEH && TM.Options.ExceptionModel == ExceptionHandling::Wasm)
+ report_fatal_error("-exception-model=wasm not allowed with "
+ "-enable-emscripten-cxx-exceptions");
+ if (DoSjLj && TM.Options.ExceptionModel == ExceptionHandling::Wasm)
+ report_fatal_error("Emscripten SjLj is not supported with Wasm EH yet");
+
// Declare (or get) global variables __THREW__, __threwValue, and
// getTempRet0/setTempRet0 function which are used in common for both
// exception handling and setjmp/longjmp handling
diff --git a/llvm/test/CodeGen/WebAssembly/lower-em-ehsjlj-options.ll b/llvm/test/CodeGen/WebAssembly/lower-em-ehsjlj-options.ll
index 3428d5c08af3..fa30cd7d4a56 100644
--- a/llvm/test/CodeGen/WebAssembly/lower-em-ehsjlj-options.ll
+++ b/llvm/test/CodeGen/WebAssembly/lower-em-ehsjlj-options.ll
@@ -3,6 +3,8 @@
; RUN: llc < %s | FileCheck %s --check-prefix=NONE
; RUN: not --crash llc < %s -enable-emscripten-cxx-exceptions -mtriple=wasm64-unknown-unknown 2>&1 | FileCheck %s --check-prefix=WASM64-EH
; RUN: not --crash llc < %s -enable-emscripten-sjlj -mtriple=wasm64-unknown-unknown 2>&1 | FileCheck %s --check-prefix=WASM64-SJLJ
+; RUN: not --crash llc < %s -enable-emscripten-cxx-exceptions -exception-model=wasm 2>&1 | FileCheck %s --check-prefix=WASM-EH-EM-EH
+; RUN: not --crash llc < %s -enable-emscripten-sjlj -exception-model=wasm 2>&1 | FileCheck %s --check-prefix=WASM-EH-EM-SJLJ
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
target triple = "wasm32-unknown-unknown"
@@ -104,3 +106,5 @@ attributes #2 = { nounwind }
; WASM64-EH: LLVM ERROR: Emscripten EH/SjLj is not supported with wasm64 yet
; WASM64-SJLJ: LLVM ERROR: Emscripten EH/SjLj is not supported with wasm64 yet
+; WASM-EH-EM-EH: LLVM ERROR: -exception-model=wasm not allowed with -enable-emscripten-cxx-exceptions
+; WASM-EH-EM-SJLJ: LLVM ERROR: Emscripten SjLj is not supported with Wasm EH yet
More information about the llvm-commits
mailing list