diff options
| author | Reid Kleckner <reid@kleckner.net> | 2014-05-23 21:13:45 +0000 |
|---|---|---|
| committer | Reid Kleckner <reid@kleckner.net> | 2014-05-23 21:13:45 +0000 |
| commit | 8756959802c659b53f431bcd75b5234f0c9589ab (patch) | |
| tree | cdf906607f80c0c6ca999264c6c709fe6c4bcb0e /lib/CodeGen/CodeGenModule.h | |
| parent | 3ccca48c69e96f10485bc7eda0a1531dee22b775 (diff) | |
| download | clang-8756959802c659b53f431bcd75b5234f0c9589ab.tar.gz clang-8756959802c659b53f431bcd75b5234f0c9589ab.tar.bz2 clang-8756959802c659b53f431bcd75b5234f0c9589ab.tar.xz | |
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
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209555 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenModule.h')
| -rw-r--r-- | lib/CodeGen/CodeGenModule.h | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/CodeGen/CodeGenModule.h b/lib/CodeGen/CodeGenModule.h index eff51cea8b..9e5835132a 100644 --- a/lib/CodeGen/CodeGenModule.h +++ b/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 |
