diff options
author | Devang Patel <dpatel@apple.com> | 2009-10-14 17:02:49 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2009-10-14 17:02:49 +0000 |
commit | ad89036441492939570bf8972f93b00b6a358264 (patch) | |
tree | 567530d66ea45d142d4cb0591b7a58d2bcae0da9 /lib/VMCore | |
parent | 10c6f85c9ba78275c9f6de2ac9ea136200a09d10 (diff) | |
download | external_llvm-ad89036441492939570bf8972f93b00b6a358264.zip external_llvm-ad89036441492939570bf8972f93b00b6a358264.tar.gz external_llvm-ad89036441492939570bf8972f93b00b6a358264.tar.bz2 |
Add copyMD to copy metadata from one instruction to another instruction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84113 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/Metadata.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/VMCore/Metadata.cpp b/lib/VMCore/Metadata.cpp index f3601cb..110c5e3 100644 --- a/lib/VMCore/Metadata.cpp +++ b/lib/VMCore/Metadata.cpp @@ -359,6 +359,20 @@ void MetadataContext::removeMDs(const Instruction *Inst) { MetadataStore.erase(I); } +/// copyMD - If metadata is attached with Instruction In1 then attach +/// the same metadata to In2. +void MetadataContext::copyMD(Instruction *In1, Instruction *In2) { + assert (In1 && In2 && "Invalid instruction!"); + MDStoreTy::iterator I = MetadataStore.find(In1); + if (I == MetadataStore.end()) + return; + + MDMapTy &In1Info = I->second; + MDMapTy In2Info; + for (MDMapTy::iterator I = In1Info.begin(), E = In1Info.end(); I != E; ++I) + if (MDNode *MD = dyn_cast_or_null<MDNode>(I->second)) + addMD(I->first, MD, In2); +} /// getMD - Get the metadata of given kind attached with an Instruction. /// If the metadata is not found then return 0. @@ -416,3 +430,4 @@ void MetadataContext::ValueIsRAUWd(Value *V1, Value *V2) { // FIXME : Give custom handlers a chance to override this. ValueIsCloned(I1, I2); } + |