summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2018-08-29 17:26:58 +0000
committerMartin Storsjo <martin@martin.st>2018-08-29 17:26:58 +0000
commit5ff7a8e67b1c0123fea25d67d1017b898e28504e (patch)
treeaed2436cf1d3bafa8f665cb069771742477b6b0c /clang/lib/CodeGen/CodeGenModule.cpp
parentcfbbb707f539feed15bc35ecd44a095688d5b27a (diff)
downloadbcm5719-llvm-5ff7a8e67b1c0123fea25d67d1017b898e28504e.tar.gz
bcm5719-llvm-5ff7a8e67b1c0123fea25d67d1017b898e28504e.zip
[MinGW] Don't mark external variables as DSO local
Since MinGW supports automatically importing external variables from DLLs even without the DLLImport attribute, we shouldn't mark them as DSO local unless we actually know them to be local for sure. Keep marking thread local variables as DSO local. Differential Revision: https://reviews.llvm.org/D51382 llvm-svn: 340941
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 29692eedb53..c5cac6a3982 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -730,6 +730,14 @@ static bool shouldAssumeDSOLocal(const CodeGenModule &CGM,
return false;
const llvm::Triple &TT = CGM.getTriple();
+ if (TT.isWindowsGNUEnvironment()) {
+ // In MinGW, variables without DLLImport can still be automatically
+ // imported from a DLL by the linker; don't mark variables that
+ // potentially could come from another DLL as DSO local.
+ if (GV->isDeclarationForLinker() && isa<llvm::GlobalVariable>(GV) &&
+ !GV->isThreadLocal())
+ return false;
+ }
// Every other GV is local on COFF.
// Make an exception for windows OS in the triple: Some firmware builds use
// *-win32-macho triples. This (accidentally?) produced windows relocations
OpenPOWER on IntegriCloud