Author: kremenek
Date: Wed Nov 14 02:05:03 2007
New Revision: 44105

URL: http://llvm.org/viewvc/llvm-project?rev=44105&view=rev
Log:
Added two new overloaded versions of BatchEmitOwnedPtrs and
BatchReadOwnedPtrs.

Modified:
    llvm/trunk/include/llvm/Bitcode/Deserialize.h
    llvm/trunk/include/llvm/Bitcode/Serialize.h
    llvm/trunk/lib/Bitcode/Reader/Deserialize.cpp

Modified: llvm/trunk/include/llvm/Bitcode/Deserialize.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/Deserialize.h?rev=44105&r1=44104&r2=44105&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Bitcode/Deserialize.h (original)
+++ llvm/trunk/include/llvm/Bitcode/Deserialize.h Wed Nov 14 02:05:03 2007
@@ -230,6 +230,32 @@
     }
   }
   
+  template <typename T1, typename T2>
+  void BatchReadOwnedPtrs(unsigned NumT1Ptrs, T1** Ptrs, T2*& P2,
+                          bool A1=true, bool A2=true) {
+    
+    BatchIDVec.clear();
+    
+    for (unsigned i = 0; i < NumT1Ptrs; ++i)
+      BatchIDVec.push_back(ReadPtrID());
+    
+    SerializedPtrID ID2 = ReadPtrID();
+    
+    for (unsigned i = 0; i < NumT1Ptrs; ++i) {
+      SerializedPtrID& PtrID = BatchIDVec[i];
+      
+      T1* p = PtrID ? SerializeTrait<T1>::Create(*this) : NULL;
+      
+      if (PtrID && A1)
+        RegisterPtr(PtrID,p);
+      
+      Ptrs[i] = p;
+    }
+    
+    P2 = (ID2) ? SerializeTrait<T2>::Create(*this) : NULL;
+    if (ID2 && A2) RegisterPtr(ID2,P2);    
+  }    
+  
   template <typename T1, typename T2, typename T3>
   void BatchReadOwnedPtrs(unsigned NumT1Ptrs, T1** Ptrs, 
                           T2*& P2, T3*& P3,

Modified: llvm/trunk/include/llvm/Bitcode/Serialize.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/Serialize.h?rev=44105&r1=44104&r2=44105&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Bitcode/Serialize.h (original)
+++ llvm/trunk/include/llvm/Bitcode/Serialize.h Wed Nov 14 02:05:03 2007
@@ -94,6 +94,20 @@
       if (Ptrs[i]) SerializeTrait<T>::Emit(*this,*Ptrs[i]);
   }
   
+  template <typename T1, typename T2>
+  void BatchEmitOwnedPtrs(unsigned NumT1Ptrs, T1* const * Ptrs, T2* p2) {
+    
+    for (unsigned i = 0; i < NumT1Ptrs; ++i)
+      EmitPtr(Ptrs[i]);
+    
+    EmitPtr(p2);
+    
+    for (unsigned i = 0; i < NumT1Ptrs; ++i)
+      if (Ptrs[i]) SerializeTrait<T1>::Emit(*this,*Ptrs[i]);
+    
+    if (p2) SerializeTrait<T2>::Emit(*this,*p2);
+  }
+  
   template <typename T1, typename T2, typename T3>
   void BatchEmitOwnedPtrs(unsigned NumT1Ptrs, T1* const * Ptrs,
                           T2* p2, T3* p3) {

Modified: llvm/trunk/lib/Bitcode/Reader/Deserialize.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/Deserialize.cpp?rev=44105&r1=44104&r2=44105&view=diff

==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/Deserialize.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/Deserialize.cpp Wed Nov 14 02:05:03 2007
@@ -13,6 +13,8 @@
 
 #include "llvm/Bitcode/Deserialize.h"
 
+#define DEBUG_BACKPATCH
+
 #ifdef DEBUG_BACKPATCH
 #include "llvm/Support/Streams.h"
 #endif
@@ -346,18 +348,24 @@
     return;
   }
   
-#ifdef DEBUG_BACKPATCH
-  llvm::cerr << "ReadUintPtr: " << PtrId << "\n";
-#endif
-  
   MapTy::value_type& E = BPatchMap.FindAndConstruct(BPKey(PtrId));
   
-  if (HasFinalPtr(E))
+  if (HasFinalPtr(E)) {
     PtrRef = GetFinalPtr(E);
+
+#ifdef DEBUG_BACKPATCH
+    llvm::cerr << "ReadUintPtr: " << PtrId
+               << " <-- " <<  (void*) GetFinalPtr(E) << '\n';
+#endif    
+  }
   else {
     assert (AllowBackpatch &&
             "Client forbids backpatching for this pointer.");
     
+#ifdef DEBUG_BACKPATCH
+    llvm::cerr << "ReadUintPtr: " << PtrId << " (NO PTR YET)\n";
+#endif
+    
     // Register backpatch.  Check the freelist for a BPNode.
     BPNode* N;
 


_______________________________________________
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

Reply via email to