diff options
author | Teresa Johnson <tejohnson@google.com> | 2016-12-16 21:25:01 +0000 |
---|---|---|
committer | Teresa Johnson <tejohnson@google.com> | 2016-12-16 21:25:01 +0000 |
commit | a61f5e379675732666744bcba25efbc9922e016a (patch) | |
tree | e9fca58ec6916e678a6fc2d90bb2b00c3846c0e5 /llvm/lib/LTO/ThinLTOCodeGenerator.cpp | |
parent | 3ca147ea3d8c2364542c2e4c2b7ba83fdf5e6dcd (diff) | |
download | bcm5719-llvm-a61f5e379675732666744bcba25efbc9922e016a.tar.gz bcm5719-llvm-a61f5e379675732666744bcba25efbc9922e016a.zip |
[ThinLTO] Import composite types as declarations
Summary:
When reading the metadata bitcode, create a type declaration when
possible for composite types when we are importing. Doing this in
the bitcode reader saves memory. Also it works naturally in the case
when the type ODR map contains a definition for the same composite type
because it was used in the importing module (buildODRType will
automatically use the existing definition and not create a type
declaration).
For Chromium built with -g2, this reduces the aggregate size of the
generated native object files by 66% (from 31G to 10G). It reduced
the time through the ThinLTO link and backend phases by about 20% on
my machine.
Reviewers: mehdi_amini, dblaikie, aprantl
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D27775
llvm-svn: 289993
Diffstat (limited to 'llvm/lib/LTO/ThinLTOCodeGenerator.cpp')
-rw-r--r-- | llvm/lib/LTO/ThinLTOCodeGenerator.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp index 950930176c0..2791efc69cd 100644 --- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp +++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp @@ -168,12 +168,13 @@ static void promoteModule(Module &TheModule, const ModuleSummaryIndex &Index) { static std::unique_ptr<Module> loadModuleFromBuffer(const MemoryBufferRef &Buffer, LLVMContext &Context, - bool Lazy) { + bool Lazy, bool IsImporting) { SMDiagnostic Err; Expected<std::unique_ptr<Module>> ModuleOrErr = - Lazy ? getLazyBitcodeModule(Buffer, Context, - /* ShouldLazyLoadMetadata */ true) - : parseBitcodeFile(Buffer, Context); + Lazy + ? getLazyBitcodeModule(Buffer, Context, + /* ShouldLazyLoadMetadata */ true, IsImporting) + : parseBitcodeFile(Buffer, Context); if (!ModuleOrErr) { handleAllErrors(ModuleOrErr.takeError(), [&](ErrorInfoBase &EIB) { SMDiagnostic Err = SMDiagnostic(Buffer.getBufferIdentifier(), @@ -191,7 +192,7 @@ crossImportIntoModule(Module &TheModule, const ModuleSummaryIndex &Index, const FunctionImporter::ImportMapTy &ImportList) { auto Loader = [&](StringRef Identifier) { return loadModuleFromBuffer(ModuleMap[Identifier], TheModule.getContext(), - /*Lazy=*/true); + /*Lazy=*/true, /*IsImporting*/ true); }; FunctionImporter Importer(Index, Loader); @@ -787,7 +788,8 @@ void ThinLTOCodeGenerator::run() { Context.setDiscardValueNames(LTODiscardValueNames); // Parse module now - auto TheModule = loadModuleFromBuffer(ModuleBuffer, Context, false); + auto TheModule = loadModuleFromBuffer(ModuleBuffer, Context, false, + /*IsImporting*/ false); // CodeGen ProducedBinaries[count] = codegen(*TheModule); @@ -933,7 +935,8 @@ void ThinLTOCodeGenerator::run() { } // Parse module now - auto TheModule = loadModuleFromBuffer(ModuleBuffer, Context, false); + auto TheModule = loadModuleFromBuffer(ModuleBuffer, Context, false, + /*IsImporting*/ false); // Save temps: original file. saveTempBitcode(*TheModule, SaveTempsDir, count, ".0.original.bc"); |