diff --git a/llvm/include/llvm/Bitcode/Deserialize.h b/llvm/include/llvm/Bitcode/Deserialize.h index 5f8e13755932..48f78bf9e5d9 100644 --- a/llvm/include/llvm/Bitcode/Deserialize.h +++ b/llvm/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) {