summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.h
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2014-05-23 21:13:45 +0000
committerReid Kleckner <reid@kleckner.net>2014-05-23 21:13:45 +0000
commit563f0e852c5002ff177aa73802b543d5e3781388 (patch)
tree0c4b207fb3ca3b86cf291fc5f4c88f08d5c15cdd /clang/lib/CodeGen/CodeGenModule.h
parent2f75351c02a32592f5c0f2af3a2ab10cf12cdb07 (diff)
downloadbcm5719-llvm-563f0e852c5002ff177aa73802b543d5e3781388.tar.gz
bcm5719-llvm-563f0e852c5002ff177aa73802b543d5e3781388.zip
Use comdats to avoid double initialization of weak data
Initializers of global data that can appear multiple TUs (static data members of class templates or __declspec(selectany) data) are now in a comdat group keyed on the global variable being initialized. On non-Windows platforms, this is a code size and startup time optimization. On Windows, this is necessary for ABI compatibility with MSVC. Fixes PR16959. Reviewers: rsmith Differential Revision: http://reviews.llvm.org/D3811 llvm-svn: 209555
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.h')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.h18
1 files changed, 15 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h
index eff51cea8bd..9e5835132ae 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -233,7 +233,18 @@ class CodeGenModule : public CodeGenTypeCache {
CodeGenModule(const CodeGenModule &) LLVM_DELETED_FUNCTION;
void operator=(const CodeGenModule &) LLVM_DELETED_FUNCTION;
- typedef std::vector<std::pair<llvm::Constant*, int> > CtorList;
+ struct Structor {
+ Structor() : Priority(0), Initializer(nullptr), AssociatedData(nullptr) {}
+ Structor(int Priority, llvm::Constant *Initializer,
+ llvm::Constant *AssociatedData)
+ : Priority(Priority), Initializer(Initializer),
+ AssociatedData(AssociatedData) {}
+ int Priority;
+ llvm::Constant *Initializer;
+ llvm::Constant *AssociatedData;
+ };
+
+ typedef std::vector<Structor> CtorList;
ASTContext &Context;
const LangOptions &LangOpts;
@@ -1081,8 +1092,9 @@ private:
bool PerformInit);
// FIXME: Hardcoding priority here is gross.
- void AddGlobalCtor(llvm::Function *Ctor, int Priority=65535);
- void AddGlobalDtor(llvm::Function *Dtor, int Priority=65535);
+ void AddGlobalCtor(llvm::Function *Ctor, int Priority = 65535,
+ llvm::Constant *AssociatedData = 0);
+ void AddGlobalDtor(llvm::Function *Dtor, int Priority = 65535);
/// Generates a global array of functions and priorities using the given list
/// and name. This array will have appending linkage and is suitable for use
OpenPOWER on IntegriCloud