Skip to content

Commit 57bd7c7

Browse files
committed
[DTLTO] Code refactor - addressed Teresa review comments. #2
1 parent 4469fc4 commit 57bd7c7

5 files changed

Lines changed: 17 additions & 19 deletions

File tree

lld/COFF/LTO.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ BitcodeCompiler::BitcodeCompiler(COFFLinkerContext &c) : ctx(c) {
126126

127127
// Initialize ltoObj.
128128
lto::ThinBackend backend;
129-
if (ctx.config.thinLTOIndexOnly || !ctx.config.dtltoDistributor.empty()) {
129+
if (ctx.config.thinLTOIndexOnly) {
130130
auto OnIndexWrite = [&](StringRef S) { thinIndices.erase(S); };
131131
backend = lto::createWriteIndexesThinBackend(
132132
llvm::hardware_concurrency(ctx.config.thinLTOJobs),
@@ -144,7 +144,7 @@ BitcodeCompiler::BitcodeCompiler(COFFLinkerContext &c) : ctx(c) {
144144
ctx.config.ltoPartitions);
145145
else
146146
ltoObj = std::make_unique<lto::DTLTO>(
147-
createConfig(), backend, ctx.config.ltoPartitions,
147+
createConfig(), ctx.config.ltoPartitions,
148148
llvm::lto::LTO::LTOKind::LTOK_Default, nullptr,
149149
ctx.config.thinLTOEmitImportsFiles, ctx.config.thinLTOIndexOnly,
150150
ctx.config.outputFile, ctx.config.dtltoDistributor,

lld/ELF/LTO.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ BitcodeCompiler::BitcodeCompiler(Ctx &ctx) : ctx(ctx) {
184184
// Initialize ltoObj.
185185
lto::ThinBackend backend;
186186
auto onIndexWrite = [&](StringRef s) { thinIndices.erase(s); };
187-
if (ctx.arg.thinLTOIndexOnly || !ctx.arg.dtltoDistributor.empty()) {
187+
if (ctx.arg.thinLTOIndexOnly) {
188188
backend = lto::createWriteIndexesThinBackend(
189189
llvm::hardware_concurrency(ctx.arg.thinLTOJobs),
190190
std::string(ctx.arg.thinLTOPrefixReplaceOld),
@@ -209,8 +209,8 @@ BitcodeCompiler::BitcodeCompiler(Ctx &ctx) : ctx(ctx) {
209209
ltoModes[ctx.arg.ltoKind]);
210210
else
211211
ltoObj = std::make_unique<lto::DTLTO>(
212-
createConfig(ctx), backend, ctx.arg.ltoPartitions,
213-
ltoModes[ctx.arg.ltoKind], onIndexWrite, ctx.arg.thinLTOEmitIndexFiles,
212+
createConfig(ctx), ctx.arg.ltoPartitions, ltoModes[ctx.arg.ltoKind],
213+
onIndexWrite, ctx.arg.thinLTOEmitIndexFiles,
214214
ctx.arg.thinLTOEmitImportsFiles, ctx.arg.outputFile,
215215
ctx.arg.dtltoDistributor, ctx.arg.dtltoDistributorArgs,
216216
ctx.arg.dtltoCompiler, ctx.arg.dtltoCompilerPrependArgs,

llvm/include/llvm/DTLTO/DTLTO.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,15 @@ class DTLTO : public LTO {
4747
using Base = LTO;
4848

4949
public:
50-
LLVM_ABI DTLTO(Config Conf, ThinBackend Backend,
51-
unsigned ParallelCodeGenParallelismLevel, LTOKind LTOMode,
52-
IndexWriteCallback OnWrite, bool EmitIndexFiles,
53-
bool EmitImportsFiles, StringRef LinkerOutputFile,
54-
StringRef Distributor, ArrayRef<StringRef> DistributorArgs,
55-
StringRef RemoteCompiler,
50+
LLVM_ABI DTLTO(Config Conf, unsigned ParallelCodeGenParallelismLevel,
51+
LTOKind LTOMode, IndexWriteCallback OnWrite,
52+
bool EmitIndexFiles, bool EmitImportsFiles,
53+
StringRef LinkerOutputFile, StringRef Distributor,
54+
ArrayRef<StringRef> DistributorArgs, StringRef RemoteCompiler,
5655
ArrayRef<StringRef> RemoteCompilerPrependArgs,
5756
ArrayRef<StringRef> RemoteCompilerArgs,
5857
AddBufferFn AddBufferArg, bool SaveTempsArg)
59-
: Base(std::move(Conf), Backend, ParallelCodeGenParallelismLevel,
60-
LTOMode),
58+
: Base(std::move(Conf), {}, ParallelCodeGenParallelismLevel, LTOMode),
6159
AddBuffer(AddBufferArg), SaveTemps(SaveTempsArg),
6260
ShouldEmitIndexFiles(EmitIndexFiles),
6361
ShouldEmitImportFiles(EmitImportsFiles), OnWriteCb(OnWrite),

llvm/lib/LTO/LTO.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1299,7 +1299,7 @@ Error LTO::checkPartiallySplit() {
12991299
}
13001300

13011301
Error LTO::run(AddStreamFn AddStream, FileCache Cache) {
1302-
llvm::scope_exit CleanUp([this]() { cleanup(); });
1302+
llvm::scope_exit CleanUp([this]() { LTO::cleanup(); });
13031303

13041304
// Compute "dead" symbols, we don't want to import/export these!
13051305
DenseSet<GlobalValue::GUID> GUIDPreservedSymbols;

llvm/tools/llvm-lto2/llvm-lto2.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ static int run(int argc, char **argv) {
444444
};
445445

446446
ThinBackend Backend;
447-
if (ThinLTODistributedIndexes || !DTLTODistributor.empty())
447+
if (ThinLTODistributedIndexes)
448448
Backend = createWriteIndexesThinBackend(llvm::hardware_concurrency(Threads),
449449
/*OldPrefix=*/"",
450450
/*NewPrefix=*/"",
@@ -478,10 +478,10 @@ static int run(int argc, char **argv) {
478478
std::unique_ptr<LTO> Lto;
479479
if (!DTLTODistributor.empty()) {
480480
Lto = std::make_unique<DTLTO>(
481-
std::move(Conf), std::move(Backend), 1, LTOMode, nullptr,
482-
ThinLTOEmitIndexes, ThinLTOEmitImports, OutputFilename,
483-
DTLTODistributor, DTLTODistributorArgsSV, DTLTOCompiler,
484-
DTLTOCompilerPrependArgsSV, DTLTOCompilerArgsSV, AddBuffer, SaveTemps);
481+
std::move(Conf), 1, LTOMode, nullptr, ThinLTOEmitIndexes,
482+
ThinLTOEmitImports, OutputFilename, DTLTODistributor,
483+
DTLTODistributorArgsSV, DTLTOCompiler, DTLTOCompilerPrependArgsSV,
484+
DTLTOCompilerArgsSV, AddBuffer, SaveTemps);
485485
} else {
486486
Lto =
487487
std::make_unique<LTO>(std::move(Conf), std::move(Backend), 1, LTOMode);

0 commit comments

Comments
 (0)