[llvm-commits] [llvm] r43855 - /llvm/trunk/include/llvm/Bitcode/Deserialize.h

Ted Kremenek kremenek at apple.com
Wed Nov 7 16:04:53 PST 2007


Author: kremenek
Date: Wed Nov  7 18:04:50 2007
New Revision: 43855

URL: http://llvm.org/viewvc/llvm-project?rev=43855&view=rev
Log:
Revised implementation of BatchReadOwnedPtrs() that deserializes an
array of pointers to not allocate a second array to contain the pointer ids.

Fixed bug in the same member function where deserialized pointers were
not being registered with the backpatcher.

Modified:
    llvm/trunk/include/llvm/Bitcode/Deserialize.h

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

==============================================================================
--- llvm/trunk/include/llvm/Bitcode/Deserialize.h (original)
+++ llvm/trunk/include/llvm/Bitcode/Deserialize.h Wed Nov  7 18:04:50 2007
@@ -168,17 +168,20 @@
   }
   
   template <typename T>
-  void BatchReadOwnedPtrs(unsigned NumPtrs, T** Ptrs) {
-    llvm::SmallVector<unsigned,20> PtrIDs;
-    PtrIDs.reserve(NumPtrs);
-    
-    for (unsigned i = 0; i < NumPtrs; ++i)
-      PtrIDs.push_back(ReadInt());
-    
+  void BatchReadOwnedPtrs(unsigned NumPtrs, T** Ptrs, bool AutoRegister=true) {
     for (unsigned i = 0; i < NumPtrs; ++i)
-      Ptrs[i] = PtrIDs[i] ? SerializeTrait<T>::Materialize(*this) : NULL;
-  }
+      reinterpret_cast<uintptr_t&>(Ptrs[i]) = ReadInt();
     
+    for (unsigned i = 0; i < NumPtrs; ++i) {
+      unsigned PtrID = reinterpret_cast<uintptr_t>(Ptrs[i]);
+      T* p = PtrID ? SerializeTrait<T>::Materialize(*this) : NULL;
+      
+      if (PtrID && AutoRegister)
+        RegisterPtr(PtrID,p);
+      
+      Ptrs[i] = p;
+    }
+  }    
   
   template <typename T>
   void ReadPtr(T*& PtrRef, bool AllowBackpatch = true) {





More information about the llvm-commits mailing list