diff options
author | Devang Patel <dpatel@apple.com> | 2009-09-29 20:42:25 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2009-09-29 20:42:25 +0000 |
commit | 74da40a96fecd07ce0bb4eee169087bfac2e5f23 (patch) | |
tree | e23d104d7b7461096f0600f642441f00848f9d1c /lib/VMCore | |
parent | 58a230a4917592f5c529cb40e75bfc3e1c681b69 (diff) | |
download | external_llvm-74da40a96fecd07ce0bb4eee169087bfac2e5f23.zip external_llvm-74da40a96fecd07ce0bb4eee169087bfac2e5f23.tar.gz external_llvm-74da40a96fecd07ce0bb4eee169087bfac2e5f23.tar.bz2 |
Add removeMD().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83107 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/Metadata.cpp | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/lib/VMCore/Metadata.cpp b/lib/VMCore/Metadata.cpp index 6e2fc3f..54e5242 100644 --- a/lib/VMCore/Metadata.cpp +++ b/lib/VMCore/Metadata.cpp @@ -327,6 +327,39 @@ void MetadataContext::addMD(unsigned MDKind, MDNode *Node, Instruction *Inst) { return; } +/// removeMD - Remove metadata of given kind attached with an instuction. +void MetadataContext::removeMD(unsigned Kind, Instruction *Inst) { + MDStoreTy::iterator I = MetadataStore.find(Inst); + if (I == MetadataStore.end()) + return; + + MDMapTy &Info = I->second; + for (MDMapTy::iterator MI = Info.begin(), ME = Info.end(); MI != ME; ++MI) { + MDPairTy &P = *MI; + if (P.first == Kind) { + Info.erase(MI); + return; + } + } + + return; +} + +/// removeMDs - Remove all metadata attached with an instruction. +void MetadataContext::removeMDs(const Instruction *Inst) { + // Find Metadata handles for this instruction. + MDStoreTy::iterator I = MetadataStore.find(Inst); + assert (I != MetadataStore.end() && "Invalid custom metadata info!"); + MDMapTy &Info = I->second; + + // FIXME : Give all metadata handlers a chance to adjust. + + // Remove the entries for this instruction. + Info.clear(); + MetadataStore.erase(I); +} + + /// getMD - Get the metadata of given kind attached with an Instruction. /// If the metadata is not found then return 0. MDNode *MetadataContext::getMD(unsigned MDKind, const Instruction *Inst) { @@ -356,21 +389,6 @@ const StringMap<unsigned> *MetadataContext::getHandlerNames() { return &MDHandlerNames; } -/// ValueIsDeleted - This handler is used to update metadata store -/// when a value is deleted. -void MetadataContext::ValueIsDeleted(const Instruction *Inst) { - // Find Metadata handles for this instruction. - MDStoreTy::iterator I = MetadataStore.find(Inst); - assert (I != MetadataStore.end() && "Invalid custom metadata info!"); - MDMapTy &Info = I->second; - - // FIXME : Give all metadata handlers a chance to adjust. - - // Remove the entries for this instruction. - Info.clear(); - MetadataStore.erase(I); -} - /// ValueIsCloned - This handler is used to update metadata store /// when In1 is cloned to create In2. void MetadataContext::ValueIsCloned(const Instruction *In1, Instruction *In2) { |