Fix PR12080 by ensuring that MaterializeModule actually reads all the bitcode

in the streaming case.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151676 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Derek Schuff 2012-02-29 00:07:09 +00:00
parent d0fff1886c
commit 0ffe698429
2 changed files with 12 additions and 4 deletions

View File

@ -2789,6 +2789,12 @@ bool BitcodeReader::MaterializeModule(Module *M, std::string *ErrInfo) {
Materialize(F, ErrInfo)) Materialize(F, ErrInfo))
return true; 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 // 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 // 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 // module is materialized because there could always be another function body

View File

@ -182,13 +182,15 @@ class BitcodeReader : public GVMaterializer {
public: public:
explicit BitcodeReader(MemoryBuffer *buffer, LLVMContext &C) explicit BitcodeReader(MemoryBuffer *buffer, LLVMContext &C)
: Context(C), TheModule(0), Buffer(buffer), BufferOwned(false), : Context(C), TheModule(0), Buffer(buffer), BufferOwned(false),
LazyStreamer(0), SeenValueSymbolTable(false), ErrorString(0), LazyStreamer(0), NextUnreadBit(0), SeenValueSymbolTable(false),
ValueList(C), MDValueList(C), SeenFirstFunctionBody(false) { ErrorString(0), ValueList(C), MDValueList(C),
SeenFirstFunctionBody(false) {
} }
explicit BitcodeReader(DataStreamer *streamer, LLVMContext &C) explicit BitcodeReader(DataStreamer *streamer, LLVMContext &C)
: Context(C), TheModule(0), Buffer(0), BufferOwned(false), : Context(C), TheModule(0), Buffer(0), BufferOwned(false),
LazyStreamer(streamer), SeenValueSymbolTable(false), ErrorString(0), LazyStreamer(streamer), NextUnreadBit(0), SeenValueSymbolTable(false),
ValueList(C), MDValueList(C), SeenFirstFunctionBody(false) { ErrorString(0), ValueList(C), MDValueList(C),
SeenFirstFunctionBody(false) {
} }
~BitcodeReader() { ~BitcodeReader() {
FreeState(); FreeState();