Skip to content

Commit fec5490

Browse files
committed
Sync with llvm#127749
- Remove linker version. - Make AddBuffer a default parameter for LTO::run() to minimize changes at call sites. - Format code with clang-format, even if it deviates slightly from the surrounding style. I decided that CI passing for the PRs was more important than matching the existing style. - Order distributor command-line options correctly. - Remove dead code in llvm-lto2.cpp. - Add docstrings to Python distributors. - Update the Python mock.py distributor to validate JSON. - Organize LLVM DTLTO tests by moving them into a dedicated "dtlto" directory, tidying existing tests and adding new ones. - Implement fix for more than one LTO partition (spotted by MaskRay).
1 parent ea95125 commit fec5490

File tree

23 files changed

+488
-193
lines changed

23 files changed

+488
-193
lines changed

clang/lib/Driver/ToolChains/Gnu.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,8 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
547547
Twine(ToolChain.getDriver().getClangProgramPath())));
548548

549549
for (auto A : Args.getAllArgValues(options::OPT_Xthinlto_distributor_EQ))
550-
CmdArgs.push_back(Args.MakeArgString("-mllvm=-thinlto-distributor-arg=" + A));
550+
CmdArgs.push_back(
551+
Args.MakeArgString("-mllvm=-thinlto-distributor-arg=" + A));
551552
}
552553

553554
if (Args.hasArg(options::OPT_Z_Xlinker__no_demangle))

clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ Expected<SmallVector<StringRef>> getInput(const ArgList &Args) {
645645
std::make_unique<raw_fd_ostream>(FD, true));
646646
};
647647

648-
if (Error Err = LTOBackend.run(AddStream, /*AddBuffer=*/nullptr))
648+
if (Error Err = LTOBackend.run(AddStream))
649649
return Err;
650650

651651
if (Args.hasArg(OPT_lto_emit_llvm) || Args.hasArg(OPT_lto_emit_asm))

cross-project-tests/dtlto/dtlto-translate-options.ll

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
; RUN: opt -thinlto-bc x86_64-pc-windows-msvc.ll -o x86_64-pc-windows-msvc.bc
99

1010

11-
;; Check that any invalid arguments would cause a Clang error. This property is
12-
;; relied on by the actual testcases later in this test.
11+
;; Check that invalid arguments cause a Clang error. This property is relied on
12+
;; by the actual testcases later in this test.
1313
; RUN: not %clang -x ir x86_64-unknown-linux-gnu.ll \
1414
; RUN: -invalid-incorrect-not-an-option 2>&1 | FileCheck %s --check-prefix=SANITY1
1515
; SANITY1: unknown argument: '-invalid-incorrect-not-an-option'
@@ -25,7 +25,7 @@
2525
; DEFINE: @%{triple}.rsp %{extra_flags}
2626

2727

28-
;; Write common arguments to a response files.
28+
;; Write common arguments to response files.
2929

3030
; RUN: echo "x86_64-unknown-linux-gnu.bc -o x86_64-unknown-linux-gnu.o \
3131
; RUN: -dtlto \
@@ -63,7 +63,7 @@
6363
; RUN: %{command}
6464
; REDEFINE: %{distributor} = validate.py
6565
; RUN: not %{command} 2>&1 | FileCheck %s --check-prefix=ON \
66-
; RUN: --implicit-check-not=-no-pgo-warn-mismatch
66+
; RUN: --implicit-check-not=-no-pgo-warn-mismatch
6767
; ON-DAG: "-faddrsig"
6868
; ON-DAG: "-ffunction-sections"
6969
; ON-DAG: "-fdata-sections"
@@ -80,7 +80,7 @@
8080
; OFF-NOT: --implicit-check-not=-no-pgo-warn-mismatch
8181

8282

83-
;; Check optimisation level.
83+
;; Check optimization level.
8484

8585
; RUN: llvm-lto2 run \
8686
; RUN: -thinlto-distributor-arg=%llvm_src_root/utils/dtlto/local.py \
@@ -124,7 +124,6 @@
124124

125125

126126
;--- x86_64-unknown-linux-gnu.ll
127-
128127
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
129128
target triple = "x86_64-unknown-linux-gnu"
130129

@@ -134,7 +133,6 @@ entry:
134133
}
135134

136135
;--- x86_64-pc-windows-msvc.ll
137-
138136
target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
139137
target triple = "x86_64-pc-windows-msvc"
140138

lld/COFF/LTO.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,11 @@ BitcodeCompiler::BitcodeCompiler(COFFLinkerContext &c) : ctx(c) {
118118
// Initialize ltoObj.
119119
lto::ThinBackend backend;
120120
if (!ctx.config.dtltoDistributor.empty()) {
121-
StringRef version = getenv("LLD_VERSION"); // For testing only.
122-
if (version.empty())
123-
version = ctx.saver.save(getLLDVersion());
124121
backend = lto::createOutOfProcessThinBackend(
125122
llvm::heavyweight_hardware_concurrency(ctx.config.thinLTOJobs),
126123
/*OnWrite=*/nullptr,
127124
/*ShouldEmitIndexFiles=*/false,
128-
/*ShouldEmitImportFiles=*/false, ctx.config.outputFile, version,
125+
/*ShouldEmitImportFiles=*/false, ctx.config.outputFile,
129126
ctx.config.dtltoRemoteOptTool, ctx.config.dtltoDistributor,
130127
!ctx.config.saveTempsArgs.empty());
131128
} else if (ctx.config.thinLTOIndexOnly) {
@@ -210,7 +207,7 @@ std::vector<InputFile *> BitcodeCompiler::compile() {
210207
return std::make_unique<CachedFileStream>(
211208
std::make_unique<raw_svector_ostream>(buf[task].second));
212209
},
213-
AddBuffer, cache));
210+
cache, AddBuffer));
214211

215212
// Emit empty index files for non-indexed files
216213
for (StringRef s : thinIndices) {

lld/ELF/LTO.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,10 @@ BitcodeCompiler::BitcodeCompiler(Ctx &ctx) : ctx(ctx) {
188188
std::string(ctx.arg.thinLTOPrefixReplaceNativeObject),
189189
ctx.arg.thinLTOEmitImportsFiles, indexFile.get(), onIndexWrite);
190190
} else if (!ctx.arg.dtltoDistributor.empty() && !ctx.bitcodeFiles.empty()) {
191-
StringRef version = getenv("LLD_VERSION"); // For testing only.
192-
if (version.empty())
193-
version = ctx.saver.save(getLLDVersion());
194191
backend = lto::createOutOfProcessThinBackend(
195192
llvm::heavyweight_hardware_concurrency(ctx.arg.thinLTOJobs),
196193
onIndexWrite, ctx.arg.thinLTOEmitIndexFiles,
197-
ctx.arg.thinLTOEmitImportsFiles, ctx.arg.outputFile, version,
194+
ctx.arg.thinLTOEmitImportsFiles, ctx.arg.outputFile,
198195
ctx.arg.dtltoRemoteOptTool, ctx.arg.dtltoDistributor,
199196
!ctx.arg.saveTempsArgs.empty());
200197
} else {
@@ -347,7 +344,7 @@ SmallVector<std::unique_ptr<InputFile>, 0> BitcodeCompiler::compile() {
347344
std::make_unique<raw_svector_ostream>(
348345
buf[task].second));
349346
},
350-
AddBuffer, cache));
347+
cache, AddBuffer));
351348

352349
// Emit empty index files for non-indexed files but not in single-module mode.
353350
if (ctx.arg.thinLTOModulesToCompile.empty()) {

lld/ELF/Options.td

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
include "llvm/Option/OptParser.td"
32

43
// Convenience classes for long options which only accept two dashes. For lld

lld/MachO/LTO.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ std::vector<ObjFile *> BitcodeCompiler::compile() {
212212
return std::make_unique<CachedFileStream>(
213213
std::make_unique<raw_svector_ostream>(buf[task]));
214214
},
215-
AddBuffer, cache));
215+
cache, AddBuffer));
216216

217217
// Emit empty index files for non-indexed files
218218
for (StringRef s : thinIndices) {

lld/test/COFF/dtlto.test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
# NONE: distributor_args=[]
2727

2828
# OPT: "linker_output": "foo.exe"
29-
# OPT: "linker_version": "LLD 1.0"
3029
# BOTH: "my_clang.exe"
3130
# BOTH: "-O2"
3231
# OPT: "bobbity=20"

lld/test/ELF/dtlto/dtlto.test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
# NONE: distributor_args=[]
2727

2828
# OPT: "linker_output": "a.out"
29-
# OPT: "linker_version": "LLD 1.0"
3029
# BOTH: "my_clang.exe"
3130
# OPT: "-O3"
3231
# NONE: "-O2"

lld/wasm/LTO.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ std::vector<StringRef> BitcodeCompiler::compile() {
205205
return std::make_unique<CachedFileStream>(
206206
std::make_unique<raw_svector_ostream>(buf[task].second));
207207
},
208-
Addbuffer, cache));
208+
cache, Addbuffer));
209209

210210
// Emit empty index files for non-indexed files but not in single-module mode.
211211
for (StringRef s : thinIndices) {

0 commit comments

Comments
 (0)