[llvm-commits] CVS: llvm/lib/Linker/LinkModules.cpp

Reid Spencer reid at x10sys.com
Sat Feb 3 20:30:49 PST 2007



Changes in directory llvm/lib/Linker:

LinkModules.cpp updated: 1.133 -> 1.134
---
Log message:

Ensure that visibility and section are properly propagated.


---
Diffs of the changes:  (+8 -9)

 LinkModules.cpp |   17 ++++++++---------
 1 files changed, 8 insertions(+), 9 deletions(-)


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.133 llvm/lib/Linker/LinkModules.cpp:1.134
--- llvm/lib/Linker/LinkModules.cpp:1.133	Sat Feb  3 22:29:21 2007
+++ llvm/lib/Linker/LinkModules.cpp	Sat Feb  3 22:30:33 2007
@@ -476,11 +476,10 @@
         new GlobalVariable(SGV->getType()->getElementType(),
                            SGV->isConstant(), SGV->getLinkage(), /*init*/0,
                            SGV->getName(), Dest);
-      // Propagate alignment info.
+      // Propagate alignment, visibility and section info.
       NewDGV->setAlignment(SGV->getAlignment());
-
-      // Propagate section info.
       NewDGV->setSection(SGV->getSection());
+      NewDGV->setVisibility(SGV->getVisibility());
 
       // If the LLVM runtime renamed the global, but it is an externally visible
       // symbol, DGV must be an existing global with internal linkage.  Rename
@@ -503,11 +502,10 @@
                            SGV->isConstant(), SGV->getLinkage(), /*init*/0,
                            "", Dest);
 
-      // Propagate alignment info.
+      // Propagate alignment, section and visibility  info.
       NewDGV->setAlignment(std::max(DGV->getAlignment(), SGV->getAlignment()));
-
-      // Propagate section info.
       NewDGV->setSection(SGV->getSection());
+      NewDGV->setVisibility(SGV->getVisibility());
 
       // Make sure to remember this mapping...
       ValueMap.insert(std::make_pair(SGV, NewDGV));
@@ -515,11 +513,10 @@
       // Keep track that this is an appending variable...
       AppendingVars.insert(std::make_pair(SGV->getName(), NewDGV));
     } else {
-      // Propagate alignment info.
+      // Propagate alignment, section, and visibility info.
       DGV->setAlignment(std::max(DGV->getAlignment(), SGV->getAlignment()));
-
-      // Propagate section info.
       DGV->setSection(SGV->getSection());
+      DGV->setVisibility(SGV->getVisibility());
 
       // Otherwise, perform the mapping as instructed by GetLinkageResult.  If
       // the types don't match, and if we are to link from the source, nuke DGV
@@ -529,6 +526,8 @@
           new GlobalVariable(SGV->getType()->getElementType(),
                              DGV->isConstant(), DGV->getLinkage());
         NewDGV->setAlignment(DGV->getAlignment());
+        NewDGV->setSection(DGV->getSection());
+        NewDGV->setVisibility(DGV->getVisibility());
         Dest->getGlobalList().insert(DGV, NewDGV);
         DGV->replaceAllUsesWith(
             ConstantExpr::getBitCast(NewDGV, DGV->getType()));






More information about the llvm-commits mailing list