Skip to content

Commit 174187b

Browse files
committed
merge main into amd-staging
revert: fix later cfc76b6 [llvm][offload] Move AMDGPU offload utilities to LLVM (llvm#102487) Change-Id: I1ea1a1ea22da30c11a1bcd8fe411c40a8d7b7076
2 parents 9a789a0 + 1e9d002 commit 174187b

File tree

368 files changed

+14257
-4655
lines changed

Some content is hidden

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

368 files changed

+14257
-4655
lines changed

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2502,7 +2502,7 @@ void BinaryFunction::annotateCFIState() {
25022502
}
25032503
}
25042504

2505-
if (!StateStack.empty()) {
2505+
if (opts::Verbosity >= 1 && !StateStack.empty()) {
25062506
BC.errs() << "BOLT-WARNING: non-empty CFI stack at the end of " << *this
25072507
<< '\n';
25082508
}

clang/docs/InternalsManual.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3200,7 +3200,7 @@ are similar.
32003200
always involve two functions: an ``ActOnXXX`` function that will be called
32013201
directly from the parser, and a ``BuildXXX`` function that performs the
32023202
actual semantic analysis and will (eventually!) build the AST node. It's
3203-
fairly common for the ``ActOnCXX`` function to do very little (often just
3203+
fairly common for the ``ActOnXXX`` function to do very little (often just
32043204
some minor translation from the parser's representation to ``Sema``'s
32053205
representation of the same thing), but the separation is still important:
32063206
C++ template instantiation, for example, should always call the ``BuildXXX``

clang/docs/LanguageExtensions.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3987,7 +3987,7 @@ ellipsis (``...``) in the function signature. Alternatively, in C23 mode or
39873987
later, it may be the integer literal ``0`` if there is no parameter preceding
39883988
the ellipsis. This function initializes the given ``__builtin_va_list`` object.
39893989
It is undefined behavior to call this function on an already initialized
3990-
``__builin_va_list`` object.
3990+
``__builtin_va_list`` object.
39913991
39923992
* ``void __builtin_va_end(__builtin_va_list list)``
39933993
@@ -4321,7 +4321,7 @@ an appropriate value during the emission.
43214321
43224322
Note that there is no builtin matching the `llvm.coro.save` intrinsic. LLVM
43234323
automatically will insert one if the first argument to `llvm.coro.suspend` is
4324-
token `none`. If a user calls `__builin_suspend`, clang will insert `token none`
4324+
token `none`. If a user calls `__builtin_suspend`, clang will insert `token none`
43254325
as the first argument to the intrinsic.
43264326
43274327
Source location builtins

clang/docs/ReleaseNotes.rst

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ Resolutions to C++ Defect Reports
154154
of the target type, even if the type of the bit-field is larger.
155155
(`CWG2627: Bit-fields and narrowing conversions <https://cplusplus.github.io/CWG/issues/2627.html>`_)
156156

157+
- ``nullptr`` is now promoted to ``void*`` when passed to a C-style variadic function.
158+
(`CWG722: Can nullptr be passed to an ellipsis? <https://cplusplus.github.io/CWG/issues/722.html>`_)
159+
157160
C Language Changes
158161
------------------
159162

@@ -181,6 +184,14 @@ Modified Compiler Flags
181184

182185
- The compiler flag `-fbracket-depth` default value is increased from 256 to 2048.
183186

187+
- The ``-ffp-model`` option has been updated to enable a more limited set of
188+
optimizations when the ``fast`` argument is used and to accept a new argument,
189+
``aggressive``. The behavior of ``-ffp-model=aggressive`` is equivalent
190+
to the previous behavior of ``-ffp-model=fast``. The updated
191+
``-ffp-model=fast`` behavior no longer assumes finite math only and uses
192+
the ``promoted`` algorithm for complex division when possible rather than the
193+
less basic (limited range) algorithm.
194+
184195
Removed Compiler Flags
185196
-------------------------
186197

@@ -385,6 +396,9 @@ AST Matchers
385396
- Fixed an issue with the `hasName` and `hasAnyName` matcher when matching
386397
inline namespaces with an enclosing namespace of the same name.
387398

399+
- Fixed an ordering issue with the `hasOperands` matcher occuring when setting a
400+
binding in the first matcher and using it in the second matcher.
401+
388402
clang-format
389403
------------
390404

@@ -429,6 +443,36 @@ Moved checkers
429443
Sanitizers
430444
----------
431445

446+
- Added the ``-fsanitize-undefined-ignore-overflow-pattern`` flag which can be
447+
used to disable specific overflow-dependent code patterns. The supported
448+
patterns are: ``add-overflow-test``, ``negated-unsigned-const``, and
449+
``post-decr-while``. The sanitizer instrumentation can be toggled off for all
450+
available patterns by specifying ``all``. Conversely, you can disable all
451+
exclusions with ``none``.
452+
453+
.. code-block:: c++
454+
455+
/// specified with ``-fsanitize-undefined-ignore-overflow-pattern=add-overflow-test``
456+
int common_overflow_check_pattern(unsigned base, unsigned offset) {
457+
if (base + offset < base) { /* ... */ } // The pattern of `a + b < a`, and other re-orderings, won't be instrumented
458+
}
459+
460+
/// specified with ``-fsanitize-undefined-ignore-overflow-pattern=negated-unsigned-const``
461+
void negation_overflow() {
462+
unsigned long foo = -1UL; // No longer causes a negation overflow warning
463+
unsigned long bar = -2UL; // and so on...
464+
}
465+
466+
/// specified with ``-fsanitize-undefined-ignore-overflow-pattern=post-decr-while``
467+
void while_post_decrement() {
468+
unsigned char count = 16;
469+
while (count--) { /* ... */} // No longer causes unsigned-integer-overflow sanitizer to trip
470+
}
471+
472+
Many existing projects have a large amount of these code patterns present.
473+
This new flag should allow those projects to enable integer sanitizers with
474+
less noise.
475+
432476
Python Binding Changes
433477
----------------------
434478
- Fixed an issue that led to crashes when calling ``Type.get_exception_specification_kind``.

clang/docs/UndefinedBehaviorSanitizer.rst

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,48 @@ To silence reports from unsigned integer overflow, you can set
293293
``-fsanitize-recover=unsigned-integer-overflow``, is particularly useful for
294294
providing fuzzing signal without blowing up logs.
295295

296+
Disabling instrumentation for common overflow patterns
297+
------------------------------------------------------
298+
299+
There are certain overflow-dependent or overflow-prone code patterns which
300+
produce a lot of noise for integer overflow/truncation sanitizers. Negated
301+
unsigned constants, post-decrements in a while loop condition and simple
302+
overflow checks are accepted and pervasive code patterns. However, the signal
303+
received from sanitizers instrumenting these code patterns may be too noisy for
304+
some projects. To disable instrumentation for these common patterns one should
305+
use ``-fsanitize-undefined-ignore-overflow-pattern=``.
306+
307+
Currently, this option supports three overflow-dependent code idioms:
308+
309+
``negated-unsigned-const``
310+
311+
.. code-block:: c++
312+
313+
/// -fsanitize-undefined-ignore-overflow-pattern=negated-unsigned-const
314+
unsigned long foo = -1UL; // No longer causes a negation overflow warning
315+
unsigned long bar = -2UL; // and so on...
316+
317+
``post-decr-while``
318+
319+
.. code-block:: c++
320+
321+
/// -fsanitize-undefined-ignore-overflow-pattern=post-decr-while
322+
unsigned char count = 16;
323+
while (count--) { /* ... */ } // No longer causes unsigned-integer-overflow sanitizer to trip
324+
325+
``add-overflow-test``
326+
327+
.. code-block:: c++
328+
329+
/// -fsanitize-undefined-ignore-overflow-pattern=add-overflow-test
330+
if (base + offset < base) { /* ... */ } // The pattern of `a + b < a`, and other re-orderings,
331+
// won't be instrumented (same for signed types)
332+
333+
You can enable all exclusions with
334+
``-fsanitize-undefined-ignore-overflow-pattern=all`` or disable all exclusions
335+
with ``-fsanitize-undefined-ignore-overflow-pattern=none``. Specifying ``none``
336+
has precedence over other values.
337+
296338
Issue Suppression
297339
=================
298340

clang/docs/UsersManual.rst

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,28 +1452,30 @@ describes the various floating point semantic modes and the corresponding option
14521452
"fhonor-infinities", "{on, off}"
14531453
"fsigned-zeros", "{on, off}"
14541454
"freciprocal-math", "{on, off}"
1455-
"allow_approximate_fns", "{on, off}"
1455+
"fallow-approximate-fns", "{on, off}"
14561456
"fassociative-math", "{on, off}"
1457+
"fcomplex-arithmetic", "{basic, improved, full, promoted}"
14571458

14581459
This table describes the option settings that correspond to the three
14591460
floating point semantic models: precise (the default), strict, and fast.
14601461

14611462

14621463
.. csv-table:: Floating Point Models
1463-
:header: "Mode", "Precise", "Strict", "Fast"
1464-
:widths: 25, 15, 15, 15
1465-
1466-
"except_behavior", "ignore", "strict", "ignore"
1467-
"fenv_access", "off", "on", "off"
1468-
"rounding_mode", "tonearest", "dynamic", "tonearest"
1469-
"contract", "on", "off", "fast"
1470-
"support_math_errno", "on", "on", "off"
1471-
"no_honor_nans", "off", "off", "on"
1472-
"no_honor_infinities", "off", "off", "on"
1473-
"no_signed_zeros", "off", "off", "on"
1474-
"allow_reciprocal", "off", "off", "on"
1475-
"allow_approximate_fns", "off", "off", "on"
1476-
"allow_reassociation", "off", "off", "on"
1464+
:header: "Mode", "Precise", "Strict", "Fast", "Aggressive"
1465+
:widths: 25, 25, 25, 25, 25
1466+
1467+
"except_behavior", "ignore", "strict", "ignore", "ignore"
1468+
"fenv_access", "off", "on", "off", "off"
1469+
"rounding_mode", "tonearest", "dynamic", "tonearest", "tonearest"
1470+
"contract", "on", "off", "fast", "fast"
1471+
"support_math_errno", "on", "on", "off", "off"
1472+
"no_honor_nans", "off", "off", "off", "on"
1473+
"no_honor_infinities", "off", "off", "off", "on"
1474+
"no_signed_zeros", "off", "off", "on", "on"
1475+
"allow_reciprocal", "off", "off", "on", "on"
1476+
"allow_approximate_fns", "off", "off", "on", "on"
1477+
"allow_reassociation", "off", "off", "on", "on"
1478+
"complex_arithmetic", "full", "full", "promoted", "basic"
14771479

14781480
The ``-ffp-model`` option does not modify the ``fdenormal-fp-math``
14791481
setting, but it does have an impact on whether ``crtfastmath.o`` is
@@ -1492,9 +1494,9 @@ for more details.
14921494
* Floating-point math obeys regular algebraic rules for real numbers (e.g.
14931495
``+`` and ``*`` are associative, ``x/y == x * (1/y)``, and
14941496
``(a + b) * c == a * c + b * c``),
1495-
* Operands to floating-point operations are not equal to ``NaN`` and
1496-
``Inf``, and
1497-
* ``+0`` and ``-0`` are interchangeable.
1497+
* No ``NaN`` or infinite values will be operands or results of
1498+
floating-point operations,
1499+
* ``+0`` and ``-0`` may be treated as interchangeable.
14981500

14991501
``-ffast-math`` also defines the ``__FAST_MATH__`` preprocessor
15001502
macro. Some math libraries recognize this macro and change their behavior.
@@ -1753,7 +1755,7 @@ for more details.
17531755
Specify floating point behavior. ``-ffp-model`` is an umbrella
17541756
option that encompasses functionality provided by other, single
17551757
purpose, floating point options. Valid values are: ``precise``, ``strict``,
1756-
and ``fast``.
1758+
``fast``, and ``aggressive``.
17571759
Details:
17581760

17591761
* ``precise`` Disables optimizations that are not value-safe on
@@ -1766,7 +1768,10 @@ for more details.
17661768
``STDC FENV_ACCESS``: by default ``FENV_ACCESS`` is disabled. This option
17671769
setting behaves as though ``#pragma STDC FENV_ACCESS ON`` appeared at the
17681770
top of the source file.
1769-
* ``fast`` Behaves identically to specifying both ``-ffast-math`` and
1771+
* ``fast`` Behaves identically to specifying ``-funsafe-math-optimizations``,
1772+
``-fno-math-errno`` and ``-fcomplex-arithmetic=promoted``
1773+
``ffp-contract=fast``
1774+
* ``aggressive`` Behaves identically to specifying both ``-ffast-math`` and
17701775
``ffp-contract=fast``
17711776

17721777
Note: If your command line specifies multiple instances

clang/include/clang/AST/Expr.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3888,6 +3888,7 @@ class BinaryOperator : public Expr {
38883888
/// Construct an empty binary operator.
38893889
explicit BinaryOperator(EmptyShell Empty) : Expr(BinaryOperatorClass, Empty) {
38903890
BinaryOperatorBits.Opc = BO_Comma;
3891+
BinaryOperatorBits.ExcludedOverflowPattern = false;
38913892
}
38923893

38933894
public:
@@ -4043,6 +4044,15 @@ class BinaryOperator : public Expr {
40434044
void setHasStoredFPFeatures(bool B) { BinaryOperatorBits.HasFPFeatures = B; }
40444045
bool hasStoredFPFeatures() const { return BinaryOperatorBits.HasFPFeatures; }
40454046

4047+
/// Set and get the bit that informs arithmetic overflow sanitizers whether
4048+
/// or not they should exclude certain BinaryOperators from instrumentation
4049+
void setExcludedOverflowPattern(bool B) {
4050+
BinaryOperatorBits.ExcludedOverflowPattern = B;
4051+
}
4052+
bool hasExcludedOverflowPattern() const {
4053+
return BinaryOperatorBits.ExcludedOverflowPattern;
4054+
}
4055+
40464056
/// Get FPFeatures from trailing storage
40474057
FPOptionsOverride getStoredFPFeatures() const {
40484058
assert(hasStoredFPFeatures());

clang/include/clang/AST/OpenMPClause.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ class OMPOneStmtClause : public Base {
191191
};
192192

193193
/// Class that handles pre-initialization statement for some clauses, like
194-
/// 'shedule', 'firstprivate' etc.
194+
/// 'schedule', 'firstprivate' etc.
195195
class OMPClauseWithPreInit {
196196
friend class OMPClauseReader;
197197

clang/include/clang/AST/Stmt.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,11 @@ class alignas(void *) Stmt {
650650
LLVM_PREFERRED_TYPE(bool)
651651
unsigned HasFPFeatures : 1;
652652

653+
/// Whether or not this BinaryOperator should be excluded from integer
654+
/// overflow sanitization.
655+
LLVM_PREFERRED_TYPE(bool)
656+
unsigned ExcludedOverflowPattern : 1;
657+
653658
SourceLocation OpLoc;
654659
};
655660

clang/include/clang/ASTMatchers/ASTMatchers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6027,7 +6027,7 @@ AST_POLYMORPHIC_MATCHER_P2(
60276027
internal::Matcher<Expr>, Matcher1, internal::Matcher<Expr>, Matcher2) {
60286028
return internal::VariadicDynCastAllOfMatcher<Stmt, NodeType>()(
60296029
anyOf(allOf(hasLHS(Matcher1), hasRHS(Matcher2)),
6030-
allOf(hasLHS(Matcher2), hasRHS(Matcher1))))
6030+
allOf(hasRHS(Matcher1), hasLHS(Matcher2))))
60316031
.matches(Node, Finder, Builder);
60326032
}
60336033

clang/include/clang/Basic/Builtins.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4745,6 +4745,12 @@ def HLSLRSqrt : LangBuiltin<"HLSL_LANG"> {
47454745
let Prototype = "void(...)";
47464746
}
47474747

4748+
def HLSLSaturate : LangBuiltin<"HLSL_LANG"> {
4749+
let Spellings = ["__builtin_hlsl_elementwise_saturate"];
4750+
let Attributes = [NoThrow, Const];
4751+
let Prototype = "void(...)";
4752+
}
4753+
47484754
// Builtins for XRay.
47494755
def XRayCustomEvent : Builtin {
47504756
let Spellings = ["__xray_customevent"];

clang/include/clang/Basic/CodeGenOptions.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ CODEGENOPT(MergeAllConstants , 1, 1) ///< Merge identical constants.
176176
CODEGENOPT(MergeFunctions , 1, 0) ///< Set when -fmerge-functions is enabled.
177177
CODEGENOPT(NoCommon , 1, 0) ///< Set when -fno-common or C++ is enabled.
178178
CODEGENOPT(NoExecStack , 1, 0) ///< Set when -Wa,--noexecstack is enabled.
179+
CODEGENOPT(MipsMsa , 1, 0) ///< Set when -Wa,-mmsa is enabled.
179180
CODEGENOPT(FatalWarnings , 1, 0) ///< Set when -Wa,--fatal-warnings is
180181
///< enabled.
181182
CODEGENOPT(NoWarn , 1, 0) ///< Set when -Wa,--no-warn is enabled.

clang/include/clang/Basic/LangOptions.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,21 @@ class LangOptionsBase {
367367
PerThread,
368368
};
369369

370+
/// Exclude certain code patterns from being instrumented by arithmetic
371+
/// overflow sanitizers
372+
enum OverflowPatternExclusionKind {
373+
/// Don't exclude any overflow patterns from sanitizers
374+
None = 1 << 0,
375+
/// Exclude all overflow patterns (below)
376+
All = 1 << 1,
377+
/// if (a + b < a)
378+
AddOverflowTest = 1 << 2,
379+
/// -1UL
380+
NegUnsignedConst = 1 << 3,
381+
/// while (count--)
382+
PostDecrInWhile = 1 << 4,
383+
};
384+
370385
enum class DefaultVisiblityExportMapping {
371386
None,
372387
/// map only explicit default visibilities to exported
@@ -555,6 +570,11 @@ class LangOptions : public LangOptionsBase {
555570
/// The default stream kind used for HIP kernel launching.
556571
GPUDefaultStreamKind GPUDefaultStream;
557572

573+
/// Which overflow patterns should be excluded from sanitizer instrumentation
574+
unsigned OverflowPatternExclusionMask = 0;
575+
576+
std::vector<std::string> OverflowPatternExclusionValues;
577+
558578
/// The seed used by the randomize structure layout feature.
559579
std::string RandstructSeed;
560580

@@ -630,6 +650,14 @@ class LangOptions : public LangOptionsBase {
630650
return MSCompatibilityVersion >= MajorVersion * 100000U;
631651
}
632652

653+
bool isOverflowPatternExcluded(OverflowPatternExclusionKind Kind) const {
654+
if (OverflowPatternExclusionMask & OverflowPatternExclusionKind::None)
655+
return false;
656+
if (OverflowPatternExclusionMask & OverflowPatternExclusionKind::All)
657+
return true;
658+
return OverflowPatternExclusionMask & Kind;
659+
}
660+
633661
/// Reset all of the options that are not considered when building a
634662
/// module.
635663
void resetNonModularOptions();

clang/include/clang/Driver/Options.td

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2570,6 +2570,11 @@ defm sanitize_stats : BoolOption<"f", "sanitize-stats",
25702570
"Disable">,
25712571
BothFlags<[], [ClangOption], " sanitizer statistics gathering.">>,
25722572
Group<f_clang_Group>;
2573+
def fsanitize_undefined_ignore_overflow_pattern_EQ : CommaJoined<["-"], "fsanitize-undefined-ignore-overflow-pattern=">,
2574+
HelpText<"Specify the overflow patterns to exclude from artihmetic sanitizer instrumentation">,
2575+
Visibility<[ClangOption, CC1Option]>,
2576+
Values<"none,all,add-overflow-test,negated-unsigned-const,post-decr-while">,
2577+
MarshallingInfoStringVector<LangOpts<"OverflowPatternExclusionValues">>;
25732578
def fsanitize_thread_memory_access : Flag<["-"], "fsanitize-thread-memory-access">,
25742579
Group<f_clang_Group>,
25752580
HelpText<"Enable memory access instrumentation in ThreadSanitizer (default)">;
@@ -5487,7 +5492,9 @@ def mmadd4 : Flag<["-"], "mmadd4">, Group<m_mips_Features_Group>,
54875492
def mno_madd4 : Flag<["-"], "mno-madd4">, Group<m_mips_Features_Group>,
54885493
HelpText<"Disable the generation of 4-operand madd.s, madd.d and related instructions.">;
54895494
def mmsa : Flag<["-"], "mmsa">, Group<m_mips_Features_Group>,
5490-
HelpText<"Enable MSA ASE (MIPS only)">;
5495+
Visibility<[ClangOption, CC1Option, CC1AsOption]>,
5496+
HelpText<"Enable MSA ASE (MIPS only)">,
5497+
MarshallingInfoFlag<CodeGenOpts<"MipsMsa">>;
54915498
def mno_msa : Flag<["-"], "mno-msa">, Group<m_mips_Features_Group>,
54925499
HelpText<"Disable MSA ASE (MIPS only)">;
54935500
def mmt : Flag<["-"], "mmt">, Group<m_mips_Features_Group>,

clang/include/clang/Driver/SanitizerArgs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class SanitizerArgs {
3333
std::vector<std::string> BinaryMetadataIgnorelistFiles;
3434
int CoverageFeatures = 0;
3535
int BinaryMetadataFeatures = 0;
36+
int OverflowPatternExclusions = 0;
3637
int MsanTrackOrigins = 0;
3738
bool MsanUseAfterDtor = true;
3839
bool MsanParamRetval = true;

0 commit comments

Comments
 (0)