diff options
author | Florian Hahn <flo@fhahn.com> | 2021-01-29 10:20:54 +0000 |
---|---|---|
committer | Florian Hahn <flo@fhahn.com> | 2021-01-29 11:53:11 +0000 |
commit | f3a710cade9381030f3e1e9778c5fc12f8a02fdf (patch) | |
tree | 1e311dad76e7a14fdd60a016d3267106ed4ddcd6 /llvm/lib/LTO/LTOBackend.cpp | |
parent | 64ced3ce89a6dd429136d0ad7832853d8b3fdef0 (diff) | |
download | llvm-f3a710cade9381030f3e1e9778c5fc12f8a02fdf.zip llvm-f3a710cade9381030f3e1e9778c5fc12f8a02fdf.tar.gz llvm-f3a710cade9381030f3e1e9778c5fc12f8a02fdf.tar.bz2 |
[LTO] Update splitCodeGen to take a reference to the module. (NFC)
splitCodeGen does not need to take ownership of the module, as it
currently clones the original module for each split operation.
There is an ~4 year old fixme to change that, but until this is
addressed, the function can just take a reference to the module.
This makes the transition of LTOCodeGenerator to use LTOBackend a bit
easier, because under some circumstances, LTOCodeGenerator needs to
write the original module back after codegen.
Reviewed By: tejohnson
Differential Revision: https://reviews.llvm.org/D95222
Diffstat (limited to 'llvm/lib/LTO/LTOBackend.cpp')
-rw-r--r-- | llvm/lib/LTO/LTOBackend.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp index 1796d6b..3839cc1 100644 --- a/llvm/lib/LTO/LTOBackend.cpp +++ b/llvm/lib/LTO/LTOBackend.cpp @@ -456,8 +456,7 @@ static void codegen(const Config &Conf, TargetMachine *TM, static void splitCodeGen(const Config &C, TargetMachine *TM, AddStreamFn AddStream, - unsigned ParallelCodeGenParallelismLevel, - std::unique_ptr<Module> Mod, + unsigned ParallelCodeGenParallelismLevel, Module &Mod, const ModuleSummaryIndex &CombinedIndex) { ThreadPool CodegenThreadPool( heavyweight_hardware_concurrency(ParallelCodeGenParallelismLevel)); @@ -465,7 +464,7 @@ static void splitCodeGen(const Config &C, TargetMachine *TM, const Target *T = &TM->getTarget(); SplitModule( - std::move(Mod), ParallelCodeGenParallelismLevel, + Mod, ParallelCodeGenParallelismLevel, [&](std::unique_ptr<Module> MPart) { // We want to clone the module in a new context to multi-thread the // codegen. We do it by serializing partition modules to bitcode @@ -532,27 +531,26 @@ Error lto::finalizeOptimizationRemarks( } Error lto::backend(const Config &C, AddStreamFn AddStream, - unsigned ParallelCodeGenParallelismLevel, - std::unique_ptr<Module> Mod, + unsigned ParallelCodeGenParallelismLevel, Module &Mod, ModuleSummaryIndex &CombinedIndex) { - Expected<const Target *> TOrErr = initAndLookupTarget(C, *Mod); + Expected<const Target *> TOrErr = initAndLookupTarget(C, Mod); if (!TOrErr) return TOrErr.takeError(); - std::unique_ptr<TargetMachine> TM = createTargetMachine(C, *TOrErr, *Mod); + std::unique_ptr<TargetMachine> TM = createTargetMachine(C, *TOrErr, Mod); if (!C.CodeGenOnly) { - if (!opt(C, TM.get(), 0, *Mod, /*IsThinLTO=*/false, + if (!opt(C, TM.get(), 0, Mod, /*IsThinLTO=*/false, /*ExportSummary=*/&CombinedIndex, /*ImportSummary=*/nullptr, /*CmdArgs*/ std::vector<uint8_t>())) return Error::success(); } if (ParallelCodeGenParallelismLevel == 1) { - codegen(C, TM.get(), AddStream, 0, *Mod, CombinedIndex); + codegen(C, TM.get(), AddStream, 0, Mod, CombinedIndex); } else { - splitCodeGen(C, TM.get(), AddStream, ParallelCodeGenParallelismLevel, - std::move(Mod), CombinedIndex); + splitCodeGen(C, TM.get(), AddStream, ParallelCodeGenParallelismLevel, Mod, + CombinedIndex); } return Error::success(); } |