[llvm-branch-commits] [llvm-branch] r134506 - /llvm/branches/type-system-rewrite/lib/Linker/LinkModules.cpp

Chris Lattner sabre at nondot.org
Wed Jul 6 10:44:57 PDT 2011


Author: lattner
Date: Wed Jul  6 12:44:57 2011
New Revision: 134506

URL: http://llvm.org/viewvc/llvm-project?rev=134506&view=rev
Log:
fix test/Linker/AppendingLinkage.ll

Modified:
    llvm/branches/type-system-rewrite/lib/Linker/LinkModules.cpp

Modified: llvm/branches/type-system-rewrite/lib/Linker/LinkModules.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/type-system-rewrite/lib/Linker/LinkModules.cpp?rev=134506&r1=134505&r2=134506&view=diff
==============================================================================
--- llvm/branches/type-system-rewrite/lib/Linker/LinkModules.cpp (original)
+++ llvm/branches/type-system-rewrite/lib/Linker/LinkModules.cpp Wed Jul  6 12:44:57 2011
@@ -360,7 +360,7 @@
     
     void computeTypeMapping();
     
-    bool linkAppendingVars(GlobalVariable *DstGV, const GlobalVariable *SrcGV);
+    bool linkAppendingVars(GlobalVariable *DstGV, GlobalVariable *SrcGV);
     bool linkGlobalProto(GlobalVariable *SrcGV);
     bool linkFunctionProto(Function *SrcF);
     bool linkAliasProto(GlobalAlias *SrcA);
@@ -491,7 +491,7 @@
 /// linkAppendingVars - If there were any appending global variables, link them
 /// together now.  Return true on error.
 bool ModuleLinker::linkAppendingVars(GlobalVariable *DstGV,
-                                     const GlobalVariable *SrcGV) {
+                                     GlobalVariable *SrcGV) {
  
   if (!SrcGV->hasAppendingLinkage() || !DstGV->hasAppendingLinkage())
     return emitError("Linking globals named '" + SrcGV->getName() +
@@ -561,6 +561,10 @@
 
   DstGV->replaceAllUsesWith(ConstantExpr::getBitCast(NG, DstGV->getType()));
   DstGV->eraseFromParent();
+  
+  // Zap the initializer in the source variable so we don't try to link it.
+  SrcGV->setInitializer(0);
+  SrcGV->setLinkage(GlobalValue::ExternalLinkage);
   return false;
 }
 





More information about the llvm-branch-commits mailing list