Skip to content

Commit 5c3bd5f

Browse files
committed
Merge branch 'main' into generalize-fusion
2 parents 8a375bf + a7425f9 commit 5c3bd5f

File tree

558 files changed

+21142
-8125
lines changed

Some content is hidden

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

558 files changed

+21142
-8125
lines changed

bolt/lib/Core/Exceptions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ bool CFIReaderWriter::fillCFIInfoFor(BinaryFunction &Function) const {
500500

501501
const FDE &CurFDE = *I->second;
502502
std::optional<uint64_t> LSDA = CurFDE.getLSDAAddress();
503-
Function.setLSDAAddress(LSDA ? *LSDA : 0);
503+
Function.setLSDAAddress(LSDA.value_or(0));
504504

505505
uint64_t Offset = Function.getFirstInstructionOffset();
506506
uint64_t CodeAlignment = CurFDE.getLinkedCIE()->getCodeAlignmentFactor();

clang-tools-extra/clang-tidy/.clang-tidy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ Checks: >
2222
-performance-unnecessary-value-param,
2323
readability-*,
2424
-readability-avoid-nested-conditional-operator,
25-
-readability-avoid-return-with-void-value,
2625
-readability-braces-around-statements,
2726
-readability-container-contains,
2827
-readability-convert-member-functions-to-static,

clang-tools-extra/clang-tidy/bugprone/NarrowingConversionsCheck.cpp

Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -381,10 +381,11 @@ void NarrowingConversionsCheck::diagNarrowTypeOrConstant(
381381
const Expr &Rhs) {
382382
APValue Constant = getConstantExprValue(Context, Rhs);
383383
if (Constant.isInt())
384-
return diagNarrowIntegerConstant(SourceLoc, Lhs, Rhs, Constant.getInt());
385-
if (Constant.isFloat())
386-
return diagNarrowConstant(SourceLoc, Lhs, Rhs);
387-
return diagNarrowType(SourceLoc, Lhs, Rhs);
384+
diagNarrowIntegerConstant(SourceLoc, Lhs, Rhs, Constant.getInt());
385+
else if (Constant.isFloat())
386+
diagNarrowConstant(SourceLoc, Lhs, Rhs);
387+
else
388+
diagNarrowType(SourceLoc, Lhs, Rhs);
388389
}
389390

390391
void NarrowingConversionsCheck::handleIntegralCast(const ASTContext &Context,
@@ -460,10 +461,10 @@ void NarrowingConversionsCheck::handleFloatingToIntegral(
460461
llvm::APFloat FloatConstant(0.0);
461462
if (getFloatingConstantExprValue(Context, Rhs, FloatConstant)) {
462463
if (!isFloatExactlyRepresentable(Context, FloatConstant, Lhs.getType()))
463-
return diagNarrowConstant(SourceLoc, Lhs, Rhs);
464+
diagNarrowConstant(SourceLoc, Lhs, Rhs);
464465

465-
if (PedanticMode)
466-
return diagConstantCast(SourceLoc, Lhs, Rhs);
466+
else if (PedanticMode)
467+
diagConstantCast(SourceLoc, Lhs, Rhs);
467468

468469
return;
469470
}
@@ -478,7 +479,7 @@ void NarrowingConversionsCheck::handleFloatingToIntegral(
478479
void NarrowingConversionsCheck::handleFloatingToBoolean(
479480
const ASTContext &Context, SourceLocation SourceLoc, const Expr &Lhs,
480481
const Expr &Rhs) {
481-
return diagNarrowTypeOrConstant(Context, SourceLoc, Lhs, Rhs);
482+
diagNarrowTypeOrConstant(Context, SourceLoc, Lhs, Rhs);
482483
}
483484

484485
void NarrowingConversionsCheck::handleBooleanToSignedIntegral(
@@ -532,19 +533,20 @@ void NarrowingConversionsCheck::handleBinaryOperator(const ASTContext &Context,
532533
if (LhsType == RhsType)
533534
return;
534535
if (RhsType->getKind() == BuiltinType::Bool && LhsType->isSignedInteger())
535-
return handleBooleanToSignedIntegral(Context, SourceLoc, Lhs, Rhs);
536-
if (RhsType->isInteger() && LhsType->getKind() == BuiltinType::Bool)
537-
return handleIntegralToBoolean(Context, SourceLoc, Lhs, Rhs);
538-
if (RhsType->isInteger() && LhsType->isFloatingPoint())
539-
return handleIntegralToFloating(Context, SourceLoc, Lhs, Rhs);
540-
if (RhsType->isInteger() && LhsType->isInteger())
541-
return handleIntegralCast(Context, SourceLoc, Lhs, Rhs);
542-
if (RhsType->isFloatingPoint() && LhsType->getKind() == BuiltinType::Bool)
543-
return handleFloatingToBoolean(Context, SourceLoc, Lhs, Rhs);
544-
if (RhsType->isFloatingPoint() && LhsType->isInteger())
545-
return handleFloatingToIntegral(Context, SourceLoc, Lhs, Rhs);
546-
if (RhsType->isFloatingPoint() && LhsType->isFloatingPoint())
547-
return handleFloatingCast(Context, SourceLoc, Lhs, Rhs);
536+
handleBooleanToSignedIntegral(Context, SourceLoc, Lhs, Rhs);
537+
else if (RhsType->isInteger() && LhsType->getKind() == BuiltinType::Bool)
538+
handleIntegralToBoolean(Context, SourceLoc, Lhs, Rhs);
539+
else if (RhsType->isInteger() && LhsType->isFloatingPoint())
540+
handleIntegralToFloating(Context, SourceLoc, Lhs, Rhs);
541+
else if (RhsType->isInteger() && LhsType->isInteger())
542+
handleIntegralCast(Context, SourceLoc, Lhs, Rhs);
543+
else if (RhsType->isFloatingPoint() &&
544+
LhsType->getKind() == BuiltinType::Bool)
545+
handleFloatingToBoolean(Context, SourceLoc, Lhs, Rhs);
546+
else if (RhsType->isFloatingPoint() && LhsType->isInteger())
547+
handleFloatingToIntegral(Context, SourceLoc, Lhs, Rhs);
548+
else if (RhsType->isFloatingPoint() && LhsType->isFloatingPoint())
549+
handleFloatingCast(Context, SourceLoc, Lhs, Rhs);
548550
}
549551

550552
bool NarrowingConversionsCheck::handleConditionalOperator(
@@ -577,21 +579,28 @@ void NarrowingConversionsCheck::handleImplicitCast(
577579
SourceLocation SourceLoc = Lhs.getExprLoc();
578580
switch (Cast.getCastKind()) {
579581
case CK_BooleanToSignedIntegral:
580-
return handleBooleanToSignedIntegral(Context, SourceLoc, Lhs, Rhs);
582+
handleBooleanToSignedIntegral(Context, SourceLoc, Lhs, Rhs);
583+
return;
581584
case CK_IntegralToBoolean:
582-
return handleIntegralToBoolean(Context, SourceLoc, Lhs, Rhs);
585+
handleIntegralToBoolean(Context, SourceLoc, Lhs, Rhs);
586+
return;
583587
case CK_IntegralToFloating:
584-
return handleIntegralToFloating(Context, SourceLoc, Lhs, Rhs);
588+
handleIntegralToFloating(Context, SourceLoc, Lhs, Rhs);
589+
return;
585590
case CK_IntegralCast:
586-
return handleIntegralCast(Context, SourceLoc, Lhs, Rhs);
591+
handleIntegralCast(Context, SourceLoc, Lhs, Rhs);
592+
return;
587593
case CK_FloatingToBoolean:
588-
return handleFloatingToBoolean(Context, SourceLoc, Lhs, Rhs);
594+
handleFloatingToBoolean(Context, SourceLoc, Lhs, Rhs);
595+
return;
589596
case CK_FloatingToIntegral:
590-
return handleFloatingToIntegral(Context, SourceLoc, Lhs, Rhs);
597+
handleFloatingToIntegral(Context, SourceLoc, Lhs, Rhs);
598+
return;
591599
case CK_FloatingCast:
592-
return handleFloatingCast(Context, SourceLoc, Lhs, Rhs);
600+
handleFloatingCast(Context, SourceLoc, Lhs, Rhs);
601+
return;
593602
default:
594-
break;
603+
return;
595604
}
596605
}
597606

@@ -610,9 +619,10 @@ void NarrowingConversionsCheck::handleBinaryOperator(const ASTContext &Context,
610619

611620
void NarrowingConversionsCheck::check(const MatchFinder::MatchResult &Result) {
612621
if (const auto *Op = Result.Nodes.getNodeAs<BinaryOperator>("binary_op"))
613-
return handleBinaryOperator(*Result.Context, *Op);
614-
if (const auto *Cast = Result.Nodes.getNodeAs<ImplicitCastExpr>("cast"))
615-
return handleImplicitCast(*Result.Context, *Cast);
616-
llvm_unreachable("must be binary operator or cast expression");
622+
handleBinaryOperator(*Result.Context, *Op);
623+
else if (const auto *Cast = Result.Nodes.getNodeAs<ImplicitCastExpr>("cast"))
624+
handleImplicitCast(*Result.Context, *Cast);
625+
else
626+
llvm_unreachable("must be binary operator or cast expression");
617627
}
618628
} // namespace clang::tidy::bugprone

clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,14 +361,15 @@ void ImplicitBoolConversionCheck::check(
361361
if (const auto *CastToBool =
362362
Result.Nodes.getNodeAs<ImplicitCastExpr>("implicitCastToBool")) {
363363
const auto *Parent = Result.Nodes.getNodeAs<Stmt>("parentStmt");
364-
return handleCastToBool(CastToBool, Parent, *Result.Context);
364+
handleCastToBool(CastToBool, Parent, *Result.Context);
365+
return;
365366
}
366367

367368
if (const auto *CastFromBool =
368369
Result.Nodes.getNodeAs<ImplicitCastExpr>("implicitCastFromBool")) {
369370
const auto *NextImplicitCast =
370371
Result.Nodes.getNodeAs<ImplicitCastExpr>("furtherImplicitCast");
371-
return handleCastFromBool(CastFromBool, NextImplicitCast, *Result.Context);
372+
handleCastFromBool(CastFromBool, NextImplicitCast, *Result.Context);
372373
}
373374
}
374375

clang/docs/InternalsManual.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ wording a diagnostic.
139139
you mean %1?``.
140140

141141
* Appropriately capitalize proper nouns like ``Clang``, ``OpenCL``, ``GCC``,
142-
``Objective-C``, etc and language standard versions like ``C11`` or ``C++11``.
142+
``Objective-C``, etc. and language standard versions like ``C11`` or ``C++11``.
143143
* The wording should be succinct. If necessary, use a semicolon to combine
144144
sentence fragments instead of using complete sentences. e.g., prefer wording
145145
like ``'%0' is deprecated; it will be removed in a future release of Clang``
@@ -886,7 +886,7 @@ a string that the tablegen backend uses as a prefix to the
886886
LANG_OPTION_WITH_MARSHALLING([...], LangOpts->IgnoreExceptions, [...])
887887
#endif // LANG_OPTION_WITH_MARSHALLING
888888

889-
Such definition can be used used in the function for parsing and generating
889+
Such definition can be used in the function for parsing and generating
890890
command line:
891891

892892
.. code-block:: c++
@@ -1745,7 +1745,7 @@ will be found by the lookup, since it effectively replaces the first
17451745
declaration of "``f``".
17461746

17471747
(Note that because ``f`` can be redeclared at block scope, or in a friend
1748-
declaration, etc. it is possible that the declaration of ``f`` found by name
1748+
declaration, etc., it is possible that the declaration of ``f`` found by name
17491749
lookup will not be the most recent one.)
17501750

17511751
In the semantics-centric view, overloading of functions is represented
@@ -1945,7 +1945,7 @@ range of iterators over declarations of "``f``".
19451945
function ``DeclContext::getPrimaryContext`` retrieves the "primary" context for
19461946
a given ``DeclContext`` instance, which is the ``DeclContext`` responsible for
19471947
maintaining the lookup table used for the semantics-centric view. Given a
1948-
DeclContext, one can obtain the set of declaration contexts that are
1948+
``DeclContext``, one can obtain the set of declaration contexts that are
19491949
semantically connected to this declaration context, in source order, including
19501950
this context (which will be the only result, for non-namespace contexts) via
19511951
``DeclContext::collectAllContexts``. Note that these functions are used
@@ -1985,7 +1985,7 @@ broken code in the AST:
19851985
errors, the Decl node is marked as invalid.
19861986
- dropping invalid node: this often happens for errors that we don’t have
19871987
graceful recovery. Prior to Recovery AST, a mismatched-argument function call
1988-
expression was dropped though a CallExpr was created for semantic analysis.
1988+
expression was dropped though a ``CallExpr`` was created for semantic analysis.
19891989

19901990
With these strategies, clang surfaces better diagnostics, and provides AST
19911991
consumers a rich AST reflecting the written source code as much as possible even

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,16 @@ Static Analyzer
241241
---------------
242242
- The Clang Static Analyzer now handles parenthesized initialization.
243243
(#GH148875)
244+
- ``__datasizeof`` (C++) and ``_Countof`` (C) no longer cause a failed assertion
245+
when given an operand of VLA type. (#GH151711)
244246

245247
New features
246248
^^^^^^^^^^^^
247249

248250
Crash and bug fixes
249251
^^^^^^^^^^^^^^^^^^^
252+
- Fixed a crash in the static analyzer that when the expression in an
253+
``[[assume(expr)]]`` attribute was enclosed in parentheses. (#GH151529)
250254

251255
Improvements
252256
^^^^^^^^^^^^

clang/docs/ThinLTO.rst

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,9 @@ during the traditional link step.
249249

250250
The implementation is documented here: https://llvm.org/docs/DTLTO.html.
251251

252+
Command-Line Options
253+
^^^^^^^^^^^^^^^^^^^^
254+
252255
DTLTO requires the LLD linker (``-fuse-ld=lld``).
253256

254257
``-fthinlto-distributor=<path>``
@@ -260,17 +263,29 @@ DTLTO requires the LLD linker (``-fuse-ld=lld``).
260263
- Can be specified multiple times to pass multiple options.
261264
- Multiple options can also be specified by separating them with commas.
262265

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-
267266
If ``-fthinlto-distributor=`` is specified, Clang supplies the path to a
268267
compiler to be executed remotely to perform the ThinLTO backend
269268
compilations. Currently, this is Clang itself.
270269

270+
Usage
271+
^^^^^
272+
273+
Compilation is unchanged from ThinLTO. DTLTO options need to supplied for the link step:
274+
275+
.. code-block:: console
276+
277+
% clang -flto=thin -fthinlto-distributor=distribute.sh -Xthinlto-distributor=--verbose,--j10 -fuse-ld=lld file1.o file2.o
278+
% clang -flto=thin -fthinlto-distributor=$(which python) -Xthinlto-distributor=distribute.py -fuse-ld=lld file1.o file2.o
279+
280+
When using lld-link:
281+
282+
.. code-block:: console
283+
284+
% lld-link /out:a.exe file1.obj file2.obj /thinlto-distributor:distribute.exe /thinlto-remote-compiler:${LLVM}\bin\clang.exe /thinlto-distributor-arg:--verbose
285+
271286
Note that currently, DTLTO is only supported in some LLD flavors. Support can
272287
be added to other LLD flavours in the future.
273-
See `DTLTO <https://lld.llvm.org/dtlto.html>`_ for more information.
288+
See `DTLTO <https://lld.llvm.org/DTLTO.html>`_ for more information.
274289

275290
More Information
276291
================

clang/include/clang/AST/Expr.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -553,17 +553,13 @@ class Expr : public ValueStmt {
553553
bool IgnoreTemplateOrMacroSubstitution = false) const;
554554

555555
/// isIntegerConstantExpr - Return the value if this expression is a valid
556-
/// integer constant expression. If not a valid i-c-e, return std::nullopt
557-
/// and fill in Loc (if specified) with the location of the invalid
558-
/// expression.
556+
/// integer constant expression. If not a valid i-c-e, return std::nullopt.
559557
///
560558
/// Note: This does not perform the implicit conversions required by C++11
561559
/// [expr.const]p5.
562560
std::optional<llvm::APSInt>
563-
getIntegerConstantExpr(const ASTContext &Ctx,
564-
SourceLocation *Loc = nullptr) const;
565-
bool isIntegerConstantExpr(const ASTContext &Ctx,
566-
SourceLocation *Loc = nullptr) const;
561+
getIntegerConstantExpr(const ASTContext &Ctx) const;
562+
bool isIntegerConstantExpr(const ASTContext &Ctx) const;
567563

568564
/// isCXX98IntegralConstantExpr - Return true if this expression is an
569565
/// integral constant expression in C++98. Can only be used in C++.
@@ -574,8 +570,8 @@ class Expr : public ValueStmt {
574570
///
575571
/// Note: This does not perform the implicit conversions required by C++11
576572
/// [expr.const]p5.
577-
bool isCXX11ConstantExpr(const ASTContext &Ctx, APValue *Result = nullptr,
578-
SourceLocation *Loc = nullptr) const;
573+
bool isCXX11ConstantExpr(const ASTContext &Ctx,
574+
APValue *Result = nullptr) const;
579575

580576
/// isPotentialConstantExpr - Return true if this function's definition
581577
/// might be usable in a constant expression in C++11, if it were marked

clang/include/clang/Basic/Attr.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1642,7 +1642,7 @@ def DeviceKernel : DeclOrTypeAttr {
16421642
}
16431643

16441644
def SYCLKernelEntryPoint : InheritableAttr {
1645-
let Spellings = [Clang<"sycl_kernel_entry_point">];
1645+
let Spellings = [CXX11<"clang", "sycl_kernel_entry_point">];
16461646
let Args = [
16471647
// KernelName is required and specifies the kernel name type.
16481648
TypeArgument<"KernelName">,

clang/include/clang/Basic/BuiltinsAMDGPU.def

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,17 @@ TARGET_BUILTIN(__builtin_amdgcn_cvt_pk_fp8_f16, "sV2h", "nc", "gfx1250-insts")
707707
TARGET_BUILTIN(__builtin_amdgcn_cvt_pk_bf8_f16, "sV2h", "nc", "gfx1250-insts")
708708
TARGET_BUILTIN(__builtin_amdgcn_cvt_sr_fp8_f16, "ihiUiIi", "nc", "gfx1250-insts")
709709
TARGET_BUILTIN(__builtin_amdgcn_cvt_sr_bf8_f16, "ihiUiIi", "nc", "gfx1250-insts")
710+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scale_pk8_f16_fp8, "V8hV2UiUiIUi", "nc", "gfx1250-insts")
711+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scale_pk8_bf16_fp8, "V8yV2UiUiIUi", "nc", "gfx1250-insts")
712+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scale_pk8_f16_bf8, "V8hV2UiUiIUi", "nc", "gfx1250-insts")
713+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scale_pk8_bf16_bf8, "V8yV2UiUiIUi", "nc", "gfx1250-insts")
714+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scale_pk8_f16_fp4, "V8hUiUiIUi", "nc", "gfx1250-insts")
715+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scale_pk8_bf16_fp4, "V8yUiUiIUi", "nc", "gfx1250-insts")
716+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scale_pk8_f32_fp8, "V8fV2UiUiIUi", "nc", "gfx1250-insts")
717+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scale_pk8_f32_bf8, "V8fV2UiUiIUi", "nc", "gfx1250-insts")
718+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scale_pk8_f32_fp4, "V8fUiUiIUi", "nc", "gfx1250-insts")
719+
TARGET_BUILTIN(__builtin_amdgcn_cvt_pk_fp8_f32_e5m3, "iffiIb", "nc", "fp8e5m3-insts")
720+
TARGET_BUILTIN(__builtin_amdgcn_cvt_sr_fp8_f32_e5m3, "ifiiIi", "nc", "fp8e5m3-insts")
710721
TARGET_BUILTIN(__builtin_amdgcn_sat_pk4_i4_i8, "UsUi", "nc", "gfx1250-insts")
711722
TARGET_BUILTIN(__builtin_amdgcn_sat_pk4_u4_u8, "UsUi", "nc", "gfx1250-insts")
712723

0 commit comments

Comments
 (0)