summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorBob Wilson <bob.wilson@apple.com>2010-06-22 00:11:03 +0000
committerBob Wilson <bob.wilson@apple.com>2010-06-22 00:11:03 +0000
commit5f9575c1cd791486e87a6c6cd62b1f9afe1c0e7f (patch)
tree2940902116cea22c1c8f1f8adbc751a2050a5241 /llvm/lib/Transforms
parent3c77a355e0850ba09c868850870663d6e1a3bc3c (diff)
downloadbcm5719-llvm-5f9575c1cd791486e87a6c6cd62b1f9afe1c0e7f.tar.gz
bcm5719-llvm-5f9575c1cd791486e87a6c6cd62b1f9afe1c0e7f.zip
Include named metadata when cloning a module.
llvm-svn: 106508
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Utils/CloneModule.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/CloneModule.cpp b/llvm/lib/Transforms/Utils/CloneModule.cpp
index b87c082793e..1809bbb3201 100644
--- a/llvm/lib/Transforms/Utils/CloneModule.cpp
+++ b/llvm/lib/Transforms/Utils/CloneModule.cpp
@@ -122,6 +122,17 @@ Module *llvm::CloneModule(const Module *M,
if (const Constant* C = I->getAliasee())
GA->setAliasee(cast<Constant>(MapValue(C, ValueMap)));
}
+
+ // And named metadata....
+ for (Module::const_named_metadata_iterator I = M->named_metadata_begin(),
+ E = M->named_metadata_end(); I != E; ++I) {
+ const NamedMDNode &NMD = *I;
+ SmallVector<MDNode*, 4> MDs;
+ for (unsigned i = 0, e = NMD.getNumOperands(); i != e; ++i)
+ MDs.push_back(cast<MDNode>(MapValue(NMD.getOperand(i), ValueMap)));
+ NamedMDNode::Create(New->getContext(), NMD.getName(),
+ MDs.data(), MDs.size(), New);
+ }
return New;
}
OpenPOWER on IntegriCloud