aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2017-12-15 00:17:10 +0000
committerSam Clegg <sbc@chromium.org>2017-12-15 00:17:10 +0000
commitbafe69026d7e78696173bf09e4959996ec750167 (patch)
tree5c2396c15d59e9707eb901c1889ea666f7d7faa4 /llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
parent476a73924e7a789c5a0844280ba0a9deac155d7b (diff)
downloadllvm-bafe69026d7e78696173bf09e4959996ec750167.zip
llvm-bafe69026d7e78696173bf09e4959996ec750167.tar.gz
llvm-bafe69026d7e78696173bf09e4959996ec750167.tar.bz2
[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 llvm-svn: 320774
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp')
-rw-r--r--llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 925e67b..24d4baa 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -1359,6 +1359,18 @@ const MCExpr *TargetLoweringObjectFileWasm::lowerRelativeReference(
void TargetLoweringObjectFileWasm::InitializeWasm() {
StaticCtorSection =
getContext().getWasmSection(".init_array", SectionKind::getData());
- StaticDtorSection =
- getContext().getWasmSection(".fini_array", SectionKind::getData());
+}
+
+MCSection *TargetLoweringObjectFileWasm::getStaticCtorSection(
+ unsigned Priority, const MCSymbol *KeySym) const {
+ return Priority == UINT16_MAX ?
+ StaticCtorSection :
+ getContext().getWasmSection(".init_array." + utostr(Priority),
+ SectionKind::getData());
+}
+
+MCSection *TargetLoweringObjectFileWasm::getStaticDtorSection(
+ unsigned Priority, const MCSymbol *KeySym) const {
+ llvm_unreachable("@llvm.global_dtors should have been lowered already");
+ return nullptr;
}