[PATCH] D41267: [LTO] Write LTO output for empty RegularLTO.ModsWithSummaries
Vitaly Buka via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 14 17:45:30 PST 2017
vitalybuka updated this revision to Diff 127058.
vitalybuka added a comment.
comment
https://reviews.llvm.org/D41267
Files:
llvm/include/llvm/LTO/LTO.h
llvm/lib/LTO/LTO.cpp
llvm/test/ThinLTO/X86/Inputs/distributed_import.ll
Index: llvm/test/ThinLTO/X86/Inputs/distributed_import.ll
===================================================================
--- llvm/test/ThinLTO/X86/Inputs/distributed_import.ll
+++ llvm/test/ThinLTO/X86/Inputs/distributed_import.ll
@@ -1,3 +1,4 @@
+target triple = "x86_64-unknown-linux-gnu"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
@G = internal global i32 7
Index: llvm/lib/LTO/LTO.cpp
===================================================================
--- llvm/lib/LTO/LTO.cpp
+++ llvm/lib/LTO/LTO.cpp
@@ -469,6 +469,9 @@
if (Conf.ResolutionFile)
writeToResolutionFile(*Conf.ResolutionFile, Input.get(), Res);
+ if (RegularLTO.EmptyModuleTargetTriple.empty())
+ RegularLTO.EmptyModuleTargetTriple = Input->getTargetTriple();
+
const SymbolResolution *ResI = Res.begin();
for (unsigned I = 0; I != Input->Mods.size(); ++I)
if (Error Err = addModule(*Input, I, ResI, Res.end()))
@@ -737,7 +740,9 @@
unsigned LTO::getMaxTasks() const {
CalledGetMaxTasks = true;
- return RegularLTO.ParallelCodeGenParallelismLevel + ThinLTO.ModuleMap.size();
+ // Reserve one for empty module.
+ return 1 + RegularLTO.ParallelCodeGenParallelismLevel +
+ ThinLTO.ModuleMap.size();
}
Error LTO::run(AddStreamFn AddStream, NativeObjectCache Cache) {
@@ -760,9 +765,21 @@
bool HasRegularLTO = RegularLTO.CombinedModule != nullptr ||
!RegularLTO.ModsWithSummaries.empty();
// Invoke regular LTO if there was a regular LTO module to start with.
- if (HasRegularLTO)
+ if (HasRegularLTO) {
if (auto E = runRegularLTO(AddStream))
return E;
+ } else {
+ // Create empty output to have consistency and avoid workarounds on build
+ // system side for missing build rule output.
+ std::unique_ptr<Module> Mod =
+ make_unique<Module>("empty.o", RegularLTO.Ctx);
+ Mod->setTargetTriple(RegularLTO.EmptyModuleTargetTriple);
+ ModuleSummaryIndex EmptyIndex;
+ if (auto E =
+ backend(Conf, [&](size_t) { return AddStream(getMaxTasks() - 1); },
+ 1, std::move(Mod), EmptyIndex))
+ return E;
+ }
return runThinLTO(AddStream, Cache, HasRegularLTO);
}
Index: llvm/include/llvm/LTO/LTO.h
===================================================================
--- llvm/include/llvm/LTO/LTO.h
+++ llvm/include/llvm/LTO/LTO.h
@@ -292,6 +292,7 @@
std::vector<GlobalValue *> Keep;
};
std::vector<AddedModule> ModsWithSummaries;
+ std::string EmptyModuleTargetTriple;
} RegularLTO;
struct ThinLTOState {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41267.127058.patch
Type: text/x-patch
Size: 2570 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171215/fccbdf1a/attachment.bin>
More information about the llvm-commits
mailing list