diff options
author | Ted Kremenek <kremenek@apple.com> | 2007-10-31 19:58:32 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2007-10-31 19:58:32 +0000 |
commit | eb9409dbb9c5fe963bf28973c5697fddfcaf48ce (patch) | |
tree | 5f8d3e20742b0f235908adc290e2632c563debf2 /lib/Bitcode | |
parent | 8aac61cff0f4c5f66412502771dd281696114ceb (diff) | |
download | external_llvm-eb9409dbb9c5fe963bf28973c5697fddfcaf48ce.zip external_llvm-eb9409dbb9c5fe963bf28973c5697fddfcaf48ce.tar.gz external_llvm-eb9409dbb9c5fe963bf28973c5697fddfcaf48ce.tar.bz2 |
Implemented deserialization of references. References are handled
just like pointers, except that they cannot be backpatched. This
means that references are essentially non-owning pointers where the
referred object must be deserialized prior to the reference being
deserialized. Because of the nature of references, this ordering of
objects is always possible.
Fixed a bug in backpatching code (returning the backpatched pointer
would accidentally include a bit flag).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43570 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bitcode')
-rw-r--r-- | lib/Bitcode/Reader/Deserialize.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/Bitcode/Reader/Deserialize.cpp b/lib/Bitcode/Reader/Deserialize.cpp index ff0dd44..4b58cf4 100644 --- a/lib/Bitcode/Reader/Deserialize.cpp +++ b/lib/Bitcode/Reader/Deserialize.cpp @@ -115,7 +115,7 @@ void Deserializer::ReadUIntPtr(uintptr_t& PtrRef) { BPatchEntry& E = BPatchMap[PtrId]; if (E.hasFinalPtr()) - PtrRef = E.getRawPtr(); + PtrRef = E.getFinalPtr(); else { // Register backpatch. Check the freelist for a BPNode. BPNode* N; @@ -132,6 +132,18 @@ void Deserializer::ReadUIntPtr(uintptr_t& PtrRef) { } } +uintptr_t Deserializer::ReadInternalRefPtr() { + unsigned PtrId = ReadInt(); + + assert (PtrId != 0 && "References cannot refer the NULL address."); + + BPatchEntry& E = BPatchMap[PtrId]; + + assert (E.hasFinalPtr() && + "Cannot backpatch references. Object must be already deserialized."); + + return E.getFinalPtr(); +} void Deserializer::BPatchEntry::setFinalPtr(BPNode*& FreeList, void* P) { assert (!hasFinalPtr()); |