Skip to content

Commit 989e0b1

Browse files
author
z1.cciauto
committed
merge main into amd-staging
2 parents 14d0d8a + 39c3066 commit 989e0b1

File tree

93 files changed

+1825
-996
lines changed

Some content is hidden

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

93 files changed

+1825
-996
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ bool isCompleteAndHasNoZeroValue(const EnumDecl *D) {
2222
const EnumDecl *Definition = D->getDefinition();
2323
return Definition && Definition->isComplete() &&
2424
!Definition->enumerators().empty() &&
25-
std::none_of(Definition->enumerator_begin(),
26-
Definition->enumerator_end(),
27-
[](const EnumConstantDecl *Value) {
28-
return Value->getInitVal().isZero();
29-
});
25+
llvm::none_of(Definition->enumerators(),
26+
[](const EnumConstantDecl *Value) {
27+
return Value->getInitVal().isZero();
28+
});
3029
}
3130

3231
AST_MATCHER(EnumDecl, isCompleteAndHasNoZeroValue) {

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ namespace {
2222
AST_MATCHER(EnumDecl, isCompleteAndHasNoZeroValue) {
2323
const EnumDecl *Definition = Node.getDefinition();
2424
return Definition && Node.isComplete() &&
25-
std::none_of(Definition->enumerator_begin(),
26-
Definition->enumerator_end(),
27-
[](const EnumConstantDecl *Value) {
28-
return Value->getInitVal().isZero();
29-
});
25+
llvm::none_of(Definition->enumerators(),
26+
[](const EnumConstantDecl *Value) {
27+
return Value->getInitVal().isZero();
28+
});
3029
}
3130

3231
} // namespace

clang/docs/LanguageExtensions.rst

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,7 +2015,7 @@ even if there is no valid ``std::tuple_element`` specialization or suitable
20152015
Blocks
20162016
======
20172017

2018-
The syntax and high level language feature description is in
2018+
The syntax and high-level language feature description is in
20192019
:doc:`BlockLanguageSpec<BlockLanguageSpec>`. Implementation and ABI details for
20202020
the clang implementation are in :doc:`Block-ABI-Apple<Block-ABI-Apple>`.
20212021

@@ -2085,7 +2085,7 @@ producing an object with the following member functions
20852085
constexpr size_t size() const;
20862086

20872087
such as ``std::string``, ``std::string_view``, ``std::vector<char>``.
2088-
This mechanism follow the same rules as ``static_assert`` messages in
2088+
This mechanism follows the same rules as ``static_assert`` messages in
20892089
C++26, see ``[dcl.pre]/p12``.
20902090

20912091
Query for this feature with ``__has_extension(gnu_asm_constexpr_strings)``.
@@ -2332,7 +2332,7 @@ Objective-C Autosynthesis of Properties
23322332
23332333
Clang provides support for autosynthesis of declared properties. Using this
23342334
feature, clang provides default synthesis of those properties not declared
2335-
@dynamic and not having user provided backing getter and setter methods.
2335+
@dynamic and not having user-provided backing getter and setter methods.
23362336
``__has_feature(objc_default_synthesize_properties)`` checks for availability
23372337
of this feature in version of clang being used.
23382338
@@ -2346,7 +2346,7 @@ In Objective-C, functions and methods are generally assumed to follow the
23462346
<https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html>`_
23472347
conventions for ownership of object arguments and
23482348
return values. However, there are exceptions, and so Clang provides attributes
2349-
to allow these exceptions to be documented. This are used by ARC and the
2349+
to allow these exceptions to be documented. These are used by ARC and the
23502350
`static analyzer <https://clang-analyzer.llvm.org>`_ Some exceptions may be
23512351
better described using the ``objc_method_family`` attribute instead.
23522352
@@ -2572,7 +2572,7 @@ Such functionality is not conformant and does not guarantee to compile
25722572
correctly in any circumstances. It can be used if:
25732573
25742574
- the kernel source does not contain call expressions to (member-) function
2575-
pointers, or virtual functions. For example this extension can be used in
2575+
pointers, or virtual functions. For example, this extension can be used in
25762576
metaprogramming algorithms to be able to specify/detect types generically.
25772577
25782578
- the generated kernel binary does not contain indirect calls because they
@@ -2610,7 +2610,7 @@ functions with variadic prototypes do not get generated in binary e.g. the
26102610
variadic prototype is used to specify a function type with any number of
26112611
arguments in metaprogramming algorithms in C++ for OpenCL.
26122612
2613-
This extensions can also be used when the kernel code is intended for targets
2613+
This extension can also be used when the kernel code is intended for targets
26142614
supporting the variadic arguments e.g. majority of CPU targets.
26152615
26162616
**Example of Use**:
@@ -2699,7 +2699,7 @@ address space qualifiers, therefore, other type qualifiers such as
26992699
Legacy 1.x atomics with generic address space
27002700
---------------------------------------------
27012701
2702-
Clang allows use of atomic functions from the OpenCL 1.x standards
2702+
Clang allows the use of atomic functions from the OpenCL 1.x standards
27032703
with the generic address space pointer in C++ for OpenCL mode.
27042704
27052705
This is a non-portable feature and might not be supported by all
@@ -2830,7 +2830,7 @@ to a possibly overlapping destination region. It takes five arguments.
28302830
The first argument is the destination WebAssembly table, and the second
28312831
argument is the source WebAssembly table. The third argument is the
28322832
destination index from where the copy starts, the fourth argument is the
2833-
source index from there the copy starts, and the fifth and last argument
2833+
source index from where the copy starts, and the fifth and last argument
28342834
is the number of elements to copy. It returns nothing.
28352835
28362836
.. code-block:: c++
@@ -3130,7 +3130,7 @@ Query for this feature with ``__has_builtin(__builtin_get_vtable_pointer)``.
31303130
------------------------------------
31313131
31323132
``__builtin_call_with_static_chain`` is used to perform a static call while
3133-
setting updating the static chain register.
3133+
updating the static chain register.
31343134
31353135
**Syntax**:
31363136
@@ -3242,7 +3242,7 @@ Query for this feature with ``__has_builtin(__builtin_readsteadycounter)``.
32423242
The ``__builtin_cpu_supports`` function detects if the run-time CPU supports
32433243
features specified in string argument. It returns a positive integer if all
32443244
features are supported and 0 otherwise. Feature names are target specific. On
3245-
AArch64 features are combined using ``+`` like this
3245+
AArch64, features are combined using ``+`` like this
32463246
``__builtin_cpu_supports("flagm+sha3+lse+rcpc2+fcma+memtag+bti+sme2")``.
32473247
If a feature name is not supported, Clang will issue a warning and replace
32483248
builtin by the constant 0.
@@ -3462,7 +3462,7 @@ Query for this feature with ``__has_builtin(__builtin_convertvector)``.
34623462
**Description**:
34633463
34643464
The '``__builtin_bitreverse``' family of builtins is used to reverse
3465-
the bitpattern of an integer value; for example ``0b10110110`` becomes
3465+
the bitpattern of an integer value; for example, ``0b10110110`` becomes
34663466
``0b01101101``. These builtins can be used within constant expressions.
34673467
34683468
``__builtin_rotateleft``
@@ -3967,7 +3967,7 @@ the debugging experience.
39673967
39683968
``__builtin_allow_runtime_check`` returns true if the check at the current
39693969
program location should be executed. It is expected to be used to implement
3970-
``assert`` like checks which can be safely removed by optimizer.
3970+
``assert`` like checks which can be safely removed by the optimizer.
39713971
39723972
**Syntax**:
39733973

clang/include/clang/Basic/BuiltinsAMDGPU.def

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,12 @@ TARGET_BUILTIN(__builtin_amdgcn_cvt_scale_pk8_bf16_fp4, "V8yUiUiIUi", "nc", "gfx
721721
TARGET_BUILTIN(__builtin_amdgcn_cvt_scale_pk8_f32_fp8, "V8fV2UiUiIUi", "nc", "gfx1250-insts")
722722
TARGET_BUILTIN(__builtin_amdgcn_cvt_scale_pk8_f32_bf8, "V8fV2UiUiIUi", "nc", "gfx1250-insts")
723723
TARGET_BUILTIN(__builtin_amdgcn_cvt_scale_pk8_f32_fp4, "V8fUiUiIUi", "nc", "gfx1250-insts")
724+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scale_pk16_f16_fp6, "V16hV3UiUiIUi", "nc", "gfx1250-insts")
725+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scale_pk16_bf16_fp6, "V16yV3UiUiIUi", "nc", "gfx1250-insts")
726+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scale_pk16_f16_bf6, "V16hV3UiUiIUi", "nc", "gfx1250-insts")
727+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scale_pk16_bf16_bf6, "V16yV3UiUiIUi", "nc", "gfx1250-insts")
728+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scale_pk16_f32_fp6, "V16fV3UiUiIUi", "nc", "gfx1250-insts")
729+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scale_pk16_f32_bf6, "V16fV3UiUiIUi", "nc", "gfx1250-insts")
724730
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_pk8_fp8_bf16, "V2UiV8yf", "nc", "gfx1250-insts")
725731
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_pk8_bf8_bf16, "V2UiV8yf", "nc", "gfx1250-insts")
726732
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_pk8_fp8_f16, "V2UiV8hf", "nc", "gfx1250-insts")

clang/lib/AST/ByteCode/ByteCodeEmitter.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,21 +137,21 @@ int32_t ByteCodeEmitter::getOffset(LabelTy Label) {
137137
template <typename T>
138138
static void emit(Program &P, std::vector<std::byte> &Code, const T &Val,
139139
bool &Success) {
140+
size_t ValPos = Code.size();
140141
size_t Size;
141142

142143
if constexpr (std::is_pointer_v<T>)
143-
Size = sizeof(uint32_t);
144+
Size = align(sizeof(uint32_t));
144145
else
145-
Size = sizeof(T);
146+
Size = align(sizeof(T));
146147

147-
if (Code.size() + Size > std::numeric_limits<unsigned>::max()) {
148+
if (ValPos + Size > std::numeric_limits<unsigned>::max()) {
148149
Success = false;
149150
return;
150151
}
151152

152153
// Access must be aligned!
153-
size_t ValPos = align(Code.size());
154-
Size = align(Size);
154+
assert(aligned(ValPos));
155155
assert(aligned(ValPos + Size));
156156
Code.resize(ValPos + Size);
157157

@@ -168,17 +168,16 @@ static void emit(Program &P, std::vector<std::byte> &Code, const T &Val,
168168
template <typename T>
169169
static void emitSerialized(std::vector<std::byte> &Code, const T &Val,
170170
bool &Success) {
171-
size_t Size = Val.bytesToSerialize();
171+
size_t ValPos = Code.size();
172+
size_t Size = align(Val.bytesToSerialize());
172173

173-
if (Code.size() + Size > std::numeric_limits<unsigned>::max()) {
174+
if (ValPos + Size > std::numeric_limits<unsigned>::max()) {
174175
Success = false;
175176
return;
176177
}
177178

178179
// Access must be aligned!
179-
assert(aligned(Code.size()));
180-
size_t ValPos = Code.size();
181-
Size = align(Size);
180+
assert(aligned(ValPos));
182181
assert(aligned(ValPos + Size));
183182
Code.resize(ValPos + Size);
184183

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,8 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
331331
}
332332

333333
case CK_FloatingToIntegral: {
334+
if (!CE->getType()->isIntegralOrEnumerationType())
335+
return false;
334336
if (!this->visit(SubExpr))
335337
return false;
336338
PrimType ToT = classifyPrim(CE);
@@ -1369,10 +1371,15 @@ bool Compiler<Emitter>::VisitVectorBinOp(const BinaryOperator *E) {
13691371
// BitAdd/BitOr/BitXor/Shl/Shr doesn't support bool type, we need perform the
13701372
// integer promotion.
13711373
bool NeedIntPromot = ElemT == PT_Bool && (E->isBitwiseOp() || E->isShiftOp());
1372-
QualType PromotTy =
1373-
Ctx.getASTContext().getPromotedIntegerType(Ctx.getASTContext().BoolTy);
1374-
PrimType PromotT = classifyPrim(PromotTy);
1375-
PrimType OpT = NeedIntPromot ? PromotT : ElemT;
1374+
QualType PromotTy;
1375+
PrimType PromotT = PT_Bool;
1376+
PrimType OpT = ElemT;
1377+
if (NeedIntPromot) {
1378+
PromotTy =
1379+
Ctx.getASTContext().getPromotedIntegerType(Ctx.getASTContext().BoolTy);
1380+
PromotT = classifyPrim(PromotTy);
1381+
OpT = PromotT;
1382+
}
13761383

13771384
auto getElem = [=](unsigned Offset, PrimType ElemT, unsigned Index) {
13781385
if (!this->emitGetLocal(PT_Ptr, Offset, E))

clang/lib/AST/ByteCode/Descriptor.cpp

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,31 @@
2121
using namespace clang;
2222
using namespace clang::interp;
2323

24+
template <typename T> static constexpr bool needsCtor() {
25+
if constexpr (std::is_same_v<T, Integral<8, true>> ||
26+
std::is_same_v<T, Integral<8, false>> ||
27+
std::is_same_v<T, Integral<16, true>> ||
28+
std::is_same_v<T, Integral<16, false>> ||
29+
std::is_same_v<T, Integral<32, true>> ||
30+
std::is_same_v<T, Integral<32, false>> ||
31+
std::is_same_v<T, Integral<64, true>> ||
32+
std::is_same_v<T, Integral<64, false>> ||
33+
std::is_same_v<T, Boolean>)
34+
return false;
35+
36+
return true;
37+
}
38+
2439
template <typename T>
2540
static void ctorTy(Block *, std::byte *Ptr, bool, bool, bool, bool, bool,
2641
const Descriptor *) {
42+
static_assert(needsCtor<T>());
2743
new (Ptr) T();
2844
}
2945

3046
template <typename T>
3147
static void dtorTy(Block *, std::byte *Ptr, const Descriptor *) {
48+
static_assert(needsCtor<T>());
3249
reinterpret_cast<T *>(Ptr)->~T();
3350
}
3451

@@ -45,9 +62,11 @@ static void ctorArrayTy(Block *, std::byte *Ptr, bool, bool, bool, bool, bool,
4562
const Descriptor *D) {
4663
new (Ptr) InitMapPtr(std::nullopt);
4764

48-
Ptr += sizeof(InitMapPtr);
49-
for (unsigned I = 0, NE = D->getNumElems(); I < NE; ++I) {
50-
new (&reinterpret_cast<T *>(Ptr)[I]) T();
65+
if constexpr (needsCtor<T>()) {
66+
Ptr += sizeof(InitMapPtr);
67+
for (unsigned I = 0, NE = D->getNumElems(); I < NE; ++I) {
68+
new (&reinterpret_cast<T *>(Ptr)[I]) T();
69+
}
5170
}
5271
}
5372

@@ -57,9 +76,12 @@ static void dtorArrayTy(Block *, std::byte *Ptr, const Descriptor *D) {
5776

5877
if (IMP)
5978
IMP = std::nullopt;
60-
Ptr += sizeof(InitMapPtr);
61-
for (unsigned I = 0, NE = D->getNumElems(); I < NE; ++I) {
62-
reinterpret_cast<T *>(Ptr)[I].~T();
79+
80+
if constexpr (needsCtor<T>()) {
81+
Ptr += sizeof(InitMapPtr);
82+
for (unsigned I = 0, NE = D->getNumElems(); I < NE; ++I) {
83+
reinterpret_cast<T *>(Ptr)[I].~T();
84+
}
6385
}
6486
}
6587

@@ -74,10 +96,14 @@ static void moveArrayTy(Block *, std::byte *Src, std::byte *Dst,
7496
}
7597
Src += sizeof(InitMapPtr);
7698
Dst += sizeof(InitMapPtr);
77-
for (unsigned I = 0, NE = D->getNumElems(); I < NE; ++I) {
78-
auto *SrcPtr = &reinterpret_cast<T *>(Src)[I];
79-
auto *DstPtr = &reinterpret_cast<T *>(Dst)[I];
80-
new (DstPtr) T(std::move(*SrcPtr));
99+
if constexpr (!needsCtor<T>()) {
100+
std::memcpy(Dst, Src, D->getNumElems() * D->getElemSize());
101+
} else {
102+
for (unsigned I = 0, NE = D->getNumElems(); I < NE; ++I) {
103+
auto *SrcPtr = &reinterpret_cast<T *>(Src)[I];
104+
auto *DstPtr = &reinterpret_cast<T *>(Dst)[I];
105+
new (DstPtr) T(std::move(*SrcPtr));
106+
}
81107
}
82108
}
83109

clang/lib/AST/ByteCode/InterpState.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,27 +77,27 @@ void InterpState::deallocate(Block *B) {
7777
const Descriptor *Desc = B->getDescriptor();
7878
assert(Desc);
7979

80+
// The block might have a pointer saved in a field in its data
81+
// that points to the block itself. We call the dtor first,
82+
// which will destroy all the data but leave InlineDescriptors
83+
// intact. If the block THEN still has pointers, we create a
84+
// DeadBlock for it.
85+
if (B->IsInitialized)
86+
B->invokeDtor();
87+
8088
if (B->hasPointers()) {
8189
size_t Size = B->getSize();
82-
8390
// Allocate a new block, transferring over pointers.
8491
char *Memory =
8592
reinterpret_cast<char *>(std::malloc(sizeof(DeadBlock) + Size));
8693
auto *D = new (Memory) DeadBlock(DeadBlocks, B);
87-
std::memset(D->B.rawData(), 0, D->B.getSize());
88-
89-
// Move data and metadata from the old block to the new (dead)block.
90-
if (B->IsInitialized && Desc->MoveFn) {
91-
Desc->MoveFn(B, B->data(), D->data(), Desc);
92-
if (Desc->getMetadataSize() > 0)
93-
std::memcpy(D->rawData(), B->rawData(), Desc->getMetadataSize());
94-
}
94+
// Since the block doesn't hold any actual data anymore, we can just
95+
// memcpy() everything over.
96+
std::memcpy(D->rawData(), B->rawData(), Desc->getAllocSize());
9597
D->B.IsInitialized = B->IsInitialized;
9698

9799
// We moved the contents over to the DeadBlock.
98100
B->IsInitialized = false;
99-
} else if (B->IsInitialized) {
100-
B->invokeDtor();
101101
}
102102
}
103103

clang/lib/AST/MicrosoftMangle.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,8 +1298,7 @@ void MicrosoftCXXNameMangler::mangleUnqualifiedName(GlobalDecl GD,
12981298
Name += "<unnamed-type-";
12991299
Name += TND->getName();
13001300
} else if (isa<EnumDecl>(TD) &&
1301-
cast<EnumDecl>(TD)->enumerator_begin() !=
1302-
cast<EnumDecl>(TD)->enumerator_end()) {
1301+
!cast<EnumDecl>(TD)->enumerators().empty()) {
13031302
// Anonymous non-empty enums mangle in the first enumerator.
13041303
auto *ED = cast<EnumDecl>(TD);
13051304
Name += "<unnamed-enum-";

clang/lib/CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -501,11 +501,7 @@ void CIRRecordLowering::accumulateFields() {
501501
fieldEnd = recordDecl->field_end();
502502
field != fieldEnd;) {
503503
if (field->isBitField()) {
504-
RecordDecl::field_iterator start = field;
505-
// Iterate to gather the list of bitfields.
506-
for (++field; field != fieldEnd && field->isBitField(); ++field)
507-
;
508-
field = accumulateBitFields(start, field);
504+
field = accumulateBitFields(field, fieldEnd);
509505
assert((field == fieldEnd || !field->isBitField()) &&
510506
"Failed to accumulate all the bitfields");
511507
} else if (!field->isZeroSize(astContext)) {

0 commit comments

Comments
 (0)