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) { _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits