From eaafbccdd8f87db75cf601cc75c8d0909a85a8e4 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Thu, 8 Nov 2007 00:04:50 +0000 Subject: [PATCH] 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. llvm-svn: 43855 --- include/llvm/Bitcode/Deserialize.h | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/include/llvm/Bitcode/Deserialize.h b/include/llvm/Bitcode/Deserialize.h index 5f8e1375593..48f78bf9e5d 100644 --- a/include/llvm/Bitcode/Deserialize.h +++ b/include/llvm/Bitcode/Deserialize.h @@ -168,17 +168,20 @@ public: } template - void BatchReadOwnedPtrs(unsigned NumPtrs, T** Ptrs) { - llvm::SmallVector PtrIDs; - PtrIDs.reserve(NumPtrs); - + void BatchReadOwnedPtrs(unsigned NumPtrs, T** Ptrs, bool AutoRegister=true) { for (unsigned i = 0; i < NumPtrs; ++i) - PtrIDs.push_back(ReadInt()); - - for (unsigned i = 0; i < NumPtrs; ++i) - Ptrs[i] = PtrIDs[i] ? SerializeTrait::Materialize(*this) : NULL; - } + reinterpret_cast(Ptrs[i]) = ReadInt(); + for (unsigned i = 0; i < NumPtrs; ++i) { + unsigned PtrID = reinterpret_cast(Ptrs[i]); + T* p = PtrID ? SerializeTrait::Materialize(*this) : NULL; + + if (PtrID && AutoRegister) + RegisterPtr(PtrID,p); + + Ptrs[i] = p; + } + } template void ReadPtr(T*& PtrRef, bool AllowBackpatch = true) {