[WebAssembly] Update WebAssemblyLowerEmscriptenEHSjLj to handle separate compilation
authorSam Clegg <sbc@chromium.org>
Tue, 17 Jul 2018 16:40:03 +0000 (16:40 +0000)
committerSam Clegg <sbc@chromium.org>
Tue, 17 Jul 2018 16:40:03 +0000 (16:40 +0000)
commit28b3e994828c9210b76b774a068a05440008be6e
tree0254672f54464c2d262b06fe5df1aea57f839905
parentc4c3633a3854ac3564f42211d9fa49bfe570f772
[WebAssembly] Update WebAssemblyLowerEmscriptenEHSjLj to handle separate compilation

Previously we were assuming whole program compilation. Now that
separate compilation is a thing we need to update this pass.
Firstly, it can no longer assert on the existence of malloc and free.
This functions might not be in the current translation unit.  If we
need them then we will generate not imports for them.

Secondly the global helper function we create should be marked as
weak since we will be generating a separate copy in each translation
unit.

Finally the names of the symbols used must be unique and fixed since
they need to agree across translation units.

Differential Revision: https://reviews.llvm.org/D49263

llvm-svn: 337301
llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
llvm/test/CodeGen/WebAssembly/lower-em-exceptions.ll
llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll