summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGDecl.cpp7
-rw-r--r--clang/lib/CodeGen/MicrosoftCXXABI.cpp5
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");
OpenPOWER on IntegriCloud