Skip to content

Commit 945f8d4

Browse files
authored
Merge branch 'release/21.x' into issue146308
2 parents cee508a + 52dfd4a commit 945f8d4

File tree

152 files changed

+4559
-1042
lines changed

Some content is hidden

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

152 files changed

+4559
-1042
lines changed

clang/docs/ClangFormatStyleOptions.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6390,6 +6390,14 @@ the configuration (without a prefix: ``Auto``).
63906390
IF (...) vs. IF(...)
63916391
<conditional-body> <conditional-body>
63926392

6393+
* ``bool AfterNot`` If ``true``, put a space between alternative operator ``not`` and the
6394+
opening parenthesis.
6395+
6396+
.. code-block:: c++
6397+
6398+
true: false:
6399+
return not (a || b); vs. return not(a || b);
6400+
63936401
* ``bool AfterOverloadedOperator`` If ``true``, put a space between operator overloading and opening
63946402
parentheses.
63956403

clang/docs/ReleaseNotes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,8 @@ New Compiler Flags
376376

377377
- New options ``-g[no-]key-instructions`` added, disabled by default. Reduces jumpiness of debug stepping for optimized code in some debuggers (not LLDB at this time). Not recommended for use without optimizations. DWARF only. Note both the positive and negative flags imply ``-g``.
378378

379+
- New options ``-fthinlto-distributor=`` and ``-Xthinlto-distributor=`` added for Integrated Distributed ThinLTO (DTLTO). DTLTO enables the distribution of backend ThinLTO compilations via external distribution systems, such as Incredibuild, during the traditional link step. (#GH147265, `ThinLTODocs <https://clang.llvm.org/docs/ThinLTO.html#integrated-distributed-thinlto-dtlto>`_).
380+
379381
Deprecated Compiler Flags
380382
-------------------------
381383

@@ -800,6 +802,8 @@ Bug Fixes in This Version
800802
declaration statements. Clang now emits a warning for these patterns. (#GH141659)
801803
- Fixed false positives for redeclaration errors of using enum in
802804
nested scopes. (#GH147495)
805+
- Fixed a crash in `clang-scan-deps` when a module with the same name is found
806+
in different locations (#GH134404, #GH146976).
803807

804808
Bug Fixes to Compiler Builtins
805809
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -1072,6 +1076,8 @@ Windows Support
10721076
extensions are enabled. This allows for properly processing ``intsafe.h`` in
10731077
the Windows SDK.
10741078

1079+
- Clang now supports `mipsel-windows-gnu` and `mipsel-windows-msvc` targets.
1080+
10751081
LoongArch Support
10761082
^^^^^^^^^^^^^^^^^
10771083

clang/docs/ThinLTO.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,38 @@ The ``BOOTSTRAP_LLVM_ENABLE_LTO=Thin`` will enable ThinLTO for stage 2 and
240240
stage 3 in case the compiler used for stage 1 does not support the ThinLTO
241241
option.
242242

243+
Integrated Distributed ThinLTO (DTLTO)
244+
--------------------------------------
245+
246+
Integrated Distributed ThinLTO (DTLTO) enables the distribution of backend
247+
ThinLTO compilations via external distribution systems, such as Incredibuild,
248+
during the traditional link step.
249+
250+
The implementation is documented here: https://llvm.org/docs/DTLTO.html.
251+
252+
DTLTO requires the LLD linker (``-fuse-ld=lld``).
253+
254+
``-fthinlto-distributor=<path>``
255+
- Specifies the ``<path>`` to the distributor process executable for DTLTO.
256+
- If specified, ThinLTO backend compilations will be distributed by LLD.
257+
258+
``-Xthinlto-distributor=<arg>``
259+
- Passes ``<arg>`` to the distributor process (see ``-fthinlto-distributor=``).
260+
- Can be specified multiple times to pass multiple options.
261+
- Multiple options can also be specified by separating them with commas.
262+
263+
Examples:
264+
- ``clang -flto=thin -fthinlto-distributor=incredibuild.exe -Xthinlto-distributor=--verbose,--j10 -fuse-ld=lld``
265+
- ``clang -flto=thin -fthinlto-distributor=$(which python) -Xthinlto-distributor=incredibuild.py -fuse-ld=lld``
266+
267+
If ``-fthinlto-distributor=`` is specified, Clang supplies the path to a
268+
compiler to be executed remotely to perform the ThinLTO backend
269+
compilations. Currently, this is Clang itself.
270+
271+
Note that currently, DTLTO is only supported in some LLD flavors. Support can
272+
be added to other LLD flavours in the future.
273+
See `DTLTO <https://lld.llvm.org/dtlto.html>`_ for more information.
274+
243275
More Information
244276
================
245277

clang/include/clang/Driver/Options.td

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,13 @@ def Xlinker : Separate<["-"], "Xlinker">, Flags<[LinkerInput, RenderAsInput]>,
990990
Visibility<[ClangOption, CLOption, FlangOption]>,
991991
HelpText<"Pass <arg> to the linker">, MetaVarName<"<arg>">,
992992
Group<Link_Group>;
993+
def Xthinlto_distributor_EQ : CommaJoined<["-"], "Xthinlto-distributor=">,
994+
Flags<[LinkOption]>,
995+
Visibility<[ClangOption, CLOption]>,
996+
HelpText<"Pass <arg> to the ThinLTO distributor process. Can be specified "
997+
"multiple times or with comma-separated values.">,
998+
MetaVarName<"<arg>">,
999+
Group<Link_Group>;
9931000
def Xoffload_linker : JoinedAndSeparate<["-"], "Xoffload-linker">,
9941001
Visibility<[ClangOption, FlangOption]>,
9951002
HelpText<"Pass <arg> to the offload linkers or the ones identified by -<triple>">,
@@ -4249,7 +4256,12 @@ def ffinite_loops: Flag<["-"], "ffinite-loops">, Group<f_Group>,
42494256
def fno_finite_loops: Flag<["-"], "fno-finite-loops">, Group<f_Group>,
42504257
HelpText<"Do not assume that any loop is finite.">,
42514258
Visibility<[ClangOption, CC1Option]>;
4252-
4259+
def fthinlto_distributor_EQ : Joined<["-"], "fthinlto-distributor=">,
4260+
Group<f_Group>,
4261+
HelpText<"Path to the ThinLTO distributor process. If specified, "
4262+
"ThinLTO backend compilations will be distributed by LLD">,
4263+
MetaVarName<"<path>">,
4264+
Visibility<[ClangOption, CLOption]>;
42534265
def ftrigraphs : Flag<["-"], "ftrigraphs">, Group<f_Group>,
42544266
HelpText<"Process trigraph sequences">, Visibility<[ClangOption, CC1Option]>;
42554267
def fno_trigraphs : Flag<["-"], "fno-trigraphs">, Group<f_Group>,

clang/include/clang/Format/Format.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4694,6 +4694,13 @@ struct FormatStyle {
46944694
/// <conditional-body> <conditional-body>
46954695
/// \endcode
46964696
bool AfterIfMacros;
4697+
/// If ``true``, put a space between alternative operator ``not`` and the
4698+
/// opening parenthesis.
4699+
/// \code
4700+
/// true: false:
4701+
/// return not (a || b); vs. return not(a || b);
4702+
/// \endcode
4703+
bool AfterNot;
46974704
/// If ``true``, put a space between operator overloading and opening
46984705
/// parentheses.
46994706
/// \code
@@ -4742,9 +4749,9 @@ struct FormatStyle {
47424749
: AfterControlStatements(false), AfterForeachMacros(false),
47434750
AfterFunctionDeclarationName(false),
47444751
AfterFunctionDefinitionName(false), AfterIfMacros(false),
4745-
AfterOverloadedOperator(false), AfterPlacementOperator(true),
4746-
AfterRequiresInClause(false), AfterRequiresInExpression(false),
4747-
BeforeNonEmptyParentheses(false) {}
4752+
AfterNot(false), AfterOverloadedOperator(false),
4753+
AfterPlacementOperator(true), AfterRequiresInClause(false),
4754+
AfterRequiresInExpression(false), BeforeNonEmptyParentheses(false) {}
47484755

47494756
bool operator==(const SpaceBeforeParensCustom &Other) const {
47504757
return AfterControlStatements == Other.AfterControlStatements &&
@@ -4753,6 +4760,7 @@ struct FormatStyle {
47534760
Other.AfterFunctionDeclarationName &&
47544761
AfterFunctionDefinitionName == Other.AfterFunctionDefinitionName &&
47554762
AfterIfMacros == Other.AfterIfMacros &&
4763+
AfterNot == Other.AfterNot &&
47564764
AfterOverloadedOperator == Other.AfterOverloadedOperator &&
47574765
AfterPlacementOperator == Other.AfterPlacementOperator &&
47584766
AfterRequiresInClause == Other.AfterRequiresInClause &&

clang/lib/Basic/Targets.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,9 @@ std::unique_ptr<TargetInfo> AllocateTarget(const llvm::Triple &Triple,
769769
case llvm::Triple::FreeBSD:
770770
return std::make_unique<FreeBSDTargetInfo<LoongArch64TargetInfo>>(Triple,
771771
Opts);
772+
case llvm::Triple::OpenBSD:
773+
return std::make_unique<OpenBSDTargetInfo<LoongArch64TargetInfo>>(Triple,
774+
Opts);
772775
default:
773776
return std::make_unique<LoongArch64TargetInfo>(Triple, Opts);
774777
}

clang/lib/Basic/Targets/OSTargets.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@ class LLVM_LIBRARY_VISIBILITY OpenBSDTargetInfo : public OSTargetInfo<Target> {
496496
case llvm::Triple::sparcv9:
497497
this->MCountName = "_mcount";
498498
break;
499+
case llvm::Triple::loongarch64:
499500
case llvm::Triple::riscv64:
500501
break;
501502
}

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ void CGDebugInfo::addInstToSpecificSourceAtom(llvm::Instruction *KeyInstruction,
170170
if (!Group || !CGM.getCodeGenOpts().DebugKeyInstructions)
171171
return;
172172

173+
llvm::DISubprogram *SP = KeyInstruction->getFunction()->getSubprogram();
174+
if (!SP || !SP->getKeyInstructionsEnabled())
175+
return;
176+
173177
addInstSourceAtomMetadata(KeyInstruction, Group, /*Rank=*/1);
174178

175179
llvm::Instruction *BackupI =

clang/lib/CodeGen/CGStmt.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,11 +846,13 @@ void CodeGenFunction::EmitGotoStmt(const GotoStmt &S) {
846846
if (HaveInsertPoint())
847847
EmitStopPoint(&S);
848848

849+
ApplyAtomGroup Grp(getDebugInfo());
849850
EmitBranchThroughCleanup(getJumpDestForLabel(S.getLabel()));
850851
}
851852

852853

853854
void CodeGenFunction::EmitIndirectGotoStmt(const IndirectGotoStmt &S) {
855+
ApplyAtomGroup Grp(getDebugInfo());
854856
if (const LabelDecl *Target = S.getConstantTarget()) {
855857
EmitBranchThroughCleanup(getJumpDestForLabel(Target));
856858
return;
@@ -869,6 +871,8 @@ void CodeGenFunction::EmitIndirectGotoStmt(const IndirectGotoStmt &S) {
869871
cast<llvm::PHINode>(IndGotoBB->begin())->addIncoming(V, CurBB);
870872

871873
EmitBranch(IndGotoBB);
874+
if (CurBB && CurBB->getTerminator())
875+
addInstToCurrentSourceAtom(CurBB->getTerminator(), nullptr);
872876
}
873877

874878
void CodeGenFunction::EmitIfStmt(const IfStmt &S) {
@@ -2672,6 +2676,9 @@ static void UpdateAsmCallInst(llvm::CallBase &Result, bool HasSideEffect,
26722676
llvm::ConstantAsMetadata::get(Loc)));
26732677
}
26742678

2679+
// Make inline-asm calls Key for the debug info feature Key Instructions.
2680+
CGF.addInstToNewSourceAtom(&Result, nullptr);
2681+
26752682
if (!NoConvergent && CGF.getLangOpts().assumeFunctionsAreConvergent())
26762683
// Conservatively, mark all inline asm blocks in CUDA or OpenCL as
26772684
// convergent (meaning, they may call an intrinsically convergent op, such
@@ -2750,14 +2757,16 @@ EmitAsmStores(CodeGenFunction &CGF, const AsmStmt &S,
27502757
}
27512758
}
27522759

2760+
ApplyAtomGroup Grp(CGF.getDebugInfo());
27532761
LValue Dest = ResultRegDests[i];
27542762
// ResultTypeRequiresCast elements correspond to the first
27552763
// ResultTypeRequiresCast.size() elements of RegResults.
27562764
if ((i < ResultTypeRequiresCast.size()) && ResultTypeRequiresCast[i]) {
27572765
unsigned Size = CGF.getContext().getTypeSize(ResultRegQualTys[i]);
27582766
Address A = Dest.getAddress().withElementType(ResultRegTypes[i]);
27592767
if (CGF.getTargetHooks().isScalarizableAsmOperand(CGF, TruncTy)) {
2760-
Builder.CreateStore(Tmp, A);
2768+
llvm::StoreInst *S = Builder.CreateStore(Tmp, A);
2769+
CGF.addInstToCurrentSourceAtom(S, S->getValueOperand());
27612770
continue;
27622771
}
27632772

clang/lib/Driver/ToolChains/Arch/Sparc.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ const char *sparc::getSparcAsmModeForCPU(StringRef Name,
2323
if (Triple.getArch() == llvm::Triple::sparcv9) {
2424
const char *DefV9CPU;
2525

26-
if (Triple.isOSLinux() || Triple.isOSFreeBSD() || Triple.isOSOpenBSD())
26+
if (Triple.isOSSolaris())
27+
DefV9CPU = "-Av9b";
28+
else if (Triple.isOSLinux() || Triple.isOSFreeBSD() || Triple.isOSOpenBSD())
2729
DefV9CPU = "-Av9a";
2830
else
2931
DefV9CPU = "-Av9";
@@ -157,6 +159,7 @@ void sparc::getSparcTargetFeatures(const Driver &D, const llvm::Triple &Triple,
157159
bool IsSparcV9ATarget =
158160
(Triple.getArch() == llvm::Triple::sparcv9) &&
159161
(Triple.isOSLinux() || Triple.isOSFreeBSD() || Triple.isOSOpenBSD());
162+
bool IsSparcV9BTarget = Triple.isOSSolaris();
160163
if (Arg *A = Args.getLastArg(options::OPT_mvis, options::OPT_mno_vis)) {
161164
if (A->getOption().matches(options::OPT_mvis))
162165
Features.push_back("+vis");
@@ -171,6 +174,8 @@ void sparc::getSparcTargetFeatures(const Driver &D, const llvm::Triple &Triple,
171174
Features.push_back("+vis2");
172175
else
173176
Features.push_back("-vis2");
177+
} else if (IsSparcV9BTarget) {
178+
Features.push_back("+vis2");
174179
}
175180

176181
if (Arg *A = Args.getLastArg(options::OPT_mvis3, options::OPT_mno_vis3)) {

0 commit comments

Comments
 (0)