r326527 - Always set dso_local in CodeGenModule::setDSOLocal.

Rafael Espindola via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 1 17:29:51 PST 2018


Author: rafael
Date: Thu Mar  1 17:29:51 2018
New Revision: 326527

URL: http://llvm.org/viewvc/llvm-project?rev=326527&view=rev
Log:
Always set dso_local in CodeGenModule::setDSOLocal.

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.

Modified:
    cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=326527&r1=326526&r2=326527&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Mar  1 17:29:51 2018
@@ -716,6 +716,12 @@ void CodeGenModule::setGlobalVisibility(
 
 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 C
 }
 
 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,




More information about the cfe-commits mailing list