summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorVitaly Buka <vitalybuka@google.com>2017-12-16 02:10:00 +0000
committerVitaly Buka <vitalybuka@google.com>2017-12-16 02:10:00 +0000
commita5376f393e128929280d8052b01dbfc4d93e0960 (patch)
tree42329494180ef8cb0a659c319211a4cd920ade97 /llvm/lib
parentcc15219fb1eb7d536fb40ffed7e4a6a779eb23ff (diff)
downloadbcm5719-llvm-a5376f393e128929280d8052b01dbfc4d93e0960.tar.gz
bcm5719-llvm-a5376f393e128929280d8052b01dbfc4d93e0960.zip
[LTO] Make processing of combined module more consistent
Summary: 1. Use stream 0 only for combined module. Previously if combined module was not processes ThinLTO used the stream for own output. However small changes in input, could trigger combined module and shuffle outputs making life of llvm::LTO harder. 2. Always process combined module and write output to stream 0. Processing empty combined module is cheap and allows llvm::LTO users to avoid implementing processing which is already done in llvm::LTO. Subscribers: mehdi_amini, inglorion, eraman, hiraditya Differential Revision: https://reviews.llvm.org/D41267 llvm-svn: 320905
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/LTO/LTO.cpp36
1 files changed, 12 insertions, 24 deletions
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp
index 69a696793a6..64e5186255b 100644
--- a/llvm/lib/LTO/LTO.cpp
+++ b/llvm/lib/LTO/LTO.cpp
@@ -385,7 +385,8 @@ StringRef InputFile::getName() const {
LTO::RegularLTOState::RegularLTOState(unsigned ParallelCodeGenParallelismLevel,
Config &Conf)
: ParallelCodeGenParallelismLevel(ParallelCodeGenParallelismLevel),
- Ctx(Conf) {}
+ Ctx(Conf), CombinedModule(llvm::make_unique<Module>("ld-temp.o", Ctx)),
+ Mover(llvm::make_unique<IRMover>(*CombinedModule)) {}
LTO::ThinLTOState::ThinLTOState(ThinBackend Backend) : Backend(Backend) {
if (!Backend)
@@ -472,6 +473,9 @@ Error LTO::add(std::unique_ptr<InputFile> Input,
if (Conf.ResolutionFile)
writeToResolutionFile(*Conf.ResolutionFile, Input.get(), Res);
+ if (RegularLTO.CombinedModule->getTargetTriple().empty())
+ RegularLTO.CombinedModule->setTargetTriple(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()))
@@ -659,12 +663,6 @@ LTO::addRegularLTO(BitcodeModule BM, ArrayRef<InputFile::Symbol> Syms,
Error LTO::linkRegularLTO(RegularLTOState::AddedModule Mod,
bool LivenessFromIndex) {
- if (!RegularLTO.CombinedModule) {
- RegularLTO.CombinedModule =
- llvm::make_unique<Module>("ld-temp.o", RegularLTO.Ctx);
- RegularLTO.Mover = llvm::make_unique<IRMover>(*RegularLTO.CombinedModule);
- }
-
std::vector<GlobalValue *> Keep;
for (GlobalValue *GV : Mod.Keep) {
if (LivenessFromIndex && !ThinLTO.CombinedIndex.isGUIDLive(GV->getGUID()))
@@ -757,16 +755,9 @@ Error LTO::run(AddStreamFn AddStream, NativeObjectCache Cache) {
computeDeadSymbols(ThinLTO.CombinedIndex, GUIDPreservedSymbols);
- // Save the status of having a regularLTO combined module, as
- // this is needed for generating the ThinLTO Task ID, and
- // the CombinedModule will be moved at the end of runRegularLTO.
- bool HasRegularLTO = RegularLTO.CombinedModule != nullptr ||
- !RegularLTO.ModsWithSummaries.empty();
- // Invoke regular LTO if there was a regular LTO module to start with.
- if (HasRegularLTO)
- if (auto E = runRegularLTO(AddStream))
- return E;
- return runThinLTO(AddStream, Cache, HasRegularLTO);
+ if (auto E = runRegularLTO(AddStream))
+ return E;
+ return runThinLTO(AddStream, Cache);
}
Error LTO::runRegularLTO(AddStreamFn AddStream) {
@@ -1081,8 +1072,7 @@ ThinBackend lto::createWriteIndexesThinBackend(std::string OldPrefix,
};
}
-Error LTO::runThinLTO(AddStreamFn AddStream, NativeObjectCache Cache,
- bool HasRegularLTO) {
+Error LTO::runThinLTO(AddStreamFn AddStream, NativeObjectCache Cache) {
if (ThinLTO.ModuleMap.empty())
return Error::success();
@@ -1167,11 +1157,9 @@ Error LTO::runThinLTO(AddStreamFn AddStream, NativeObjectCache Cache,
ThinLTO.Backend(Conf, ThinLTO.CombinedIndex, ModuleToDefinedGVSummaries,
AddStream, Cache);
- // Task numbers start at ParallelCodeGenParallelismLevel if an LTO
- // module is present, as tasks 0 through ParallelCodeGenParallelismLevel-1
- // are reserved for parallel code generation partitions.
- unsigned Task =
- HasRegularLTO ? RegularLTO.ParallelCodeGenParallelismLevel : 0;
+ // Tasks 0 through ParallelCodeGenParallelismLevel-1 are reserved for combined
+ // module and parallel code generation partitions.
+ unsigned Task = RegularLTO.ParallelCodeGenParallelismLevel;
for (auto &Mod : ThinLTO.ModuleMap) {
if (Error E = BackendProc->start(Task, Mod.second, ImportLists[Mod.first],
ExportLists[Mod.first],
OpenPOWER on IntegriCloud