From d015c7b4fdc70729bd8bd976006225c683f944f7 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Tue, 6 Nov 2007 19:49:16 +0000 Subject: [PATCH] Added support for processing abbreviations in the Deserializer. Added some #ifdef-controlled messages for debugging backpatching. llvm-svn: 43771 --- llvm/include/llvm/Bitcode/Deserialize.h | 2 +- llvm/lib/Bitcode/Reader/Deserialize.cpp | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/llvm/include/llvm/Bitcode/Deserialize.h b/llvm/include/llvm/Bitcode/Deserialize.h index 0398e434ca49..283e6035c795 100644 --- a/llvm/include/llvm/Bitcode/Deserialize.h +++ b/llvm/include/llvm/Bitcode/Deserialize.h @@ -156,9 +156,9 @@ public: bool AtEnd(); + bool inRecord(); private: void ReadRecord(); - bool inRecord(); uintptr_t ReadInternalRefPtr(); static inline bool HasFinalPtr(MapTy::value_type& V) { diff --git a/llvm/lib/Bitcode/Reader/Deserialize.cpp b/llvm/lib/Bitcode/Reader/Deserialize.cpp index ef4e4f7e0000..5642f37fac5d 100644 --- a/llvm/lib/Bitcode/Reader/Deserialize.cpp +++ b/llvm/lib/Bitcode/Reader/Deserialize.cpp @@ -13,6 +13,10 @@ #include "llvm/Bitcode/Deserialize.h" +#ifdef DEBUG_BACKPATCH +#include "llvm/Support/Streams.h" +#endif + using namespace llvm; Deserializer::Deserializer(BitstreamReader& stream) @@ -71,6 +75,11 @@ void Deserializer::ReadRecord() { continue; } + if (Code == bitc::DEFINE_ABBREV) { + Stream.ReadAbbrevRecord(); + continue; + } + break; } @@ -136,6 +145,10 @@ void Deserializer::RegisterPtr(unsigned PtrId, const void* Ptr) { assert (!HasFinalPtr(E) && "Pointer already registered."); +#ifdef DEBUG_BACKPATCH + llvm::cerr << "RegisterPtr: " << PtrId << " => " << Ptr << "\n"; +#endif + SetPtr(E,Ptr); } @@ -145,8 +158,12 @@ void Deserializer::ReadUIntPtr(uintptr_t& PtrRef) { if (PtrId == 0) { PtrRef = 0; return; - } - + } + +#ifdef DEBUG_BACKPATCH + llvm::cerr << "ReadUintPtr: " << PtrId << "\n"; +#endif + MapTy::value_type& E = BPatchMap.FindAndConstruct(BPKey(PtrId)); if (HasFinalPtr(E))