Author: kremenek Date: Mon Nov 12 13:11:15 2007 New Revision: 44021 URL: http://llvm.org/viewvc/llvm-project?rev=44021&view=rev Log: Added versions of ReadPtr that takes an explicit SerializedPtrID. This allows clients of the Deserializer to read the pointer ID before they are ready to deserialize the object (which can mean registering a pointer reference with the backpatcher).
Changed some methods that took an argument "SerializedPtrID" to "const SerializedPtrID&" (pass-by-reference). This is to accommodate a future revision of SerializedPtrID where it may be much fatter than an unsigned integer. Modified: llvm/trunk/include/llvm/Bitcode/Deserialize.h llvm/trunk/lib/Bitcode/Reader/Deserialize.cpp Modified: llvm/trunk/include/llvm/Bitcode/Deserialize.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/Deserialize.h?rev=44021&r1=44020&r2=44021&view=diff ============================================================================== --- llvm/trunk/include/llvm/Bitcode/Deserialize.h (original) +++ llvm/trunk/include/llvm/Bitcode/Deserialize.h Mon Nov 12 13:11:15 2007 @@ -240,10 +240,28 @@ ReadPtr(const_cast<T*&>(PtrRef), AllowBackpatch); } + + template <typename T> + void ReadPtr(T*& PtrRef, const SerializedPtrID& PtrID, bool AllowBackpatch = true) { + ReadUIntPtr(reinterpret_cast<uintptr_t&>(PtrRef), PtrID, AllowBackpatch); + } + + template <typename T> + void ReadPtr(const T*& PtrRef, const SerializedPtrID& PtrID, + bool AllowBackpatch = true) { + + ReadPtr(const_cast<T*&>(PtrRef), PtrID, AllowBackpatch); + } + template <typename T> T* ReadPtr() { T* x; ReadPtr<T>(x,false); return x; } - void ReadUIntPtr(uintptr_t& PtrRef, bool AllowBackpatch = true); + void ReadUIntPtr(uintptr_t& PtrRef, const SerializedPtrID& PtrID, + bool AllowBackpatch = true); + + void ReadUIntPtr(uintptr_t& PtrRef, bool AllowBackpatch = true) { + ReadUIntPtr(PtrRef,ReadPtrID(),AllowBackpatch); + } template <typename T> T& ReadRef() { @@ -251,7 +269,7 @@ return *p; } - void RegisterPtr(SerializedPtrID PtrId, const void* Ptr); + void RegisterPtr(const SerializedPtrID& PtrID, const void* Ptr); void RegisterPtr(const void* Ptr) { RegisterPtr(ReadPtrID(),Ptr); @@ -263,7 +281,7 @@ } template<typename T> - void RegisterRef(SerializedPtrID PtrID, const T& x) { + void RegisterRef(const SerializedPtrID& PtrID, const T& x) { RegisterPtr(PtrID,&x); } Modified: llvm/trunk/lib/Bitcode/Reader/Deserialize.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/Deserialize.cpp?rev=44021&r1=44020&r2=44021&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Reader/Deserialize.cpp (original) +++ llvm/trunk/lib/Bitcode/Reader/Deserialize.cpp Mon Nov 12 13:11:15 2007 @@ -324,7 +324,9 @@ buff.push_back('\0'); } -void Deserializer::RegisterPtr(SerializedPtrID PtrId, const void* Ptr) { +void Deserializer::RegisterPtr(const SerializedPtrID& PtrId, + const void* Ptr) { + MapTy::value_type& E = BPatchMap.FindAndConstruct(BPKey(PtrId)); assert (!HasFinalPtr(E) && "Pointer already registered."); @@ -336,9 +338,9 @@ SetPtr(E,Ptr); } -void Deserializer::ReadUIntPtr(uintptr_t& PtrRef, bool AllowBackpatch) { - SerializedPtrID PtrId = ReadPtrID(); - +void Deserializer::ReadUIntPtr(uintptr_t& PtrRef, + const SerializedPtrID& PtrId, + bool AllowBackpatch) { if (PtrId == 0) { PtrRef = 0; return; _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits