diff options
author | Chris Lattner <sabre@nondot.org> | 2007-05-15 06:29:44 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-05-15 06:29:44 +0000 |
commit | a6f88ced8b4bc88ac63d2d11a0bcbbe5a54b938a (patch) | |
tree | 19a5a0e508d4a5e096e20902bcb73ea80f8bf18d /llvm/lib/Bitcode/Reader/BitcodeReader.cpp | |
parent | daed139420a6f524a5ab3295fdf460673c81dddc (diff) | |
download | bcm5719-llvm-a6f88ced8b4bc88ac63d2d11a0bcbbe5a54b938a.tar.gz bcm5719-llvm-a6f88ced8b4bc88ac63d2d11a0bcbbe5a54b938a.zip |
implement the ModuleProvider::dematerializeFunction hook
llvm-svn: 37080
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 445a7c248e3..3ee046b440a 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1114,7 +1114,6 @@ bool BitcodeReader::materializeFunction(Function *F, std::string *ErrInfo) { // 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 @@ bool BitcodeReader::materializeFunction(Function *F, std::string *ErrInfo) { 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; |