[WebAssembly] Nullify unnecessary setjmp invokes
authorHeejin Ahn <aheejin@gmail.com>
Thu, 27 Jan 2022 01:25:33 +0000 (17:25 -0800)
committerHeejin Ahn <aheejin@gmail.com>
Fri, 28 Jan 2022 05:11:10 +0000 (21:11 -0800)
commit4f1244d7ccb8a9d1c932e2a7d883d0cd1da9650d
tree1bcc216dd91a5e44a84cab81d48c02c5a2c3e102
parent20c1d9ce5ece40ec779f3e5898a369fce9c7ba0b
[WebAssembly] Nullify unnecessary setjmp invokes

This is similar to D116619, but now it handles `invoke`s. The reason we
didn't handle `invoke`s back then was we didn't support Wasm EH + Wasm
SjLj together, and the only case SjLj transformation will see `invoke`s
is when we are using Wasm EH. (In Emscripten EH, they would have been
transformed to `call`s to invoke wrappers.)

But after D117610 we support Wasm EH + Wasm SjLj together and we can
nullify `invoke`s to `setjmp` when there is no other longjmpable calls
within the function. Actually this is very unlikely to happen in
practice, because we treat destructors as longjmpable and also treat
`__cxa_end_catch` as longjmpable even if it is not.

Reviewed By: dschuff

Differential Revision: https://reviews.llvm.org/D118408
llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
llvm/test/CodeGen/WebAssembly/lower-wasm-ehsjlj.ll