[clang] [llvm] [WebAssembly] Implement an alternative translation for -wasm-enable-sjlj (PR #84137)

Heejin Ahn via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 13 17:14:06 PDT 2024


================
@@ -198,9 +198,18 @@
 ///
 /// If there are calls to setjmp()
 ///
-/// 2) and 3): The same as 2) and 3) in Emscripten SjLj.
-/// (setjmpTable/setjmpTableSize initialization + setjmp callsite
-/// transformation)
+/// 2) In the function entry that calls setjmp, initialize
+///    functionInvocationId as follows:
+///
+///    functionInvocationId = alloca()
+///
+/// 3) Lower
+///      setjmp(env)
+///    into
+///      __wasm_setjmp(env, label, functionInvocationId)
+///
+///    A BB with setjmp is split into two after setjmp call in order to
+///    make the post-setjmp BB the possible destination of longjmp BB.
----------------
aheejin wrote:

As I said in the emscripten PR, I think we can use your libraries in both Emscripten SjLj and Wasm SjLj. The only reason we have `handleLongjmpableCallsForEmscriptenSjLj` and `handleLongjmpableCallsForEmscriptenSjLj` separately is how we transform code is different and not because the way we use `saveSetjmp` and `testSetjmp` is any different.

So we can remove all uses of the current `saveSetjmp` and `testSetjmp` in this file and fix test accordingly, and move this comment block to `Emscripten setjmp/longjmp handling` part and leave this Wasm side comment as is.

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


More information about the llvm-commits mailing list