[llvm-commits] [llvm] r115759 - /llvm/trunk/lib/Linker/LinkModules.cpp

Bill Wendling isanbard at gmail.com
Wed Oct 6 00:03:52 PDT 2010


Author: void
Date: Wed Oct  6 02:03:52 2010
New Revision: 115759

URL: http://llvm.org/viewvc/llvm-project?rev=115759&view=rev
Log:
Change RequiresMerge to RequiresUnique. It's a better description of what this
fix is trying to accomplish.

This code could still use some polishing.

Modified:
    llvm/trunk/lib/Linker/LinkModules.cpp

Modified: llvm/trunk/lib/Linker/LinkModules.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=115759&r1=115758&r2=115759&view=diff
==============================================================================
--- llvm/trunk/lib/Linker/LinkModules.cpp (original)
+++ llvm/trunk/lib/Linker/LinkModules.cpp Wed Oct  6 02:03:52 2010
@@ -454,11 +454,12 @@
   }
 }
 
-// RequiresMerge - Return true if the source global variable needs to be merged
-// with the destination global variable. I.e., there shouldn't be a new global
-// variable created in the destination Module, rather the initializers should be
-// merged in an intelligent fashion.
-static bool RequiresMerge(const GlobalVariable *SGV, const GlobalVariable *DGV){
+// RequiresUnique - Returns true if the global variable needs to be
+// unique. I.e., there shouldn't be a new global variable created in the
+// destination Module, rather the source variable's initializer needs to be
+// identical to the destination variable's initializer.
+static bool RequiresUnique(const GlobalVariable *SGV,
+                           const GlobalVariable *DGV) {
   const StringRef SrcSec(SGV->getSection());
   const StringRef DstSec(DGV->getSection());
 
@@ -492,7 +493,7 @@
     // be merged instead of replaced.
     if (SymTabGV) {
       const GlobalVariable *GV = dyn_cast<GlobalVariable>(SymTabGV);
-      if (GV && RequiresMerge(SGV, GV)) {
+      if (GV && RequiresUnique(SGV, GV)) {
         // Make sure to remember this mapping.
         ValueMap[SGV] = SymTabGV;
         continue;
@@ -851,7 +852,7 @@
       // If dest is a global variable, check that initializers match.
       if (GlobalVariable *DGVar = dyn_cast<GlobalVariable>(DGV)) {
         if (DGVar->hasInitializer()) {
-          if (SGV->hasExternalLinkage() || RequiresMerge(SGV, DGVar)) {
+          if (SGV->hasExternalLinkage() || RequiresUnique(SGV, DGVar)) {
             if (DGVar->getInitializer() != SInit)
               return Error(Err, "Global Variable Collision on '" +
                            SGV->getName() +





More information about the llvm-commits mailing list