Skip to content

Commit e8ffd65

Browse files
committed
merge main into amd-staging
2 parents 7271c2f + 11857be commit e8ffd65

File tree

389 files changed

+26194
-4087
lines changed

Some content is hidden

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

389 files changed

+26194
-4087
lines changed

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,11 @@ class BinaryFunction {
11741174
return getSecondaryEntryPointSymbol(BB.getLabel());
11751175
}
11761176

1177+
/// Remove a label from the secondary entry point map.
1178+
void removeSymbolFromSecondaryEntryPointMap(const MCSymbol *Label) {
1179+
SecondaryEntryPoints.erase(Label);
1180+
}
1181+
11771182
/// Return true if the basic block is an entry point into the function
11781183
/// (either primary or secondary).
11791184
bool isEntryPoint(const BinaryBasicBlock &BB) const {
@@ -2126,6 +2131,10 @@ class BinaryFunction {
21262131
return Islands && !Islands->DataOffsets.empty();
21272132
}
21282133

2134+
bool isStartOfConstantIsland(uint64_t Offset) const {
2135+
return hasConstantIsland() && Islands->DataOffsets.count(Offset);
2136+
}
2137+
21292138
/// Return true iff the symbol could be seen inside this function otherwise
21302139
/// it is probably another function.
21312140
bool isSymbolValidInScope(const SymbolRef &Symbol, uint64_t SymbolSize) const;

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,6 +1896,15 @@ void BinaryFunction::postProcessEntryPoints() {
18961896
if (BC.isAArch64() && Offset == getSize())
18971897
continue;
18981898

1899+
// If we have grabbed a wrong code label which actually points to some
1900+
// constant island inside the function, ignore this label and remove it
1901+
// from the secondary entry point map.
1902+
if (isStartOfConstantIsland(Offset)) {
1903+
BC.SymbolToFunctionMap.erase(Label);
1904+
removeSymbolFromSecondaryEntryPointMap(Label);
1905+
continue;
1906+
}
1907+
18991908
BC.errs() << "BOLT-WARNING: reference in the middle of instruction "
19001909
"detected in function "
19011910
<< *this << " at offset 0x" << Twine::utohexstr(Offset) << '\n';

bolt/runtime/hugify.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//
77
//===---------------------------------------------------------------------===//
88

9-
#if defined(__x86_64__) || \
10-
(defined(__aarch64__) || defined(__arm64__)) && !defined(__APPLE__)
9+
#if (defined(__x86_64__) || defined(__aarch64__) || defined(__arm64__)) && \
10+
!defined(__APPLE__)
1111

1212
#include "common.h"
1313

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# This test is to verify that BOLT won't take a label pointing to constant
2+
# island as a secondary entry point (function `_start` doesn't have ELF size
3+
# set originally) and the function won't otherwise be mistaken as non-simple.
4+
5+
# RUN: %clang %cflags -pie %s -o %t.so -Wl,-q -Wl,--init=_foo -Wl,--fini=_foo
6+
# RUN: llvm-bolt %t.so -o %t.bolt.so --print-cfg 2>&1 | FileCheck %s
7+
# CHECK-NOT: BOLT-WARNING: reference in the middle of instruction detected \
8+
# CHECK-NOT: function _start at offset 0x{{[0-9a-f]+}}
9+
# CHECK: Binary Function "_start" after building cfg
10+
11+
.text
12+
13+
.global _foo
14+
.type _foo, %function
15+
_foo:
16+
ret
17+
18+
.global _start
19+
.type _start, %function
20+
_start:
21+
b _foo
22+
23+
.balign 16
24+
_random_consts:
25+
.long 0x12345678
26+
.long 0x90abcdef
27+
28+
.global _bar
29+
.type _bar, %function
30+
_bar:
31+
ret
32+
33+
# Dummy relocation to force relocation mode
34+
.reloc 0, R_AARCH64_NONE
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# This test is to verify that BOLT won't take a label pointing to constant
2+
# island as a secondary entry point (function `_start` doesn't have ELF size
3+
# set originally) and the function won't otherwise be mistaken as non-simple.
4+
5+
# RUN: %clang %cflags -pie %s -o %t.so -Wl,-q -Wl,--init=_foo -Wl,--fini=_foo
6+
# RUN: llvm-bolt %t.so -o %t.bolt.so --print-cfg 2>&1 | FileCheck %s
7+
# CHECK-NOT: BOLT-WARNING: reference in the middle of instruction detected \
8+
# CHECK-NOT: function _start at offset 0x{{[0-9a-f]+}}
9+
# CHECK: Binary Function "_start" after building cfg
10+
11+
.text
12+
13+
.global _foo
14+
.type _foo, %function
15+
_foo:
16+
ret
17+
18+
.global _start
19+
.type _start, %function
20+
_start:
21+
j _foo
22+
23+
.balign 16
24+
_random_consts:
25+
.long 0x12345678
26+
.long 0x90abcdef
27+
28+
.global _bar
29+
.type _bar, %function
30+
_bar:
31+
ret
32+
33+
# Dummy relocation to force relocation mode
34+
.reloc 0, R_RISCV_NONE

clang-tools-extra/clangd/ConfigFragment.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ struct Fragment {
347347
/// "IWYU": Include what you use. Insert the owning header for top-level
348348
/// symbols, unless the header is already directly included or the
349349
/// symbol is forward-declared
350-
/// "NeverInsert": Never insert headers
350+
/// "Never": Never insert headers
351351
std::optional<Located<std::string>> HeaderInsertion;
352352
};
353353
CompletionBlock Completion;

clang/cmake/caches/Fuchsia-stage2.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,6 @@ set(LLVM_TOOLCHAIN_TOOLS
459459
llvm-libtool-darwin
460460
llvm-lipo
461461
llvm-ml
462-
llvm-mt
463462
llvm-nm
464463
llvm-objcopy
465464
llvm-objdump
@@ -481,6 +480,10 @@ set(LLVM_TOOLCHAIN_TOOLS
481480
scan-build-py
482481
CACHE STRING "")
483482

483+
if (LLVM_ENABLE_LIBXML2)
484+
list(APPEND LLVM_TOOLCHAIN_TOOLS llvm-mt)
485+
endif()
486+
484487
set(LLVM_Toolchain_DISTRIBUTION_COMPONENTS
485488
bolt
486489
clang

clang/docs/PointerAuthentication.rst

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,52 @@ a number of different tests.
280280
normal interface. This may be true even on targets where pointer
281281
authentication is not enabled by default.
282282

283+
__ptrauth Qualifier
284+
^^^^^^^^^^^^^^^^^^^
285+
286+
``__ptrauth(key, address, discriminator)`` is an extended type
287+
qualifier which causes so-qualified objects to hold pointers signed using the
288+
specified schema rather than the default schema for such types.
289+
290+
In the current implementation in Clang, the qualified type must be a C pointer
291+
type, either to a function or to an object. It currently cannot be an
292+
Objective-C pointer type, a C++ reference type, or a block pointer type; these
293+
restrictions may be lifted in the future.
294+
295+
The qualifier's operands are as follows:
296+
297+
- ``key`` - an expression evaluating to a key value from ``<ptrauth.h>``; must
298+
be a constant expression
299+
300+
- ``address`` - whether to use address diversity (1) or not (0); must be
301+
a constant expression with one of these two values
302+
303+
- ``discriminator`` - a constant discriminator; must be a constant expression
304+
305+
See `Discriminators`_ for more information about discriminators.
306+
307+
Currently the operands must be constant-evaluable even within templates. In the
308+
future this restriction may be lifted to allow value-dependent expressions as
309+
long as they instantiate to a constant expression.
310+
311+
Consistent with the ordinary C/C++ rule for parameters, top-level ``__ptrauth``
312+
qualifiers on a parameter (after parameter type adjustment) are ignored when
313+
deriving the type of the function. The parameter will be passed using the
314+
default ABI for the unqualified pointer type.
315+
316+
If ``x`` is an object of type ``__ptrauth(key, address, discriminator) T``,
317+
then the signing schema of the value stored in ``x`` is a key of ``key`` and
318+
a discriminator determined as follows:
319+
320+
- if ``address`` is 0, then the discriminator is ``discriminator``;
321+
322+
- if ``address`` is 1 and ``discriminator`` is 0, then the discriminator is
323+
``&x``; otherwise
324+
325+
- if ``address`` is 1 and ``discriminator`` is non-zero, then the discriminator
326+
is ``ptrauth_blend_discriminator(&x, discriminator)``; see
327+
`ptrauth_blend_discriminator`_.
328+
283329
``<ptrauth.h>``
284330
~~~~~~~~~~~~~~~
285331

clang/docs/ReleaseNotes.rst

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,6 @@ Non-comprehensive list of changes in this release
195195
- Added `__builtin_elementwise_exp10`.
196196
- For AMDPGU targets, added `__builtin_v_cvt_off_f32_i4` that maps to the `v_cvt_off_f32_i4` instruction.
197197
- Added `__builtin_elementwise_minnum` and `__builtin_elementwise_maxnum`.
198-
- Clang itself now uses split stacks instead of threads for allocating more
199-
stack space when running on Apple AArch64 based platforms. This means that
200-
stack traces of Clang from debuggers, crashes, and profilers may look
201-
different than before.
202198

203199
New Compiler Flags
204200
------------------
@@ -391,6 +387,14 @@ Improvements to Clang's diagnostics
391387
392388
- An error is now emitted when a ``musttail`` call is made to a function marked with the ``not_tail_called`` attribute. (#GH133509).
393389

390+
- ``-Whigher-precisision-for-complex-divison`` warns when:
391+
392+
- The divisor is complex.
393+
- When the complex division happens in a higher precision type due to arithmetic promotion.
394+
- When using the divide and assign operator (``/=``).
395+
396+
Fixes #GH131127
397+
394398
Improvements to Clang's time-trace
395399
----------------------------------
396400

@@ -420,6 +424,9 @@ Bug Fixes in This Version
420424
- Defining an integer literal suffix (e.g., ``LL``) before including
421425
``<stdint.h>`` in a freestanding build no longer causes invalid token pasting
422426
when using the ``INTn_C`` macros. (#GH85995)
427+
- Fixed an assertion failure in the expansion of builtin macros like ``__has_embed()`` with line breaks before the
428+
closing paren. (#GH133574)
429+
- Fixed a crash in error recovery for expressions resolving to templates. (#GH135621)
423430
- Clang no longer accepts invalid integer constants which are too large to fit
424431
into any (standard or extended) integer type when the constant is unevaluated.
425432
Merely forming the token is sufficient to render the program invalid. Code
@@ -475,7 +482,6 @@ Bug Fixes to C++ Support
475482
by template argument deduction.
476483
- Clang is now better at instantiating the function definition after its use inside
477484
of a constexpr lambda. (#GH125747)
478-
- Fixed a local class member function instantiation bug inside dependent lambdas. (#GH59734), (#GH132208)
479485
- Clang no longer crashes when trying to unify the types of arrays with
480486
certain differences in qualifiers (this could happen during template argument
481487
deduction or when building a ternary operator). (#GH97005)
@@ -567,9 +573,11 @@ Arm and AArch64 Support
567573
^^^^^^^^^^^^^^^^^^^^^^^
568574
- For ARM targets, cc1as now considers the FPU's features for the selected CPU or Architecture.
569575
- The ``+nosimd`` attribute is now fully supported for ARM. Previously, this had no effect when being used with
570-
ARM targets, however this will now disable NEON instructions being generated. The ``simd`` option is
576+
ARM targets, however this will now disable NEON instructions being generated. The ``simd`` option is
571577
also now printed when the ``--print-supported-extensions`` option is used.
572578

579+
- Support for __ptrauth type qualifier has been added.
580+
573581
Android Support
574582
^^^^^^^^^^^^^^^
575583

clang/docs/UsersManual.rst

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2301,11 +2301,31 @@ are listed below.
23012301

23022302
When enabled, allows the compiler to assume that each object file
23032303
passed to the linker has been compiled using a unique source file
2304-
name. This is useful for reducing link times when doing ThinLTO
2304+
path. This is useful for reducing link times when doing ThinLTO
23052305
in combination with whole-program devirtualization or CFI.
23062306

2307-
A misuse of this flag will generally result in a duplicate symbol
2308-
error at link time.
2307+
The full source path passed to the compiler must be unique. This
2308+
means that, for example, the following is a usage error:
2309+
2310+
.. code-block:: console
2311+
2312+
$ cd foo
2313+
$ clang -funique-source-file-names -c foo.c
2314+
$ cd ../bar
2315+
$ clang -funique-source-file-names -c foo.c
2316+
$ cd ..
2317+
$ clang foo/foo.o bar/foo.o
2318+
2319+
but this is not:
2320+
2321+
.. code-block:: console
2322+
2323+
$ clang -funique-source-file-names -c foo/foo.c
2324+
$ clang -funique-source-file-names -c bar/foo.c
2325+
$ clang foo/foo.o bar/foo.o
2326+
2327+
A misuse of this flag may result in a duplicate symbol error at
2328+
link time.
23092329

23102330
.. option:: -fforce-emit-vtables
23112331

clang/include/clang/AST/OpenACCClause.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,11 @@ class OpenACCSelfClause final
430430
}
431431

432432
bool isConditionExprClause() const { return HasConditionExpr.has_value(); }
433+
bool isVarListClause() const { return !isConditionExprClause(); }
434+
bool isEmptySelfClause() const {
435+
return (isConditionExprClause() && !hasConditionExpr()) ||
436+
(!isConditionExprClause() && getVarList().empty());
437+
}
433438

434439
bool hasConditionExpr() const {
435440
assert(HasConditionExpr.has_value() &&

clang/include/clang/AST/Type.h

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,12 @@ class PointerAuthQualifier {
312312
return Result;
313313
}
314314

315+
std::string getAsString() const;
316+
std::string getAsString(const PrintingPolicy &Policy) const;
317+
318+
bool isEmptyWhenPrinted(const PrintingPolicy &Policy) const;
319+
void print(raw_ostream &OS, const PrintingPolicy &Policy) const;
320+
315321
void Profile(llvm::FoldingSetNodeID &ID) const { ID.AddInteger(Data); }
316322
};
317323

@@ -562,7 +568,7 @@ class Qualifiers {
562568

563569
bool hasAddressSpace() const { return Mask & AddressSpaceMask; }
564570
LangAS getAddressSpace() const {
565-
return static_cast<LangAS>(Mask >> AddressSpaceShift);
571+
return static_cast<LangAS>((Mask & AddressSpaceMask) >> AddressSpaceShift);
566572
}
567573
bool hasTargetSpecificAddressSpace() const {
568574
return isTargetAddressSpace(getAddressSpace());
@@ -803,17 +809,18 @@ class Qualifiers {
803809
static_assert(sizeof(PointerAuthQualifier) == sizeof(uint32_t),
804810
"PointerAuthQualifier must be 32 bits");
805811

812+
static constexpr uint64_t PtrAuthShift = 32;
813+
static constexpr uint64_t PtrAuthMask = UINT64_C(0xffffffff) << PtrAuthShift;
814+
806815
static constexpr uint64_t UMask = 0x8;
807816
static constexpr uint64_t UShift = 3;
808817
static constexpr uint64_t GCAttrMask = 0x30;
809818
static constexpr uint64_t GCAttrShift = 4;
810819
static constexpr uint64_t LifetimeMask = 0x1C0;
811820
static constexpr uint64_t LifetimeShift = 6;
812821
static constexpr uint64_t AddressSpaceMask =
813-
~(CVRMask | UMask | GCAttrMask | LifetimeMask);
822+
~(CVRMask | UMask | GCAttrMask | LifetimeMask | PtrAuthMask);
814823
static constexpr uint64_t AddressSpaceShift = 9;
815-
static constexpr uint64_t PtrAuthShift = 32;
816-
static constexpr uint64_t PtrAuthMask = uint64_t(0xffffffff) << PtrAuthShift;
817824
};
818825

819826
class QualifiersAndAtomic {
@@ -1449,6 +1456,12 @@ class QualType {
14491456
return getQualifiers().getPointerAuth();
14501457
}
14511458

1459+
bool hasAddressDiscriminatedPointerAuth() const {
1460+
if (PointerAuthQualifier PtrAuth = getPointerAuth())
1461+
return PtrAuth.isAddressDiscriminated();
1462+
return false;
1463+
}
1464+
14521465
enum PrimitiveDefaultInitializeKind {
14531466
/// The type does not fall into any of the following categories. Note that
14541467
/// this case is zero-valued so that values of this enum can be used as a

0 commit comments

Comments
 (0)