[WebAssembly] Implement @llvm.global_ctors and @llvm.global_dtors
commit5334180cf2fafa3564ed803026f8c2ae7f76b0ce
authorSam Clegg <sbc@chromium.org>
Fri, 15 Dec 2017 00:17:10 +0000 (15 00:17 +0000)
committerSam Clegg <sbc@chromium.org>
Fri, 15 Dec 2017 00:17:10 +0000 (15 00:17 +0000)
treeb3bda965562f5cfb5fdfb61378f3f1b8e62b4192
parentd7cf6c74e2ebd4bfa9e02f8ffebeeced38d28d12
[WebAssembly] Implement @llvm.global_ctors and @llvm.global_dtors

Summary:
- lowers @llvm.global_dtors by adding @llvm.global_ctors
  functions which register the destructors with `__cxa_atexit`.
- impements @llvm.global_ctors with wasm start functions and linker metadata

See [here](https://github.com/WebAssembly/tool-conventions/issues/25) for more background.

Subscribers: jfb, dschuff, mgorny, jgravelle-google, aheejin, sunfish

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320774 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
lib/CodeGen/TargetLoweringObjectFileImpl.cpp
lib/MC/WasmObjectWriter.cpp
lib/Target/WebAssembly/CMakeLists.txt
lib/Target/WebAssembly/WebAssembly.h
lib/Target/WebAssembly/WebAssemblyLowerGlobalDtors.cpp [new file with mode: 0644]
lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
test/CodeGen/WebAssembly/lower-global-dtors.ll [new file with mode: 0644]
test/MC/WebAssembly/init-fini-array.ll