diff options
Diffstat (limited to 'llvm/lib/LTO/LTO.cpp')
-rw-r--r-- | llvm/lib/LTO/LTO.cpp | 36 |
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], |