diff options
| author | Hans Wennborg <hans@hanshq.net> | 2014-06-18 15:55:13 +0000 |
|---|---|---|
| committer | Hans Wennborg <hans@hanshq.net> | 2014-06-18 15:55:13 +0000 |
| commit | ef2272c49e1da9ef22b142ea4a8dca86a9cf80e5 (patch) | |
| tree | 0e5d398de6a617ade8213438b547087ac3e1ab5e /clang/lib/CodeGen | |
| parent | dbb3e3e64f40098a74e1d337cfbc1212959fe832 (diff) | |
| download | bcm5719-llvm-ef2272c49e1da9ef22b142ea4a8dca86a9cf80e5.tar.gz bcm5719-llvm-ef2272c49e1da9ef22b142ea4a8dca86a9cf80e5.zip | |
Inherit dll attributes to static locals
This makes us handle static locals in exported/imported functions correctly.
Differential Revision: http://reviews.llvm.org/D4136
llvm-svn: 211173
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CGDecl.cpp | 7 | ||||
| -rw-r--r-- | clang/lib/CodeGen/MicrosoftCXXABI.cpp | 5 |
2 files changed, 10 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index 12c520792fc..a28e7213771 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -201,6 +201,13 @@ CodeGenFunction::CreateStaticVarDecl(const VarDecl &D, if (D.getTLSKind()) CGM.setTLSMode(GV, D); + if (D.isExternallyVisible()) { + if (D.hasAttr<DLLImportAttr>()) + GV->setDLLStorageClass(llvm::GlobalVariable::DLLImportStorageClass); + else if (D.hasAttr<DLLExportAttr>()) + GV->setDLLStorageClass(llvm::GlobalVariable::DLLExportStorageClass); + } + // Make sure the result is of the correct type. unsigned ExpectedAddrSpace = CGM.getContext().getTargetAddressSpace(Ty); if (AddrSpace != ExpectedAddrSpace) { diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp b/clang/lib/CodeGen/MicrosoftCXXABI.cpp index ffcf76eb421..ca2aaa2edf1 100644 --- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp +++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp @@ -1425,12 +1425,13 @@ void MicrosoftCXXABI::EmitGuardedInit(CodeGenFunction &CGF, const VarDecl &D, Out.flush(); } - // Create the guard variable with a zero-initializer. Just absorb linkage - // and visibility from the guarded variable. + // Create the guard variable with a zero-initializer. Just absorb linkage, + // visibility and dll storage class from the guarded variable. GI->Guard = new llvm::GlobalVariable(CGM.getModule(), GuardTy, false, GV->getLinkage(), Zero, GuardName.str()); GI->Guard->setVisibility(GV->getVisibility()); + GI->Guard->setDLLStorageClass(GV->getDLLStorageClass()); } else { assert(GI->Guard->getLinkage() == GV->getLinkage() && "static local from the same function had different linkage"); |

