aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2010-06-22 18:52:38 +0000
committerDevang Patel <dpatel@apple.com>2010-06-22 18:52:38 +0000
commitd8800e797261285f91c2a3382215fd740e6f875d (patch)
tree3bd67b25743ad88413c0f2048990807b365b70e8 /lib/Transforms
parentd3a067bbc204838cd492fec8f1d054fd768af4af (diff)
downloadexternal_llvm-d8800e797261285f91c2a3382215fd740e6f875d.zip
external_llvm-d8800e797261285f91c2a3382215fd740e6f875d.tar.gz
external_llvm-d8800e797261285f91c2a3382215fd740e6f875d.tar.bz2
Clone named metadata while cloning a module.
Reapply Bob's patch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106560 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Utils/CloneModule.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/Transforms/Utils/CloneModule.cpp b/lib/Transforms/Utils/CloneModule.cpp
index b87c082..1809bbb 100644
--- a/lib/Transforms/Utils/CloneModule.cpp
+++ b/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;
}