[llvm-commits] [llvm] r147971 - in /llvm/trunk: include/llvm/GlobalValue.h lib/Transforms/IPO/ConstantMerge.cpp

Eli Friedman eli.friedman at gmail.com
Wed Jan 11 14:06:46 PST 2012


Author: efriedma
Date: Wed Jan 11 16:06:46 2012
New Revision: 147971

URL: http://llvm.org/viewvc/llvm-project?rev=147971&view=rev
Log:
Re-fix the issue Bill fixed in r147899 in a slightly different way, which doesn't abuse the semantics of linker_private.  We don't really want to merge any string constant with a weak_odr global.


Modified:
    llvm/trunk/include/llvm/GlobalValue.h
    llvm/trunk/lib/Transforms/IPO/ConstantMerge.cpp

Modified: llvm/trunk/include/llvm/GlobalValue.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/GlobalValue.h?rev=147971&r1=147970&r2=147971&view=diff
==============================================================================
--- llvm/trunk/include/llvm/GlobalValue.h (original)
+++ llvm/trunk/include/llvm/GlobalValue.h Wed Jan 11 16:06:46 2012
@@ -192,14 +192,6 @@
            Linkage == LinkerPrivateWeakDefAutoLinkage;
   }
 
-  /// mayBeRemovedByLinker - Whether the definition of this global may be
-  /// removed at link time.
-  static bool mayBeRemovedByLinker(LinkageTypes Linkage) {
-    return isLinkerPrivateLinkage(Linkage) ||
-      isLinkerPrivateWeakLinkage(Linkage) ||
-      isLinkerPrivateWeakDefAutoLinkage(Linkage);
-  }
-
   bool hasExternalLinkage() const { return isExternalLinkage(Linkage); }
   bool hasAvailableExternallyLinkage() const {
     return isAvailableExternallyLinkage(Linkage);
@@ -233,8 +225,6 @@
 
   bool isWeakForLinker() const { return isWeakForLinker(Linkage); }
 
-  bool mayBeRemovedByLinker() const { return mayBeRemovedByLinker(Linkage); }
-
   /// copyAttributesFrom - copy all additional attributes (those not needed to
   /// create a GlobalValue) from the GlobalValue Src to this one.
   virtual void copyAttributesFrom(const GlobalValue *Src);

Modified: llvm/trunk/lib/Transforms/IPO/ConstantMerge.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ConstantMerge.cpp?rev=147971&r1=147970&r2=147971&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/ConstantMerge.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/ConstantMerge.cpp Wed Jan 11 16:06:46 2012
@@ -140,8 +140,11 @@
           UsedGlobals.count(GV))
         continue;
 
-      // Ignore any constants which may be removed by the linker.
-      if (GV->mayBeRemovedByLinker())
+      // This transformation is legal for weak ODR globals in the sense it
+      // doesn't change semantics, but we really don't want to perform it
+      // anyway; it's likely to pessimize code generation, and some tools
+      // (like the Darwin linker in cases involving CFString) don't expect it.
+      if (GV->isWeakForLinker())
         continue;
 
       Constant *Init = GV->getInitializer();
@@ -172,9 +175,8 @@
           UsedGlobals.count(GV))
         continue;
 
-      // We can only replace constants with local linkage and which aren't
-      // removed by the linker.
-      if (!GV->hasLocalLinkage() || GV->mayBeRemovedByLinker())
+      // We can only replace constant with local linkage.
+      if (!GV->hasLocalLinkage())
         continue;
 
       Constant *Init = GV->getInitializer();





More information about the llvm-commits mailing list