[PATCH] D117943: [WebAssembly] Treat __cxa_end_catch not longjmpable in Emscripten SjLj
Heejin Ahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 27 21:04:20 PST 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd9517efbb3dc: [WebAssembly] Treat __cxa_end_catch not longjmpable in Emscripten SjLj (authored by aheejin).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D117943/new/
https://reviews.llvm.org/D117943
Files:
llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
llvm/test/CodeGen/WebAssembly/lower-em-ehsjlj.ll
Index: llvm/test/CodeGen/WebAssembly/lower-em-ehsjlj.ll
===================================================================
--- llvm/test/CodeGen/WebAssembly/lower-em-ehsjlj.ll
+++ llvm/test/CodeGen/WebAssembly/lower-em-ehsjlj.ll
@@ -33,21 +33,23 @@
; CHECK-NEXT: %[[CMP:.*]] = icmp eq i32 %__THREW__.val, 1
; CHECK-NEXT: br i1 %[[CMP]], label %lpad, label %try.cont
-; longjmp checking part
-; CHECK: if.then1:
-; CHECK: call i32 @testSetjmp
-
+; CHECK: lpad:
lpad: ; preds = %entry
%0 = landingpad { i8*, i32 }
catch i8* null
%1 = extractvalue { i8*, i32 } %0, 0
%2 = extractvalue { i8*, i32 } %0, 1
+; CHECK-NOT: call {{.*}} void @__invoke_void(void ()* @__cxa_end_catch)
%3 = call i8* @__cxa_begin_catch(i8* %1) #2
call void @__cxa_end_catch()
br label %try.cont
try.cont: ; preds = %lpad, %entry
ret void
+
+; longjmp checking part
+; CHECK: if.then1:
+; CHECK: call i32 @testSetjmp
}
; @foo can either throw an exception or longjmp. Because this function doesn't
Index: llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
===================================================================
--- llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
@@ -630,9 +630,9 @@
// Exception-catching related functions
//
- // We intentionally excluded __cxa_end_catch here even though it surely cannot
- // longjmp, in order to maintain the unwind relationship from all existing
- // catchpads (and calls within them) to catch.dispatch.longjmp.
+ // We intentionally treat __cxa_end_catch longjmpable in Wasm SjLj even though
+ // it surely cannot longjmp, in order to maintain the unwind relationship from
+ // all existing catchpads (and calls within them) to catch.dispatch.longjmp.
//
// In Wasm EH + Wasm SjLj, we
// 1. Make all catchswitch and cleanuppad that unwind to caller unwind to
@@ -663,6 +663,8 @@
//
// The comment block in findWasmUnwindDestinations() in
// SelectionDAGBuilder.cpp is addressing a similar problem.
+ if (CalleeName == "__cxa_end_catch")
+ return WebAssembly::WasmEnableSjLj;
if (CalleeName == "__cxa_begin_catch" ||
CalleeName == "__cxa_allocate_exception" || CalleeName == "__cxa_throw" ||
CalleeName == "__clang_call_terminate")
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117943.403874.patch
Type: text/x-patch
Size: 2455 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220128/1bacf3fd/attachment-0001.bin>
More information about the llvm-commits
mailing list