aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2021-01-01 01:02:52 -0800
committerHeejin Ahn <aheejin@gmail.com>2021-02-06 08:40:30 -0800
commitbe0efa1f2368c007b9ecb533db42102166ce9a17 (patch)
tree786af52728281ae55bf7c2a1ccd1a0bf2d592da5 /llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
parente1172959226689a7d1b3ba8c04883969161333af (diff)
downloadllvm-be0efa1f2368c007b9ecb533db42102166ce9a17.zip
llvm-be0efa1f2368c007b9ecb533db42102166ce9a17.tar.gz
llvm-be0efa1f2368c007b9ecb533db42102166ce9a17.tar.bz2
[WebAssembly] Handle EH terminate pads for cleanup
Terminate pads, cleanup pads with `__clang_call_terminate` call, have `catch` instruction in them because `__clang_call_terminate` takes an exception pointer. But these terminate pads should be reached also in case of foreign exception. So this pass attaches an additional `catch_all` BB after every terminate pad BB, with a call to `std::terminate`. Reviewed By: tlively Differential Revision: https://reviews.llvm.org/D94050
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp')
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
index 135055a..0b07850 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
@@ -82,6 +82,7 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeWebAssemblyTarget() {
initializeWebAssemblyExceptionInfoPass(PR);
initializeWebAssemblyCFGSortPass(PR);
initializeWebAssemblyCFGStackifyPass(PR);
+ initializeWebAssemblyHandleEHTerminatePadsPass(PR);
initializeWebAssemblyExplicitLocalsPass(PR);
initializeWebAssemblyLowerBrUnlessPass(PR);
initializeWebAssemblyRegNumberingPass(PR);
@@ -485,6 +486,10 @@ void WebAssemblyPassConfig::addPreEmitPass() {
// Insert BLOCK and LOOP markers.
addPass(createWebAssemblyCFGStackify());
+ // Handle terminate pads for cleanups
+ if (TM->Options.ExceptionModel == ExceptionHandling::Wasm)
+ addPass(createWebAssemblyHandleEHTerminatePads());
+
// Insert explicit local.get and local.set operators.
if (!WasmDisableExplicitLocals)
addPass(createWebAssemblyExplicitLocals());