[WebAssembly] Rename Emscripten EH functions
authorHeejin Ahn <aheejin@gmail.com>
Mon, 28 Sep 2020 10:57:37 +0000 (03:57 -0700)
committerHeejin Ahn <aheejin@gmail.com>
Wed, 7 Oct 2020 16:42:49 +0000 (09:42 -0700)
commit3bba91f64eef15956f589fa446c265a714cc7893
tree2e6d8fa3d9d8138c47d2ff6ec9a8fd21223fbd68
parent91a98ec11e2e001d01c47286bc1721046beeae62
[WebAssembly] Rename Emscripten EH functions

Renaming for some Emscripten EH functions has so far been done in
wasm-emscripten-finalize tool in Binaryen. But recently we decided to
make a compilation/linking path that does not rely on
wasm-emscripten-finalize for modifications, so here we move that
functionality to LLVM.

Invoke wrappers are generated in LowerEmscriptenEHSjLj pass, but final
wasm types are not available in the IR pass, we need to rename them at
the end of the pipeline.

This patch also removes uses of `emscripten_longjmp_jmpbuf` in
LowerEmscriptenEHSjLj pass, replacing that with `emscripten_longjmp`.
`emscripten_longjmp_jmpbuf` is lowered to `emscripten_longjmp`, but
previously we generated calls to `emscripten_longjmp_jmpbuf` in
LowerEmscriptenEHSjLj pass because it takes `jmp_buf*` instead of `i32`.
But we were able use `ptrtoint` to make it use `emscripten_longjmp`
directly here.

Addresses:
https://github.com/WebAssembly/binaryen/issues/3043
https://github.com/WebAssembly/binaryen/issues/3081

Companions:
https://github.com/WebAssembly/binaryen/pull/3191
https://github.com/emscripten-core/emscripten/pull/12399

Reviewed By: dschuff, tlively, sbc100

Differential Revision: https://reviews.llvm.org/D88697
llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.h
llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
llvm/test/CodeGen/WebAssembly/function-bitcasts.ll
llvm/test/CodeGen/WebAssembly/lower-em-ehsjlj-multi-return.ll [new file with mode: 0644]
llvm/test/CodeGen/WebAssembly/lower-em-ehsjlj-options.ll
llvm/test/CodeGen/WebAssembly/lower-em-sjlj-sret.ll
llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll