diff options
author | Ted Kremenek <kremenek@apple.com> | 2007-11-17 03:34:33 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2007-11-17 03:34:33 +0000 |
commit | 247fdca789b10543848e110ab0860f99724b6788 (patch) | |
tree | 062e8fdb4d2e34e197243743b39c6b38f47ae296 /include/llvm/Bitcode/Deserialize.h | |
parent | b51b4b5fdfdd7a85ea66776d7900214f8b24f826 (diff) |
Reverted patch 44199:
http://llvm.org/viewvc/llvm-project?rev=44199&view=rev
This patch completely broke serialization due to an invariant I assumed but
did not hold. The assumed invariant was that all pointer IDs emitted by a call
to BatchEmitOwnedPtrs would be consecutive. This is only the case if there has
been no forward references to an owned pointer (and hence already registered
with the Serializer object).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44203 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Bitcode/Deserialize.h')
-rw-r--r-- | include/llvm/Bitcode/Deserialize.h | 86 |
1 files changed, 24 insertions, 62 deletions
diff --git a/include/llvm/Bitcode/Deserialize.h b/include/llvm/Bitcode/Deserialize.h index ef25da7140..9b84c8ed45 100644 --- a/include/llvm/Bitcode/Deserialize.h +++ b/include/llvm/Bitcode/Deserialize.h @@ -137,13 +137,7 @@ public: uint64_t ReadInt(); int64_t ReadSInt(); - SerializedPtrID ReadPtrID() { return (SerializedPtrID) ReadInt(); } - - SerializedPtrID ReadDiffPtrID(SerializedPtrID& PrevID) { - bool x = ReadBool(); - return (SerializedPtrID) (x ? (PrevID+1) : 0); - } bool ReadBool() { @@ -189,7 +183,7 @@ public: bool A1=true, bool A2=true) { SerializedPtrID ID1 = ReadPtrID(); - SerializedPtrID ID2 = ReadDiffPtrID(ID2); + SerializedPtrID ID2 = ReadPtrID(); P1 = (ID1) ? SerializeTrait<T1>::Create(*this) : NULL; if (ID1 && A1) RegisterPtr(ID1,P1); @@ -203,27 +197,8 @@ public: bool A1=true, bool A2=true, bool A3=true) { SerializedPtrID ID1 = ReadPtrID(); - SerializedPtrID ID2 = ReadDiffPtrID(ID1); - SerializedPtrID ID3 = ReadDiffPtrID(ID2); - - P1 = (ID1) ? SerializeTrait<T1>::Create(*this) : NULL; - if (ID1 && A1) RegisterPtr(ID1,P1); - - P2 = (ID2) ? SerializeTrait<T2>::Create(*this) : NULL; - if (ID2 && A2) RegisterPtr(ID2,P2); - - P3 = (ID3) ? SerializeTrait<T3>::Create(*this) : NULL; - if (ID3 && A3) RegisterPtr(ID3,P3); - } - - template <typename T1, typename T2, typename T3, typename T4> - void BatchReadOwnedPtrs(T1*& P1, T2*& P2, T3*& P3, T4*& P4, - bool A1=true, bool A2=true, bool A3=true, bool A4=true) { - - SerializedPtrID ID1 = ReadPtrID(); - SerializedPtrID ID2 = ReadDiffPtrID(ID1); - SerializedPtrID ID3 = ReadDiffPtrID(ID2); - SerializedPtrID ID4 = ReadDiffPtrID(ID3); + SerializedPtrID ID2 = ReadPtrID(); + SerializedPtrID ID3 = ReadPtrID(); P1 = (ID1) ? SerializeTrait<T1>::Create(*this) : NULL; if (ID1 && A1) RegisterPtr(ID1,P1); @@ -233,20 +208,14 @@ public: P3 = (ID3) ? SerializeTrait<T3>::Create(*this) : NULL; if (ID3 && A3) RegisterPtr(ID3,P3); - - P4 = (ID4) ? SerializeTrait<T4>::Create(*this) : NULL; - if (ID4 && A4) RegisterPtr(ID4,P4); } template <typename T> void BatchReadOwnedPtrs(unsigned NumPtrs, T** Ptrs, bool AutoRegister=true) { llvm::SmallVector<SerializedPtrID,10> BatchIDVec; - SerializedPtrID TempPtrID; - for (unsigned i = 0; i < NumPtrs; ++i) { - TempPtrID = i ? ReadDiffPtrID(TempPtrID) : ReadPtrID(); - BatchIDVec.push_back(TempPtrID); - } + for (unsigned i = 0; i < NumPtrs; ++i) + BatchIDVec.push_back(ReadPtrID()); for (unsigned i = 0; i < NumPtrs; ++i) { SerializedPtrID& PtrID = BatchIDVec[i]; @@ -263,19 +232,13 @@ public: template <typename T1, typename T2> void BatchReadOwnedPtrs(unsigned NumT1Ptrs, T1** Ptrs, T2*& P2, bool A1=true, bool A2=true) { - - SerializedPtrID ID2 = ReadPtrID(); - SerializedPtrID TempID = ID2; - - llvm::SmallVector<SerializedPtrID,10> BatchIDVec; - for (unsigned i = 0; i < NumT1Ptrs; ++i) { - TempID = ReadDiffPtrID(TempID); - BatchIDVec.push_back(TempID); - } + llvm::SmallVector<SerializedPtrID,10> BatchIDVec; + + for (unsigned i = 0; i < NumT1Ptrs; ++i) + BatchIDVec.push_back(ReadPtrID()); - P2 = (ID2) ? SerializeTrait<T2>::Create(*this) : NULL; - if (ID2 && A2) RegisterPtr(ID2,P2); + SerializedPtrID ID2 = ReadPtrID(); for (unsigned i = 0; i < NumT1Ptrs; ++i) { SerializedPtrID& PtrID = BatchIDVec[i]; @@ -286,31 +249,24 @@ public: RegisterPtr(PtrID,p); Ptrs[i] = p; - } + } + + P2 = (ID2) ? SerializeTrait<T2>::Create(*this) : NULL; + if (ID2 && A2) RegisterPtr(ID2,P2); } template <typename T1, typename T2, typename T3> void BatchReadOwnedPtrs(unsigned NumT1Ptrs, T1** Ptrs, T2*& P2, T3*& P3, bool A1=true, bool A2=true, bool A3=true) { - - SerializedPtrID ID2 = ReadPtrID(); - SerializedPtrID ID3 = ReadDiffPtrID(ID2); - - SerializedPtrID TempID = ID3; llvm::SmallVector<SerializedPtrID,10> BatchIDVec; - for (unsigned i = 0; i < NumT1Ptrs; ++i) { - TempID = ReadDiffPtrID(TempID); - BatchIDVec.push_back(TempID); - } - - P2 = (ID2) ? SerializeTrait<T2>::Create(*this) : NULL; - if (ID2 && A2) RegisterPtr(ID2,P2); + for (unsigned i = 0; i < NumT1Ptrs; ++i) + BatchIDVec.push_back(ReadPtrID()); - P3 = (ID3) ? SerializeTrait<T3>::Create(*this) : NULL; - if (ID3 && A3) RegisterPtr(ID3,P3); + SerializedPtrID ID2 = ReadPtrID(); + SerializedPtrID ID3 = ReadPtrID(); for (unsigned i = 0; i < NumT1Ptrs; ++i) { SerializedPtrID& PtrID = BatchIDVec[i]; @@ -322,6 +278,12 @@ public: Ptrs[i] = p; } + + P2 = (ID2) ? SerializeTrait<T2>::Create(*this) : NULL; + if (ID2 && A2) RegisterPtr(ID2,P2); + + P3 = (ID3) ? SerializeTrait<T3>::Create(*this) : NULL; + if (ID3 && A3) RegisterPtr(ID3,P3); } template <typename T> |