summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-03-13 21:54:20 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-03-13 21:54:20 +0000
commitcba833a09d06598f74a8f2ae4c612b1ea092d886 (patch)
treeff6c91c875a48e7d558bd027ccadd873708156cc
parent794e6a60a8ceab3781a8b99952f24592a4a9c007 (diff)
downloadbcm5719-llvm-cba833a09d06598f74a8f2ae4c612b1ea092d886.tar.gz
bcm5719-llvm-cba833a09d06598f74a8f2ae4c612b1ea092d886.zip
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 :-) llvm-svn: 232221
-rw-r--r--llvm/include/llvm/IR/GVMaterializer.h2
-rw-r--r--llvm/include/llvm/IR/Module.h2
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.h2
-rw-r--r--llvm/lib/IR/Module.cpp6
-rw-r--r--llvm/lib/Object/IRObjectFile.cpp4
-rw-r--r--llvm/tools/gold/gold-plugin.cpp1
6 files changed, 15 insertions, 2 deletions
diff --git a/llvm/include/llvm/IR/GVMaterializer.h b/llvm/include/llvm/IR/GVMaterializer.h
index 6f57dc2a98a..ae2f2e1aefb 100644
--- a/llvm/include/llvm/IR/GVMaterializer.h
+++ b/llvm/include/llvm/IR/GVMaterializer.h
@@ -53,6 +53,8 @@ public:
///
virtual std::error_code MaterializeModule(Module *M) = 0;
+ virtual std::error_code materializeMetadata() = 0;
+
virtual std::vector<StructType *> getIdentifiedStructTypes() const = 0;
};
diff --git a/llvm/include/llvm/IR/Module.h b/llvm/include/llvm/IR/Module.h
index 698e8747495..ac60c8e885e 100644
--- a/llvm/include/llvm/IR/Module.h
+++ b/llvm/include/llvm/IR/Module.h
@@ -502,6 +502,8 @@ public:
/// Materializer.
std::error_code materializeAllPermanently();
+ std::error_code materializeMetadata();
+
/// @}
/// @name Direct access to the globals list, functions list, and symbol table
/// @{
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.h b/llvm/lib/Bitcode/Reader/BitcodeReader.h
index 0a69148d84d..27e8b2e2111 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.h
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.h
@@ -255,7 +255,7 @@ public:
static uint64_t decodeSignRotatedValue(uint64_t V);
/// Materialize any deferred Metadata block.
- std::error_code materializeMetadata();
+ std::error_code materializeMetadata() override;
private:
std::vector<StructType *> IdentifiedStructTypes;
diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp
index 3a88db9754a..3e8f91fee74 100644
--- a/llvm/lib/IR/Module.cpp
+++ b/llvm/lib/IR/Module.cpp
@@ -413,6 +413,12 @@ std::error_code Module::materializeAllPermanently() {
return std::error_code();
}
+std::error_code Module::materializeMetadata() {
+ if (!Materializer)
+ return std::error_code();
+ return Materializer->materializeMetadata();
+}
+
//===----------------------------------------------------------------------===//
// Other module related stuff.
//
diff --git a/llvm/lib/Object/IRObjectFile.cpp b/llvm/lib/Object/IRObjectFile.cpp
index 6369d8befd1..58c4ca312e8 100644
--- a/llvm/lib/Object/IRObjectFile.cpp
+++ b/llvm/lib/Object/IRObjectFile.cpp
@@ -300,7 +300,9 @@ llvm::object::IRObjectFile::create(MemoryBufferRef Object,
std::unique_ptr<MemoryBuffer> Buff(
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())
return EC;
diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp
index f7379ea314a..8decc8ea6d5 100644
--- a/llvm/tools/gold/gold-plugin.cpp
+++ b/llvm/tools/gold/gold-plugin.cpp
@@ -598,6 +598,7 @@ getModuleForFile(LLVMContext &Context, claimed_file &F,
Module &M = Obj.getModule();
+ M.materializeMetadata();
UpgradeDebugInfo(M);
SmallPtrSet<GlobalValue *, 8> Used;
OpenPOWER on IntegriCloud