From d4bcefc7d9ff16710b2509e494614b5c08013567 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 24 Oct 2014 18:13:04 +0000 Subject: Don't ever call materializeAllPermanently during LTO. To do this, change the representation of lazy loaded functions. The previous representation cannot differentiate between a function whose body has been removed and one whose body hasn't been read from the .bc file. That means that in order to drop a function, the entire body had to be read. llvm-svn: 220580 --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp') diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index ca6d73c..507164c 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -2070,6 +2070,7 @@ std::error_code BitcodeReader::ParseModule(bool Resume) { // If this is a function with a body, remember the prototype we are // creating now, so that we can match up the body with them later. if (!isProto) { + Func->setIsMaterializable(true); FunctionsWithBodies.push_back(Func); if (LazyStreamer) DeferredFunctionInfo[Func] = 0; @@ -3281,14 +3282,6 @@ std::error_code BitcodeReader::FindFunctionInStream( void BitcodeReader::releaseBuffer() { Buffer.release(); } -bool BitcodeReader::isMaterializable(const GlobalValue *GV) const { - if (const Function *F = dyn_cast(GV)) { - return F->isDeclaration() && - DeferredFunctionInfo.count(const_cast(F)); - } - return false; -} - std::error_code BitcodeReader::Materialize(GlobalValue *GV) { Function *F = dyn_cast(GV); // If it's not a function or is already material, ignore the request. @@ -3308,6 +3301,7 @@ std::error_code BitcodeReader::Materialize(GlobalValue *GV) { if (std::error_code EC = ParseFunctionBody(F)) return EC; + F->setIsMaterializable(false); // Upgrade any old intrinsic calls in the function. for (UpgradedIntrinsicMap::iterator I = UpgradedIntrinsics.begin(), @@ -3349,6 +3343,7 @@ void BitcodeReader::Dematerialize(GlobalValue *GV) { // Just forget the function body, we can remat it later. F->dropAllReferences(); + F->setIsMaterializable(true); } std::error_code BitcodeReader::MaterializeModule(Module *M) { -- cgit v1.1