diff options
author | Ted Kremenek <kremenek@apple.com> | 2007-11-08 00:04:50 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2007-11-08 00:04:50 +0000 |
commit | f5b9dc34cbe6c9aea9f213d99bfe7ca2164d1a36 (patch) | |
tree | 68f3d52185fa1f302fbd339ddb994bdba459053f | |
parent | 2d0f50551cc3a8ebb9965a159e4d5535b4544335 (diff) | |
download | external_llvm-f5b9dc34cbe6c9aea9f213d99bfe7ca2164d1a36.zip external_llvm-f5b9dc34cbe6c9aea9f213d99bfe7ca2164d1a36.tar.gz external_llvm-f5b9dc34cbe6c9aea9f213d99bfe7ca2164d1a36.tar.bz2 |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43855 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/Bitcode/Deserialize.h | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/include/llvm/Bitcode/Deserialize.h b/include/llvm/Bitcode/Deserialize.h index 5f8e137..48f78bf 100644 --- a/include/llvm/Bitcode/Deserialize.h +++ b/include/llvm/Bitcode/Deserialize.h @@ -168,17 +168,20 @@ public: } 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) { |