[llvm-commits] [llvm] r92252 - in /llvm/trunk: include/llvm/Instruction.h include/llvm/Metadata.h lib/VMCore/Instruction.cpp lib/VMCore/Metadata.cpp

Chris Lattner sabre at nondot.org
Mon Dec 28 23:44:16 PST 2009


Author: lattner
Date: Tue Dec 29 01:44:16 2009
New Revision: 92252

URL: http://llvm.org/viewvc/llvm-project?rev=92252&view=rev
Log:
remove some unneeded Metadata interfaces.

Modified:
    llvm/trunk/include/llvm/Instruction.h
    llvm/trunk/include/llvm/Metadata.h
    llvm/trunk/lib/VMCore/Instruction.cpp
    llvm/trunk/lib/VMCore/Metadata.cpp

Modified: llvm/trunk/include/llvm/Instruction.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instruction.h?rev=92252&r1=92251&r2=92252&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Instruction.h (original)
+++ llvm/trunk/include/llvm/Instruction.h Tue Dec 29 01:44:16 2009
@@ -160,6 +160,7 @@
   MDNode *getMetadataImpl(unsigned KindID) const;
   MDNode *getMetadataImpl(const char *Kind) const;
   void getAllMetadataImpl(SmallVectorImpl<std::pair<unsigned,MDNode*> > &)const;
+  void removeAllMetadata();
 public:
   //===--------------------------------------------------------------------===//
   // Predicates and helper methods.

Modified: llvm/trunk/include/llvm/Metadata.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Metadata.h?rev=92252&r1=92251&r2=92252&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Metadata.h (original)
+++ llvm/trunk/include/llvm/Metadata.h Tue Dec 29 01:44:16 2009
@@ -231,14 +231,6 @@
   /// getMDKindNames - Populate client supplied SmallVector with the name for
   /// each custom metadata ID.   ID #0 is not used, so it is filled in as empty.
   void getMDKindNames(SmallVectorImpl<StringRef> &) const;
-
-  /// ValueIsDeleted - This handler is used to update metadata store
-  /// when a value is deleted.
-  void ValueIsDeleted(Instruction *Inst);
-
-  /// ValueIsCloned - This handler is used to update metadata store
-  /// when In1 is cloned to create In2.
-  void ValueIsCloned(const Instruction *In1, Instruction *In2);
 };
 
 } // end llvm namespace

Modified: llvm/trunk/lib/VMCore/Instruction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instruction.cpp?rev=92252&r1=92251&r2=92252&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Instruction.cpp (original)
+++ llvm/trunk/lib/VMCore/Instruction.cpp Tue Dec 29 01:44:16 2009
@@ -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() {
   assert(Parent == 0 && "Instruction still linked in the program!");
   if (hasMetadata())
-    getContext().pImpl->TheMetadata.ValueIsDeleted(this);
+    removeAllMetadata();
 }
 
 
@@ -462,7 +460,14 @@
 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;
 }

Modified: llvm/trunk/lib/VMCore/Metadata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Metadata.cpp?rev=92252&r1=92251&r2=92252&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Metadata.cpp (original)
+++ llvm/trunk/lib/VMCore/Metadata.cpp Tue Dec 29 01:44:16 2009
@@ -273,26 +273,12 @@
 
   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 @@
     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 @@
   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 @@
   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);
+}
+





More information about the llvm-commits mailing list