[llvm] r232221 - Be lazy about loading metadata in IRObjectFile.
Duncan P. N. Exon Smith
dexonsmith at apple.com
Fri Mar 13 15:06:37 PDT 2015
> On 2015-Mar-13, at 14:54, Rafael Espindola <rafael.espindola at gmail.com> wrote:
>
> Author: rafael
> Date: Fri Mar 13 16:54:20 2015
> New Revision: 232221
>
> URL: http://llvm.org/viewvc/llvm-project?rev=232221&view=rev
> Log:
> 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 :-)
Nice!
>
> Modified:
> llvm/trunk/include/llvm/IR/GVMaterializer.h
> llvm/trunk/include/llvm/IR/Module.h
> llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h
> llvm/trunk/lib/IR/Module.cpp
> llvm/trunk/lib/Object/IRObjectFile.cpp
> llvm/trunk/tools/gold/gold-plugin.cpp
>
> Modified: llvm/trunk/include/llvm/IR/GVMaterializer.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/GVMaterializer.h?rev=232221&r1=232220&r2=232221&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/IR/GVMaterializer.h (original)
> +++ llvm/trunk/include/llvm/IR/GVMaterializer.h Fri Mar 13 16:54:20 2015
> @@ -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;
> };
>
>
> Modified: llvm/trunk/include/llvm/IR/Module.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Module.h?rev=232221&r1=232220&r2=232221&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/IR/Module.h (original)
> +++ llvm/trunk/include/llvm/IR/Module.h Fri Mar 13 16:54:20 2015
> @@ -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
> /// @{
>
> Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h?rev=232221&r1=232220&r2=232221&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h (original)
> +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h Fri Mar 13 16:54:20 2015
> @@ -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;
>
> Modified: llvm/trunk/lib/IR/Module.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Module.cpp?rev=232221&r1=232220&r2=232221&view=diff
> ==============================================================================
> --- llvm/trunk/lib/IR/Module.cpp (original)
> +++ llvm/trunk/lib/IR/Module.cpp Fri Mar 13 16:54:20 2015
> @@ -413,6 +413,12 @@ std::error_code Module::materializeAllPe
> return std::error_code();
> }
>
> +std::error_code Module::materializeMetadata() {
> + if (!Materializer)
> + return std::error_code();
> + return Materializer->materializeMetadata();
> +}
> +
> //===----------------------------------------------------------------------===//
> // Other module related stuff.
> //
>
> Modified: llvm/trunk/lib/Object/IRObjectFile.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/IRObjectFile.cpp?rev=232221&r1=232220&r2=232221&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Object/IRObjectFile.cpp (original)
> +++ llvm/trunk/lib/Object/IRObjectFile.cpp Fri Mar 13 16:54:20 2015
> @@ -300,7 +300,9 @@ llvm::object::IRObjectFile::create(Memor
> 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;
>
>
> Modified: llvm/trunk/tools/gold/gold-plugin.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/gold/gold-plugin.cpp?rev=232221&r1=232220&r2=232221&view=diff
> ==============================================================================
> --- llvm/trunk/tools/gold/gold-plugin.cpp (original)
> +++ llvm/trunk/tools/gold/gold-plugin.cpp Fri Mar 13 16:54:20 2015
> @@ -598,6 +598,7 @@ getModuleForFile(LLVMContext &Context, c
>
> Module &M = Obj.getModule();
>
> + M.materializeMetadata();
> UpgradeDebugInfo(M);
>
> SmallPtrSet<GlobalValue *, 8> Used;
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list