[llvm] r316920 - Move isDSOLocal check and add a comment.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 30 09:32:31 PDT 2017


Author: rafael
Date: Mon Oct 30 09:32:31 2017
New Revision: 316920

URL: http://llvm.org/viewvc/llvm-project?rev=316920&view=rev
Log:
Move isDSOLocal check and add a comment.

Modified:
    llvm/trunk/lib/Target/TargetMachine.cpp

Modified: llvm/trunk/lib/Target/TargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetMachine.cpp?rev=316920&r1=316919&r2=316920&view=diff
==============================================================================
--- llvm/trunk/lib/Target/TargetMachine.cpp (original)
+++ llvm/trunk/lib/Target/TargetMachine.cpp Mon Oct 30 09:32:31 2017
@@ -114,6 +114,17 @@ static TLSModel::Model getSelectedTLSMod
 
 bool TargetMachine::shouldAssumeDSOLocal(const Module &M,
                                          const GlobalValue *GV) const {
+  // If the IR producer requested that this GV be treated as dso local, obey.
+  if (GV && GV->isDSOLocal())
+    return true;
+
+  // According to the llvm language reference, we should be able to just return
+  // false in here if we have a GV, as we know it is dso_preemptable.
+  // At this point in time, the various IR producers have not been transitioned
+  // to always produce a dso_local when it is possible to do so. As a result we
+  // still have some pre-dso_local logic in here to improve the quality of the
+  // generated code:
+
   Reloc::Model RM = getRelocationModel();
   const Triple &TT = getTargetTriple();
 
@@ -137,8 +148,7 @@ bool TargetMachine::shouldAssumeDSOLocal
       GV->hasExternalWeakLinkage())
     return false;
 
-  if (GV && (GV->hasLocalLinkage() || !GV->hasDefaultVisibility() ||
-              GV->isDSOLocal()))
+  if (GV && (GV->hasLocalLinkage() || !GV->hasDefaultVisibility()))
     return true;
 
   if (TT.isOSBinFormatMachO()) {




More information about the llvm-commits mailing list