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

Dan Gohman gohman at apple.com
Tue Aug 24 12:31:04 PDT 2010


Author: djg
Date: Tue Aug 24 14:31:04 2010
New Revision: 111948

URL: http://llvm.org/viewvc/llvm-project?rev=111948&view=rev
Log:
When linking NamedMDNodes, remap their operands.

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=111948&r1=111947&r2=111948&view=diff
==============================================================================
--- llvm/trunk/lib/Linker/LinkModules.cpp (original)
+++ llvm/trunk/lib/Linker/LinkModules.cpp Tue Aug 24 14:31:04 2010
@@ -451,14 +451,16 @@
 }
 
 // Insert all of the named mdnoes in Src into the Dest module.
-static void LinkNamedMDNodes(Module *Dest, Module *Src) {
+static void LinkNamedMDNodes(Module *Dest, Module *Src,
+                             ValueToValueMapTy &ValueMap) {
   for (Module::const_named_metadata_iterator I = Src->named_metadata_begin(),
          E = Src->named_metadata_end(); I != E; ++I) {
     const NamedMDNode *SrcNMD = I;
     NamedMDNode *DestNMD = Dest->getOrInsertNamedMetadata(SrcNMD->getName());
     // Add Src elements into Dest node.
     for (unsigned i = 0, e = SrcNMD->getNumOperands(); i != e; ++i) 
-      DestNMD->addOperand(SrcNMD->getOperand(i));
+      DestNMD->addOperand(cast<MDNode>(MapValue(SrcNMD->getOperand(i),
+                                                ValueMap)));
   }
 }
 
@@ -1243,7 +1245,7 @@
   }
 
   // Insert all of the named mdnoes in Src into the Dest module.
-  LinkNamedMDNodes(Dest, Src);
+  LinkNamedMDNodes(Dest, Src, ValueMap);
 
   // Insert all of the globals in src into the Dest module... without linking
   // initializers (which could refer to functions not yet mapped over).





More information about the llvm-commits mailing list