Be lazy about loading metadata in IRObjectFile.

This speeds up llvm-ar building lib64/libclangSema.a with debug IR files
from 8.658015807 seconds to just 0.351036519 seconds :-)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232221 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2015-03-13 21:54:20 +00:00
parent fbbc2cc358
commit dc6141a4ff
6 changed files with 15 additions and 2 deletions

View File

@@ -53,6 +53,8 @@ public:
/// ///
virtual std::error_code MaterializeModule(Module *M) = 0; virtual std::error_code MaterializeModule(Module *M) = 0;
virtual std::error_code materializeMetadata() = 0;
virtual std::vector<StructType *> getIdentifiedStructTypes() const = 0; virtual std::vector<StructType *> getIdentifiedStructTypes() const = 0;
}; };

View File

@@ -502,6 +502,8 @@ public:
/// Materializer. /// Materializer.
std::error_code materializeAllPermanently(); std::error_code materializeAllPermanently();
std::error_code materializeMetadata();
/// @} /// @}
/// @name Direct access to the globals list, functions list, and symbol table /// @name Direct access to the globals list, functions list, and symbol table
/// @{ /// @{

View File

@@ -255,7 +255,7 @@ public:
static uint64_t decodeSignRotatedValue(uint64_t V); static uint64_t decodeSignRotatedValue(uint64_t V);
/// Materialize any deferred Metadata block. /// Materialize any deferred Metadata block.
std::error_code materializeMetadata(); std::error_code materializeMetadata() override;
private: private:
std::vector<StructType *> IdentifiedStructTypes; std::vector<StructType *> IdentifiedStructTypes;

View File

@@ -413,6 +413,12 @@ std::error_code Module::materializeAllPermanently() {
return std::error_code(); return std::error_code();
} }
std::error_code Module::materializeMetadata() {
if (!Materializer)
return std::error_code();
return Materializer->materializeMetadata();
}
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// Other module related stuff. // Other module related stuff.
// //

View File

@@ -300,7 +300,9 @@ llvm::object::IRObjectFile::create(MemoryBufferRef Object,
std::unique_ptr<MemoryBuffer> Buff( std::unique_ptr<MemoryBuffer> Buff(
MemoryBuffer::getMemBuffer(BCOrErr.get(), false)); MemoryBuffer::getMemBuffer(BCOrErr.get(), false));
ErrorOr<Module *> MOrErr = getLazyBitcodeModule(std::move(Buff), Context); ErrorOr<Module *> MOrErr =
getLazyBitcodeModule(std::move(Buff), Context, nullptr,
/*ShouldLazyLoadMetadata*/ true);
if (std::error_code EC = MOrErr.getError()) if (std::error_code EC = MOrErr.getError())
return EC; return EC;

View File

@@ -598,6 +598,7 @@ getModuleForFile(LLVMContext &Context, claimed_file &F,
Module &M = Obj.getModule(); Module &M = Obj.getModule();
M.materializeMetadata();
UpgradeDebugInfo(M); UpgradeDebugInfo(M);
SmallPtrSet<GlobalValue *, 8> Used; SmallPtrSet<GlobalValue *, 8> Used;