summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Linker
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-08-24 19:31:04 +0000
committerDan Gohman <gohman@apple.com>2010-08-24 19:31:04 +0000
commit35351901167eae21e19e2d10a720b02eaf90cd31 (patch)
tree78d9b302b98aa2970d79dd560871e9d7c11fe665 /llvm/lib/Linker
parent09392785b4470dd2beef675a93ddc3066ac8f959 (diff)
downloadbcm5719-llvm-35351901167eae21e19e2d10a720b02eaf90cd31.tar.gz
bcm5719-llvm-35351901167eae21e19e2d10a720b02eaf90cd31.zip
When linking NamedMDNodes, remap their operands.
llvm-svn: 111948
Diffstat (limited to 'llvm/lib/Linker')
-rw-r--r--llvm/lib/Linker/LinkModules.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp
index fd9692de240..016c82cc992 100644
--- a/llvm/lib/Linker/LinkModules.cpp
+++ b/llvm/lib/Linker/LinkModules.cpp
@@ -451,14 +451,16 @@ static bool GetLinkageResult(GlobalValue *Dest, const GlobalValue *Src,
}
// 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 @@ Linker::LinkModules(Module *Dest, Module *Src, std::string *ErrorMsg) {
}
// 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).
OpenPOWER on IntegriCloud