]> granicus.if.org Git - clang/commitdiff
Always set dso_local in CodeGenModule::setDSOLocal.
authorRafael Espindola <rafael.espindola@gmail.com>
Fri, 2 Mar 2018 01:29:51 +0000 (01:29 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Fri, 2 Mar 2018 01:29:51 +0000 (01:29 +0000)
This shouldn't change any results for now, but is more consistent with
how we set dllimport/dllexport and will make future changes easier.

Since clang produces IR as it parses, it can find out mid file that
something is dllimport. When that happens we have to drop
dso_local. This is not a problem right now because
CodeGenModule::setDSOLocal is called from relatively few places at
the moment.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326527 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CodeGenModule.cpp

index 389f586443c8cf1b981dc61c68b0082b1ee5df31..de3810554f9e5b7f94eaf282925d397b26cc6c3f 100644 (file)
@@ -716,6 +716,12 @@ void CodeGenModule::setGlobalVisibility(llvm::GlobalValue *GV,
 
 static bool shouldAssumeDSOLocal(const CodeGenModule &CGM,
                                  llvm::GlobalValue *GV) {
+  if (GV->hasLocalLinkage())
+    return true;
+
+  if (!GV->hasDefaultVisibility() && !GV->hasExternalWeakLinkage())
+    return true;
+
   // DLLImport explicitly marks the GV as external.
   if (GV->hasDLLImportStorageClass())
     return false;
@@ -773,8 +779,7 @@ static bool shouldAssumeDSOLocal(const CodeGenModule &CGM,
 }
 
 void CodeGenModule::setDSOLocal(llvm::GlobalValue *GV) const {
-  if (shouldAssumeDSOLocal(*this, GV))
-    GV->setDSOLocal(true);
+  GV->setDSOLocal(shouldAssumeDSOLocal(*this, GV));
 }
 
 void CodeGenModule::setDLLImportDLLExport(llvm::GlobalValue *GV,