aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2016-05-10 15:54:09 +0000
committerTeresa Johnson <tejohnson@google.com>2016-05-10 15:54:09 +0000
commit8570fe47ef2019911fca7bce9bbd912eedd0c34a (patch)
treee8f78fcf18c17c3ba9f6347532a4a884df422e67 /llvm/lib/LTO/ThinLTOCodeGenerator.cpp
parentc191acf09769666ee5472e52fc29a2b831e0645b (diff)
downloadllvm-8570fe47ef2019911fca7bce9bbd912eedd0c34a.zip
llvm-8570fe47ef2019911fca7bce9bbd912eedd0c34a.tar.gz
llvm-8570fe47ef2019911fca7bce9bbd912eedd0c34a.tar.bz2
[ThinLTO] Add option to emit imports files for distributed backends
Summary: Add support for emission of plaintext lists of the imported files for each distributed backend compilation. Used for distributed build file staging. Invoked with new gold-plugin thinlto-emit-imports-files option, which is only valid with thinlto-index-only (i.e. for distributed builds), or from llvm-lto with new -thinlto-action=emitimports value. Depends on D19556. Reviewers: joker.eph Subscribers: llvm-commits, joker.eph Differential Revision: http://reviews.llvm.org/D19636 llvm-svn: 269067
Diffstat (limited to 'llvm/lib/LTO/ThinLTOCodeGenerator.cpp')
-rw-r--r--llvm/lib/LTO/ThinLTOCodeGenerator.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
index 68d7a71..93a3f3e 100644
--- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
@@ -743,6 +743,30 @@ void ThinLTOCodeGenerator::gatherImportedSummariesForModule(
}
/**
+ * Emit the list of files needed for importing into module.
+ */
+void ThinLTOCodeGenerator::emitImports(StringRef ModulePath,
+ StringRef OutputName,
+ ModuleSummaryIndex &Index) {
+ auto ModuleCount = Index.modulePaths().size();
+
+ // Collect for each module the list of function it defines (GUID -> Summary).
+ StringMap<GVSummaryMapTy> ModuleToDefinedGVSummaries(ModuleCount);
+ Index.collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
+
+ // Generate import/export list
+ StringMap<FunctionImporter::ImportMapTy> ImportLists(ModuleCount);
+ StringMap<FunctionImporter::ExportSetTy> ExportLists(ModuleCount);
+ ComputeCrossModuleImport(Index, ModuleToDefinedGVSummaries, ImportLists,
+ ExportLists);
+
+ std::error_code EC;
+ if ((EC = EmitImportsFiles(ModulePath, OutputName, ImportLists)))
+ report_fatal_error(Twine("Failed to open ") + OutputName +
+ " to save imports lists\n");
+}
+
+/**
* Perform internalization.
*/
void ThinLTOCodeGenerator::internalize(Module &TheModule,