From 48f848716e80d01619b239111db48bfac77baad1 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 1 May 2007 04:59:48 +0000 Subject: implement scafolding for lazy deserialization of function bodies git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36614 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Bitcode/Reader/BitcodeReader.h | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'lib/Bitcode/Reader/BitcodeReader.h') diff --git a/lib/Bitcode/Reader/BitcodeReader.h b/lib/Bitcode/Reader/BitcodeReader.h index 0935c06f93..470758f0e5 100644 --- a/lib/Bitcode/Reader/BitcodeReader.h +++ b/lib/Bitcode/Reader/BitcodeReader.h @@ -17,7 +17,9 @@ #include "llvm/ModuleProvider.h" #include "llvm/Type.h" #include "llvm/User.h" +#include "llvm/Bitcode/BitstreamReader.h" #include "llvm/Bitcode/LLVMBitCodes.h" +#include "llvm/ADT/DenseMap.h" #include namespace llvm { @@ -59,14 +61,31 @@ public: class BitcodeReader : public ModuleProvider { MemoryBuffer *Buffer; + BitstreamReader Stream; + const char *ErrorString; std::vector TypeList; BitcodeReaderValueList ValueList; std::vector > GlobalInits; std::vector > AliasInits; + + // When reading the module header, this list is populated with functions that + // have bodies later in the file. + std::vector FunctionsWithBodies; + + // After the module header has been read, the FunctionsWithBodies list is + // reversed. This keeps track of whether we've done this yet. + bool HasReversedFunctionsWithBodies; + + /// DeferredFunctionInfo - When function bodies are initially scanned, this + /// map contains info about where to find deferred function body (in the + /// stream) and what linkage the original function had. + DenseMap > DeferredFunctionInfo; public: - BitcodeReader(MemoryBuffer *buffer) : Buffer(buffer), ErrorString(0) {} + BitcodeReader(MemoryBuffer *buffer) : Buffer(buffer), ErrorString(0) { + HasReversedFunctionsWithBodies = false; + } ~BitcodeReader(); @@ -77,10 +96,7 @@ public: Buffer = 0; } - virtual bool materializeFunction(Function *F, std::string *ErrInfo = 0) { - // FIXME: TODO - return false; - } + virtual bool materializeFunction(Function *F, std::string *ErrInfo = 0); virtual Module *materializeModule(std::string *ErrInfo = 0) { // FIXME: TODO @@ -106,6 +122,7 @@ private: bool ParseTypeSymbolTable(BitstreamReader &Stream); bool ParseValueSymbolTable(BitstreamReader &Stream); bool ParseConstants(BitstreamReader &Stream); + bool ParseFunction(BitstreamReader &Stream); bool ResolveGlobalAndAliasInits(); }; -- cgit v1.2.3