[WebAssembly] Don't inline -emscripten-cxx-exceptions-allowed functions
authorHeejin Ahn <aheejin@gmail.com>
Wed, 24 Mar 2021 13:06:58 +0000 (06:06 -0700)
committerHeejin Ahn <aheejin@gmail.com>
Wed, 24 Mar 2021 19:27:49 +0000 (12:27 -0700)
commita6aae5f7fcd1111db87bfe77072912484213f872
tree4b1f47098b00e29b5e26f83ab2f210ab034f589a
parent9d4557927999601f77e9fa9d0906cd5362d5f4ee
[WebAssembly] Don't inline -emscripten-cxx-exceptions-allowed functions

Functions specified in `-emscripten-cxx-exceptions-allowed`, which is
set by Emscripten's `EXCEPTION_CATCHING_ALLOWED` setting, can be inlined
in LLVM middle ends before we reach WebAssemblyLowerEmscriptenEHSjLj
pass in the wasm backend and thus don't get transformed for exception
catching.

This fixes the issue by adding `--force-attribute=FUNC_NAME:noinline`
for each function name in `-emscripten-cxx-exceptions-allowed`, which
adds `noinline` attribute to the specified function and thus excludes
the function from inlining candidates in optimization passes.

Fixes the remaining half of
https://github.com/emscripten-core/emscripten/issues/10721.

Reviewed By: sbc100

Differential Revision: https://reviews.llvm.org/D99259
clang/lib/Driver/ToolChains/WebAssembly.cpp
clang/test/Driver/wasm-toolchain.c