[WebAssembly] Handle EH terminate pads for cleanup
authorHeejin Ahn <aheejin@gmail.com>
Fri, 1 Jan 2021 09:02:52 +0000 (01:02 -0800)
committerHeejin Ahn <aheejin@gmail.com>
Sat, 6 Feb 2021 16:40:30 +0000 (08:40 -0800)
commitbe0efa1f2368c007b9ecb533db42102166ce9a17
tree786af52728281ae55bf7c2a1ccd1a0bf2d592da5
parente1172959226689a7d1b3ba8c04883969161333af
[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
llvm/lib/Target/WebAssembly/CMakeLists.txt
llvm/lib/Target/WebAssembly/WebAssembly.h
llvm/lib/Target/WebAssembly/WebAssemblyHandleEHTerminatePads.cpp [new file with mode: 0644]
llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
llvm/test/CodeGen/WebAssembly/exception.ll