diff options
author | Jennifer Yu <jennifer.yu@intel.com> | 2019-04-03 17:21:40 +0000 |
---|---|---|
committer | Jennifer Yu <jennifer.yu@intel.com> | 2019-04-03 17:21:40 +0000 |
commit | 0b28b8b09be710320a07012de90a3083d2c39905 (patch) | |
tree | 7e621d43221f043a73d868bed11ab5166bbe8d95 /clang/lib/CodeGen/CGDeclCXX.cpp | |
parent | 540e18ded758f4f659d7af1b61d4c5f75111bf8e (diff) | |
download | bcm5719-llvm-0b28b8b09be710320a07012de90a3083d2c39905.tar.gz bcm5719-llvm-0b28b8b09be710320a07012de90a3083d2c39905.zip |
Bug-40323: MS ABI adding template static member in the linker directive section to make sure init function can be called before main.
llvm-svn: 357610
Diffstat (limited to 'clang/lib/CodeGen/CGDeclCXX.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGDeclCXX.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index cd3301bd6ca..d6fd7f26285 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -481,6 +481,12 @@ CodeGenModule::EmitCXXGlobalVarDeclInitFunc(const VarDecl *D, // minor startup time optimization. In the MS C++ ABI, there are no guard // variables, so this COMDAT key is required for correctness. AddGlobalCtor(Fn, 65535, COMDATKey); + if (getTarget().getCXXABI().isMicrosoft()) { + // In The MS C++, MS add template static data member in the linker + // drective. + assert(COMDATKey); + addUsedGlobal(COMDATKey); + } } else if (D->hasAttr<SelectAnyAttr>()) { // SelectAny globals will be comdat-folded. Put the initializer into a // COMDAT group associated with the global, so the initializers get folded |