Changes in directory llvm/lib/Bitcode/Reader:
BitcodeReader.cpp updated: 1.48 -> 1.49 BitcodeReader.h updated: 1.19 -> 1.20 --- Log message: implement the ModuleProvider::dematerializeFunction hook --- Diffs of the changes: (+21 -9) BitcodeReader.cpp | 27 +++++++++++++++++++-------- BitcodeReader.h | 3 ++- 2 files changed, 21 insertions(+), 9 deletions(-) Index: llvm/lib/Bitcode/Reader/BitcodeReader.cpp diff -u llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.48 llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.49 --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1.48 Tue May 8 00:38:01 2007 +++ llvm/lib/Bitcode/Reader/BitcodeReader.cpp Tue May 15 01:29:44 2007 @@ -1114,7 +1114,6 @@ // restore the real linkage type for the function. Stream.JumpToBit(DFII->second.first); F->setLinkage((GlobalValue::LinkageTypes)DFII->second.second); - DeferredFunctionInfo.erase(DFII); if (ParseFunctionBody(F)) { if (ErrInfo) *ErrInfo = ErrorString; @@ -1124,14 +1123,26 @@ return false; } +void BitcodeReader::dematerializeFunction(Function *F) { + // If this function isn't materialized, or if it is a proto, this is a noop. + if (F->hasNotBeenReadFromBytecode() || F->isDeclaration()) + return; + + assert(DeferredFunctionInfo.count(F) && "No info to read function later?"); + + // Just forget the function body, we can remat it later. + F->deleteBody(); + F->setLinkage(GlobalValue::GhostLinkage); +} + + Module *BitcodeReader::materializeModule(std::string *ErrInfo) { - DenseMap<Function*, std::pair<uint64_t, unsigned> >::iterator I = - DeferredFunctionInfo.begin(); - while (!DeferredFunctionInfo.empty()) { - Function *F = (*I++).first; - assert(F->hasNotBeenReadFromBytecode() && - "Deserialized function found in map!"); - if (materializeFunction(F, ErrInfo)) + for (DenseMap<Function*, std::pair<uint64_t, unsigned> >::iterator I = + DeferredFunctionInfo.begin(), E = DeferredFunctionInfo.end(); I != E; + ++I) { + Function *F = I->first; + if (F->hasNotBeenReadFromBytecode() && + materializeFunction(F, ErrInfo)) return 0; } return TheModule; Index: llvm/lib/Bitcode/Reader/BitcodeReader.h diff -u llvm/lib/Bitcode/Reader/BitcodeReader.h:1.19 llvm/lib/Bitcode/Reader/BitcodeReader.h:1.20 --- llvm/lib/Bitcode/Reader/BitcodeReader.h:1.19 Sat May 5 22:23:14 2007 +++ llvm/lib/Bitcode/Reader/BitcodeReader.h Tue May 15 01:29:44 2007 @@ -123,7 +123,8 @@ virtual bool materializeFunction(Function *F, std::string *ErrInfo = 0); virtual Module *materializeModule(std::string *ErrInfo = 0); - + virtual void dematerializeFunction(Function *F); + bool Error(const char *Str) { ErrorString = Str; return true; _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits