From 92ef975cc52069f5d96700f68aff9fda26021458 Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Wed, 29 Feb 2012 00:07:09 +0000 Subject: Fix PR12080 by ensuring that MaterializeModule actually reads all the bitcode in the streaming case. llvm-svn: 151676 --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 6 ++++++ llvm/lib/Bitcode/Reader/BitcodeReader.h | 10 ++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'llvm/lib/Bitcode/Reader') diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 899154971b8..e3990403bd7 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -2789,6 +2789,12 @@ bool BitcodeReader::MaterializeModule(Module *M, std::string *ErrInfo) { Materialize(F, ErrInfo)) return true; + // At this point, if there are any function bodies, the current bit is + // pointing to the END_BLOCK record after them. Now make sure the rest + // of the bits in the module have been read. + if (NextUnreadBit) + ParseModule(true); + // Upgrade any intrinsic calls that slipped through (should not happen!) and // delete the old functions to clean up. We can't do this unless the entire // module is materialized because there could always be another function body diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.h b/llvm/lib/Bitcode/Reader/BitcodeReader.h index ad7baa732da..e7c4e94f785 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.h +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.h @@ -182,13 +182,15 @@ class BitcodeReader : public GVMaterializer { public: explicit BitcodeReader(MemoryBuffer *buffer, LLVMContext &C) : Context(C), TheModule(0), Buffer(buffer), BufferOwned(false), - LazyStreamer(0), SeenValueSymbolTable(false), ErrorString(0), - ValueList(C), MDValueList(C), SeenFirstFunctionBody(false) { + LazyStreamer(0), NextUnreadBit(0), SeenValueSymbolTable(false), + ErrorString(0), ValueList(C), MDValueList(C), + SeenFirstFunctionBody(false) { } explicit BitcodeReader(DataStreamer *streamer, LLVMContext &C) : Context(C), TheModule(0), Buffer(0), BufferOwned(false), - LazyStreamer(streamer), SeenValueSymbolTable(false), ErrorString(0), - ValueList(C), MDValueList(C), SeenFirstFunctionBody(false) { + LazyStreamer(streamer), NextUnreadBit(0), SeenValueSymbolTable(false), + ErrorString(0), ValueList(C), MDValueList(C), + SeenFirstFunctionBody(false) { } ~BitcodeReader() { FreeState(); -- cgit v1.2.3