diff options
author | Chris Lattner <sabre@nondot.org> | 2009-12-29 07:44:16 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-12-29 07:44:16 +0000 |
commit | 508b19a5a41a4b82be4ae71e6ea5c691bea99b96 (patch) | |
tree | 1afdfc812176be8e7b7ab4cc913b3e2c22d1a7d6 /lib/VMCore | |
parent | 7f29dfd75c1503a863a6ffa422728e10de1c6338 (diff) | |
download | external_llvm-508b19a5a41a4b82be4ae71e6ea5c691bea99b96.zip external_llvm-508b19a5a41a4b82be4ae71e6ea5c691bea99b96.tar.gz external_llvm-508b19a5a41a4b82be4ae71e6ea5c691bea99b96.tar.bz2 |
remove some unneeded Metadata interfaces.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92252 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/Instruction.cpp | 17 | ||||
-rw-r--r-- | lib/VMCore/Metadata.cpp | 48 |
2 files changed, 18 insertions, 47 deletions
diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp index 85fd0e8..a5500e6 100644 --- a/lib/VMCore/Instruction.cpp +++ b/lib/VMCore/Instruction.cpp @@ -11,12 +11,10 @@ // //===----------------------------------------------------------------------===// -#include "LLVMContextImpl.h" +#include "llvm/Instruction.h" #include "llvm/Type.h" #include "llvm/Instructions.h" -#include "llvm/Function.h" #include "llvm/Constants.h" -#include "llvm/GlobalVariable.h" #include "llvm/Module.h" #include "llvm/Support/CallSite.h" #include "llvm/Support/LeakDetector.h" @@ -52,7 +50,7 @@ Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps, Instruction::~Instruction() { assert(Parent == 0 && "Instruction still linked in the program!"); if (hasMetadata()) - getContext().pImpl->TheMetadata.ValueIsDeleted(this); + removeAllMetadata(); } @@ -462,7 +460,14 @@ bool Instruction::isSafeToSpeculativelyExecute() const { Instruction *Instruction::clone() const { Instruction *New = clone_impl(); New->SubclassOptionalData = SubclassOptionalData; - if (hasMetadata()) - getContext().pImpl->TheMetadata.ValueIsCloned(this, New); + if (!hasMetadata()) + return New; + + // Otherwise, enumerate and copy over metadata from the old instruction to the + // new one. + SmallVector<std::pair<unsigned, MDNode*>, 4> TheMDs; + getAllMetadata(TheMDs); + for (unsigned i = 0, e = TheMDs.size(); i != e; ++i) + New->setMetadata(TheMDs[i].first, TheMDs[i].second); return New; } diff --git a/lib/VMCore/Metadata.cpp b/lib/VMCore/Metadata.cpp index 8fa8d37..eb35289 100644 --- a/lib/VMCore/Metadata.cpp +++ b/lib/VMCore/Metadata.cpp @@ -273,26 +273,12 @@ public: void setMetadata(Instruction *Inst, unsigned Kind, MDNode *Node); - /// removeAllMetadata - Remove all metadata attached with an instruction. + /// removeAllMetadata - Remove all metadata attached to an instruction. void removeAllMetadata(Instruction *Inst); - - /// copyMD - If metadata is attached with Instruction In1 then attach /// the same metadata to In2. void copyMD(Instruction *In1, Instruction *In2); - - - /// ValueIsDeleted - This handler is used to update metadata store - /// when a value is deleted. - void ValueIsDeleted(const Value *) {} - void ValueIsDeleted(Instruction *Inst) { - removeAllMetadata(Inst); - } - - /// ValueIsCloned - This handler is used to update metadata store - /// when In1 is cloned to create In2. - void ValueIsCloned(const Instruction *In1, Instruction *In2); }; } @@ -413,20 +399,6 @@ void MetadataContextImpl::copyMD(Instruction *In1, Instruction *In2) { In2->setMetadata(I->first, I->second); } -/// ValueIsCloned - This handler is used to update metadata store -/// when In1 is cloned to create In2. -void MetadataContextImpl::ValueIsCloned(const Instruction *In1, - Instruction *In2) { - // Find Metadata handles for In1. - MDStoreTy::iterator I = MetadataStore.find(In1); - assert(I != MetadataStore.end() && "Invalid custom metadata info!"); - - // FIXME: Give all metadata handlers a chance to adjust. - MDMapTy &In1Info = I->second; - for (MDMapTy::iterator I = In1Info.begin(), E = In1Info.end(); I != E; ++I) - In2->setMetadata(I->first, I->second); -} - //===----------------------------------------------------------------------===// // MetadataContext implementation. // @@ -466,18 +438,6 @@ void MetadataContext::getMDKindNames(SmallVectorImpl<StringRef> &N) const { pImpl->getMDKindNames(N); } -/// ValueIsDeleted - This handler is used to update metadata store -/// when a value is deleted. -void MetadataContext::ValueIsDeleted(Instruction *Inst) { - pImpl->ValueIsDeleted(Inst); -} - -/// ValueIsCloned - This handler is used to update metadata store -/// when In1 is cloned to create In2. -void MetadataContext::ValueIsCloned(const Instruction *In1, Instruction *In2) { - pImpl->ValueIsCloned(In1, In2); -} - //===----------------------------------------------------------------------===// // Instruction Metadata method implementations. // @@ -509,3 +469,9 @@ void Instruction::getAllMetadataImpl(SmallVectorImpl<std::pair<unsigned, getContext().getMetadata().pImpl->getAllMetadata(this, Result); } +/// removeAllMetadata - Remove all metadata from this instruction. +void Instruction::removeAllMetadata() { + assert(hasMetadata() && "Caller should check"); + getContext().getMetadata().pImpl->removeAllMetadata(this); +} + |