Skip to content

Commit e2c2815

Browse files
author
z1_cciauto
authored
merge main into amd-staging (llvm#4346)
2 parents d2cf908 + 45e7fc4 commit e2c2815

File tree

89 files changed

+3788
-1535
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+3788
-1535
lines changed

.github/workflows/libcxx-build-and-test.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,10 @@ jobs:
281281
- name: Set up the MSVC dev environment
282282
if: ${{ matrix.mingw != true }}
283283
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
284+
- name: Add the installed Clang at the start of the path
285+
if: ${{ matrix.mingw != true }}
286+
run: |
287+
echo "c:\Program Files\LLVM\bin" | Out-File -FilePath $Env:GITHUB_PATH -Encoding utf8 -Append
284288
- name: Build and test
285289
run: |
286290
bash libcxx/utils/ci/run-buildbot ${{ matrix.config }}

clang/include/clang/Driver/Options.td

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,8 +1263,9 @@ def offload_compression_level_EQ : Joined<["--"], "offload-compression-level=">,
12631263
HelpText<"Compression level for offload device binaries (HIP only)">;
12641264

12651265
def offload_jobs_EQ : Joined<["--"], "offload-jobs=">,
1266-
HelpText<"Specify the number of threads to use for device offloading tasks"
1267-
" during compilation.">;
1266+
HelpText<"Specify the number of threads to use for device offloading tasks "
1267+
"during compilation. Can be a positive integer or the string "
1268+
"'jobserver' to use the make-style jobserver from the environment.">;
12681269

12691270
defm offload_via_llvm : BoolFOption<"offload-via-llvm",
12701271
LangOpts<"OffloadViaLLVM">, DefaultFalse,

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9445,14 +9445,20 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
94459445
addOffloadCompressArgs(Args, CmdArgs);
94469446

94479447
if (Arg *A = Args.getLastArg(options::OPT_offload_jobs_EQ)) {
9448-
int NumThreads;
9449-
if (StringRef(A->getValue()).getAsInteger(10, NumThreads) ||
9450-
NumThreads <= 0)
9451-
C.getDriver().Diag(diag::err_drv_invalid_int_value)
9452-
<< A->getAsString(Args) << A->getValue();
9453-
else
9454-
CmdArgs.push_back(
9455-
Args.MakeArgString("--wrapper-jobs=" + Twine(NumThreads)));
9448+
StringRef Val = A->getValue();
9449+
9450+
if (Val.equals_insensitive("jobserver"))
9451+
CmdArgs.push_back(Args.MakeArgString("--wrapper-jobs=jobserver"));
9452+
else {
9453+
int NumThreads;
9454+
if (Val.getAsInteger(10, NumThreads) || NumThreads <= 0) {
9455+
C.getDriver().Diag(diag::err_drv_invalid_int_value)
9456+
<< A->getAsString(Args) << Val;
9457+
} else {
9458+
CmdArgs.push_back(
9459+
Args.MakeArgString("--wrapper-jobs=" + Twine(NumThreads)));
9460+
}
9461+
}
94569462
}
94579463

94589464
const char *Exec =

clang/lib/Format/Format.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3199,7 +3199,7 @@ class ObjCHeaderStyleGuesser : public TokenAnalyzer {
31993199
Keywords.kw_NS_OPTIONS, TT_ObjCBlockLBrace,
32003200
TT_ObjCBlockLParen, TT_ObjCDecl, TT_ObjCForIn,
32013201
TT_ObjCMethodExpr, TT_ObjCMethodSpecifier,
3202-
TT_ObjCProperty)) {
3202+
TT_ObjCProperty, TT_ObjCSelector)) {
32033203
LLVM_DEBUG(llvm::dbgs()
32043204
<< "Detected ObjC at location "
32053205
<< FormatTok->Tok.getLocation().printToString(

clang/lib/Format/FormatToken.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,17 @@ namespace format {
127127
TYPE(ObjCBlockLParen) \
128128
TYPE(ObjCDecl) \
129129
TYPE(ObjCForIn) \
130+
/* The square brackets surrounding a method call, the colon separating the \
131+
* method or parameter name and the argument inside the square brackets, and \
132+
* the colon separating the method or parameter name and the type inside the \
133+
* method declaration. */ \
130134
TYPE(ObjCMethodExpr) \
135+
/* The '+' or '-' at the start of the line. */ \
131136
TYPE(ObjCMethodSpecifier) \
132137
TYPE(ObjCProperty) \
138+
/* The parentheses following '@selector' and the colon following the method \
139+
* or parameter name inside the parentheses. */ \
140+
TYPE(ObjCSelector) \
133141
TYPE(ObjCStringLiteral) \
134142
TYPE(OverloadedOperator) \
135143
TYPE(OverloadedOperatorLParen) \
@@ -146,6 +154,9 @@ namespace format {
146154
TYPE(RequiresExpression) \
147155
TYPE(RequiresExpressionLBrace) \
148156
TYPE(RequiresExpressionLParen) \
157+
/* The hash key in languages that have hash literals, not including the \
158+
* field name in the C++ struct literal. Also the method or parameter name \
159+
* in the Objective-C method declaration or call. */ \
149160
TYPE(SelectorName) \
150161
TYPE(StartOfName) \
151162
TYPE(StatementAttributeLikeMacro) \

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -321,13 +321,13 @@ class AnnotatingParser {
321321
return parseUntouchableParens();
322322
}
323323

324-
bool StartsObjCMethodExpr = false;
324+
bool StartsObjCSelector = false;
325325
if (!Style.isVerilog()) {
326326
if (FormatToken *MaybeSel = OpeningParen.Previous) {
327327
// @selector( starts a selector.
328328
if (MaybeSel->is(tok::objc_selector) && MaybeSel->Previous &&
329329
MaybeSel->Previous->is(tok::at)) {
330-
StartsObjCMethodExpr = true;
330+
StartsObjCSelector = true;
331331
}
332332
}
333333
}
@@ -451,10 +451,8 @@ class AnnotatingParser {
451451
}
452452
}
453453

454-
if (StartsObjCMethodExpr) {
455-
Contexts.back().ColonIsObjCMethodExpr = true;
456-
OpeningParen.setType(TT_ObjCMethodExpr);
457-
}
454+
if (StartsObjCSelector)
455+
OpeningParen.setType(TT_ObjCSelector);
458456

459457
// MightBeFunctionType and ProbablyFunctionType are used for
460458
// function pointer and reference types as well as Objective-C
@@ -513,8 +511,8 @@ class AnnotatingParser {
513511
}
514512
}
515513

516-
if (StartsObjCMethodExpr) {
517-
CurrentToken->setType(TT_ObjCMethodExpr);
514+
if (StartsObjCSelector) {
515+
CurrentToken->setType(TT_ObjCSelector);
518516
if (Contexts.back().FirstObjCSelectorName) {
519517
Contexts.back().FirstObjCSelectorName->LongestObjCSelectorName =
520518
Contexts.back().LongestObjCSelectorName;
@@ -1449,7 +1447,7 @@ class AnnotatingParser {
14491447
Next->Next->is(tok::colon)))) {
14501448
// This handles a special macro in ObjC code where selectors including
14511449
// the colon are passed as macro arguments.
1452-
Tok->setType(TT_ObjCMethodExpr);
1450+
Tok->setType(TT_ObjCSelector);
14531451
}
14541452
break;
14551453
case tok::pipe:
@@ -4608,7 +4606,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
46084606
return false;
46094607
}
46104608
if (Left.is(tok::colon))
4611-
return Left.isNot(TT_ObjCMethodExpr);
4609+
return Left.isNoneOf(TT_ObjCSelector, TT_ObjCMethodExpr);
46124610
if (Left.is(tok::coloncolon))
46134611
return false;
46144612
if (Left.is(tok::less) || Right.isOneOf(tok::greater, tok::less)) {
@@ -5464,7 +5462,7 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
54645462
// `private:` and `public:`.
54655463
if (!Right.getNextNonComment())
54665464
return false;
5467-
if (Right.is(TT_ObjCMethodExpr))
5465+
if (Right.isOneOf(TT_ObjCSelector, TT_ObjCMethodExpr))
54685466
return false;
54695467
if (Left.is(tok::question))
54705468
return false;
@@ -6288,6 +6286,7 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
62886286
return Style.BreakInheritanceList == FormatStyle::BILS_AfterColon;
62896287
if (Right.is(TT_InheritanceColon))
62906288
return Style.BreakInheritanceList != FormatStyle::BILS_AfterColon;
6289+
// When the method parameter has no name, allow breaking before the colon.
62916290
if (Right.is(TT_ObjCMethodExpr) && Right.isNot(tok::r_square) &&
62926291
Left.isNot(TT_SelectorName)) {
62936292
return true;

clang/test/Driver/hip-options.hip

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,3 +254,9 @@
254254
// RUN: --offload-arch=gfx1100 --offload-new-driver --offload-jobs=0x4 %s 2>&1 | \
255255
// RUN: FileCheck -check-prefix=INVJOBS %s
256256
// INVJOBS: clang: error: invalid integral value '0x4' in '--offload-jobs=0x4'
257+
258+
// RUN: %clang -### -Werror --target=x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
259+
// RUN: --offload-arch=gfx1100 --offload-new-driver --offload-jobs=jobserver %s 2>&1 | \
260+
// RUN: FileCheck -check-prefix=JOBSV %s
261+
// JOBSV: clang-linker-wrapper{{.*}} "--wrapper-jobs=jobserver"
262+

clang/test/Driver/linker-wrapper.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ __attribute__((visibility("protected"), used)) int x;
114114
// RUN: -fembed-offload-object=%t.out
115115
// RUN: clang-linker-wrapper --dry-run --host-triple=x86_64-unknown-linux-gnu --wrapper-jobs=4 \
116116
// RUN: --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=CUDA-PAR
117+
// RUN: clang-linker-wrapper --dry-run --host-triple=x86_64-unknown-linux-gnu --wrapper-jobs=jobserver \
118+
// RUN: --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=CUDA-PAR
117119

118120
// CUDA-PAR: fatbinary{{.*}}-64 --create {{.*}}.fatbin
119121

clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,12 +1312,18 @@ int main(int Argc, char **Argv) {
13121312

13131313
parallel::strategy = hardware_concurrency(1);
13141314
if (auto *Arg = Args.getLastArg(OPT_wrapper_jobs)) {
1315-
unsigned Threads = 0;
1316-
if (!llvm::to_integer(Arg->getValue(), Threads) || Threads == 0)
1317-
reportError(createStringError("%s: expected a positive integer, got '%s'",
1318-
Arg->getSpelling().data(),
1319-
Arg->getValue()));
1320-
parallel::strategy = hardware_concurrency(Threads);
1315+
StringRef Val = Arg->getValue();
1316+
if (Val.equals_insensitive("jobserver"))
1317+
parallel::strategy = jobserver_concurrency();
1318+
else {
1319+
unsigned Threads = 0;
1320+
if (!llvm::to_integer(Val, Threads) || Threads == 0)
1321+
reportError(createStringError(
1322+
"%s: expected a positive integer or 'jobserver', got '%s'",
1323+
Arg->getSpelling().data(), Val.data()));
1324+
else
1325+
parallel::strategy = hardware_concurrency(Threads);
1326+
}
13211327
}
13221328

13231329
if (Args.hasArg(OPT_wrapper_time_trace_eq)) {

clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ def wrapper_time_trace_granularity : Joined<["--"], "wrapper-time-trace-granular
5353

5454
def wrapper_jobs : Joined<["--"], "wrapper-jobs=">,
5555
Flags<[WrapperOnlyOption]>, MetaVarName<"<number>">,
56-
HelpText<"Sets the number of parallel jobs to use for device linking">;
56+
HelpText<"Sets the number of parallel jobs for device linking. Can be a "
57+
"positive integer or 'jobserver'.">;
5758

5859
def override_image : Joined<["--"], "override-image=">,
5960
Flags<[WrapperOnlyOption]>, MetaVarName<"<kind=file>">,

0 commit comments

Comments
 (0)