The `llvm.tls_init_funcs' (created by the front-end) holds pointers to the TLS
initialization functions. These need to be placed into the correct section so
that they are run before `main()'.
<rdar://problem/
13733006>
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180737
91177308-0d34-0410-b5e6-
96231b3b80d8
unsigned uid) const;
void EmitLLVMUsedList(const ConstantArray *InitList);
void EmitXXStructorList(const Constant *List, bool isCtor);
unsigned uid) const;
void EmitLLVMUsedList(const ConstantArray *InitList);
void EmitXXStructorList(const Constant *List, bool isCtor);
+ void EmitTLSInitFuncs(const ConstantArray *InitList);
GCMetadataPrinter *GetOrCreateGCPrinter(GCStrategy *C);
};
}
GCMetadataPrinter *GetOrCreateGCPrinter(GCStrategy *C);
};
}
+ if (GV->getName() == "llvm.tls_init_funcs") {
+ EmitTLSInitFuncs(cast<ConstantArray>(GV->getInitializer()));
+ return true;
+ }
+
+/// EmitTLSInitFuncs - Emit the TLS initialization functions.
+void AsmPrinter::EmitTLSInitFuncs(const ConstantArray *InitList) {
+ const DataLayout *TD = TM.getDataLayout();
+ OutStreamer.SwitchSection(getObjFileLowering().getTLSThreadInitSection());
+ EmitAlignment(Log2_32(TD->getPointerPrefAlignment()));
+ for (unsigned I = 0, E = InitList->getNumOperands(); I != E; ++I)
+ EmitGlobalConstant(
+ dyn_cast<Constant>(InitList->getOperand(I)->stripPointerCasts()));
+}
+
//===--------------------------------------------------------------------===//
// Emission and print routines
//
//===--------------------------------------------------------------------===//
// Emission and print routines
//