[llvm-commits] [llvm] r106508 - /llvm/trunk/lib/Transforms/Utils/CloneModule.cpp
Bob Wilson
bob.wilson at apple.com
Mon Jun 21 17:11:03 PDT 2010
Author: bwilson
Date: Mon Jun 21 19:11:03 2010
New Revision: 106508
URL: http://llvm.org/viewvc/llvm-project?rev=106508&view=rev
Log:
Include named metadata when cloning a module.
Modified:
llvm/trunk/lib/Transforms/Utils/CloneModule.cpp
Modified: llvm/trunk/lib/Transforms/Utils/CloneModule.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CloneModule.cpp?rev=106508&r1=106507&r2=106508&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/CloneModule.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/CloneModule.cpp Mon Jun 21 19:11:03 2010
@@ -122,6 +122,17 @@
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;
}
More information about the llvm-commits
mailing list