[PATCH] D41267: [LTO] Write LTO output for empty RegularLTO.ModsWithSummaries
Peter Collingbourne via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 14 17:56:59 PST 2017
pcc added a comment.
I think this patch can be simplified with my suggestions below. Let me know if it works.
================
Comment at: llvm/include/llvm/LTO/LTO.h:283-284
bool HasModule = false;
std::unique_ptr<Module> CombinedModule;
std::unique_ptr<IRMover> Mover;
----------------
Change these to:
```
Module CombinedModule;
IRMover Mover;
```
and have them be initialized by the `RegularLTOState` constructor in the same way as `LTO::linkRegularLTO` is doing right now.
================
Comment at: llvm/include/llvm/LTO/LTO.h:295
std::vector<AddedModule> ModsWithSummaries;
+ std::string EmptyModuleTargetTriple;
} RegularLTO;
----------------
Remove this field.
================
Comment at: llvm/lib/LTO/LTO.cpp:472
+ if (RegularLTO.EmptyModuleTargetTriple.empty())
+ RegularLTO.EmptyModuleTargetTriple = Input->getTargetTriple();
----------------
Make this code use `RegularLTO.CombinedModule.{g,s}etTargetTriple()` instead.
================
Comment at: llvm/lib/LTO/LTO.cpp:662-667
if (!RegularLTO.CombinedModule) {
RegularLTO.CombinedModule =
llvm::make_unique<Module>("ld-temp.o", RegularLTO.Ctx);
RegularLTO.Mover = llvm::make_unique<IRMover>(*RegularLTO.CombinedModule);
}
----------------
Remove this code.
================
Comment at: llvm/lib/LTO/LTO.cpp:744
+ // Reserve one for empty module.
+ return 1 + RegularLTO.ParallelCodeGenParallelismLevel +
+ ThinLTO.ModuleMap.size();
----------------
I don't think you need to add 1 here. With my suggestions, module 0 will be the empty module.
================
Comment at: llvm/lib/LTO/LTO.cpp:768
// Invoke regular LTO if there was a regular LTO module to start with.
- if (HasRegularLTO)
+ if (HasRegularLTO) {
if (auto E = runRegularLTO(AddStream))
----------------
Remove this line.
================
Comment at: llvm/lib/LTO/LTO.cpp:771-782
+ } else {
+ // Create empty output to have consistency and avoid workarounds workaround
+ // 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;
----------------
Remove all of this.
https://reviews.llvm.org/D41267
More information about the llvm-commits
mailing list