Skip to content

Commit eaa9a12

Browse files
authored
Merge pull request llvm#604 from AMD-Lightning-Internal/upstream_merge_202502110709
merge main into amd-staging
2 parents 245788a + cbb1039 commit eaa9a12

File tree

1,481 files changed

+62974
-72146
lines changed

Some content is hidden

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

1,481 files changed

+62974
-72146
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,11 @@ def warn_arm_interrupt_vfp_clobber : Warning<
350350
InGroup<DiagGroup<"arm-interrupt-vfp-clobber">>;
351351
def err_arm_interrupt_called : Error<
352352
"interrupt service routine cannot be called directly">;
353-
def warn_interrupt_attribute_invalid : Warning<
354-
"%select{MIPS|MSP430|RISC-V}0 'interrupt' attribute only applies to "
355-
"functions that have %select{no parameters|a 'void' return type}1">,
356-
InGroup<IgnoredAttributes>;
353+
def warn_interrupt_signal_attribute_invalid : Warning<
354+
"%select{MIPS|MSP430|RISC-V|AVR}0 '%select{interrupt|signal}1' "
355+
"attribute only applies to functions that have "
356+
"%select{no parameters|a 'void' return type}2">,
357+
InGroup<IgnoredAttributes>;
357358
def warn_riscv_repeated_interrupt_attribute : Warning<
358359
"repeated RISC-V 'interrupt' attribute">, InGroup<IgnoredAttributes>;
359360
def note_riscv_repeated_interrupt_attribute : Note<

clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class CallDescription {
3535
/// Match calls to functions from the C standard library. This also
3636
/// recognizes builtin variants whose name is derived by adding
3737
/// "__builtin", "__inline" or similar prefixes or suffixes; but only
38-
/// matches functions than are externally visible and are declared either
38+
/// matches functions that are externally visible and are declared either
3939
/// directly within a TU or in the namespace 'std'.
4040
/// For the exact heuristics, see CheckerContext::isCLibraryFunction().
4141
CLibrary,
@@ -152,7 +152,7 @@ class CallDescription {
152152
/// exists only when that is not available, for example, when _only_
153153
/// syntactic check is done on a piece of code.
154154
///
155-
/// Also, StdLibraryFunctionsChecker::Signature is likely a better candicade
155+
/// Also, StdLibraryFunctionsChecker::Signature is likely a better candidate
156156
/// for syntactic only matching if you are writing a new checker. This is
157157
/// handy if a CallDescriptionMap is already there.
158158
///
@@ -233,7 +233,7 @@ template <typename T> class CallDescriptionMap {
233233
/// exists only when that is not available, for example, when _only_
234234
/// syntactic check is done on a piece of code.
235235
///
236-
/// Also, StdLibraryFunctionsChecker::Signature is likely a better candicade
236+
/// Also, StdLibraryFunctionsChecker::Signature is likely a better candidate
237237
/// for syntactic only matching if you are writing a new checker. This is
238238
/// handy if a CallDescriptionMap is already there.
239239
///
@@ -274,7 +274,7 @@ class CallDescriptionSet {
274274
/// exists only when that is not available, for example, when _only_
275275
/// syntactic check is done on a piece of code.
276276
///
277-
/// Also, StdLibraryFunctionsChecker::Signature is likely a better candicade
277+
/// Also, StdLibraryFunctionsChecker::Signature is likely a better candidate
278278
/// for syntactic only matching if you are writing a new checker. This is
279279
/// handy if a CallDescriptionMap is already there.
280280
///

clang/lib/Headers/avx10_2convertintrin.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,13 @@ static __inline__ __m256i __DEFAULT_FN_ATTRS256 _mm256_cvt2ph_bf8(__m256h __A,
260260
static __inline__ __m256i __DEFAULT_FN_ATTRS256
261261
_mm256_mask_cvt2ph_bf8(__m256i __W, __mmask32 __U, __m256h __A, __m256h __B) {
262262
return (__m256i)__builtin_ia32_selectb_256(
263-
(__mmask16)__U, (__v32qi)_mm256_cvt2ph_bf8(__A, __B), (__v32qi)__W);
263+
(__mmask32)__U, (__v32qi)_mm256_cvt2ph_bf8(__A, __B), (__v32qi)__W);
264264
}
265265

266266
static __inline__ __m256i __DEFAULT_FN_ATTRS256
267267
_mm256_maskz_cvt2ph_bf8(__mmask32 __U, __m256h __A, __m256h __B) {
268268
return (__m256i)__builtin_ia32_selectb_256(
269-
(__mmask16)__U, (__v32qi)_mm256_cvt2ph_bf8(__A, __B),
269+
(__mmask32)__U, (__v32qi)_mm256_cvt2ph_bf8(__A, __B),
270270
(__v32qi)(__m256i)_mm256_setzero_si256());
271271
}
272272

@@ -297,13 +297,13 @@ _mm256_cvts2ph_bf8(__m256h __A, __m256h __B) {
297297
static __inline__ __m256i __DEFAULT_FN_ATTRS256
298298
_mm256_mask_cvts2ph_bf8(__m256i __W, __mmask32 __U, __m256h __A, __m256h __B) {
299299
return (__m256i)__builtin_ia32_selectb_256(
300-
(__mmask16)__U, (__v32qi)_mm256_cvts2ph_bf8(__A, __B), (__v32qi)__W);
300+
(__mmask32)__U, (__v32qi)_mm256_cvts2ph_bf8(__A, __B), (__v32qi)__W);
301301
}
302302

303303
static __inline__ __m256i __DEFAULT_FN_ATTRS256
304304
_mm256_maskz_cvts2ph_bf8(__mmask32 __U, __m256h __A, __m256h __B) {
305305
return (__m256i)__builtin_ia32_selectb_256(
306-
(__mmask16)__U, (__v32qi)_mm256_cvts2ph_bf8(__A, __B),
306+
(__mmask32)__U, (__v32qi)_mm256_cvts2ph_bf8(__A, __B),
307307
(__v32qi)(__m256i)_mm256_setzero_si256());
308308
}
309309

@@ -334,13 +334,13 @@ static __inline__ __m256i __DEFAULT_FN_ATTRS256 _mm256_cvt2ph_hf8(__m256h __A,
334334
static __inline__ __m256i __DEFAULT_FN_ATTRS256
335335
_mm256_mask_cvt2ph_hf8(__m256i __W, __mmask32 __U, __m256h __A, __m256h __B) {
336336
return (__m256i)__builtin_ia32_selectb_256(
337-
(__mmask16)__U, (__v32qi)_mm256_cvt2ph_hf8(__A, __B), (__v32qi)__W);
337+
(__mmask32)__U, (__v32qi)_mm256_cvt2ph_hf8(__A, __B), (__v32qi)__W);
338338
}
339339

340340
static __inline__ __m256i __DEFAULT_FN_ATTRS256
341341
_mm256_maskz_cvt2ph_hf8(__mmask32 __U, __m256h __A, __m256h __B) {
342342
return (__m256i)__builtin_ia32_selectb_256(
343-
(__mmask16)__U, (__v32qi)_mm256_cvt2ph_hf8(__A, __B),
343+
(__mmask32)__U, (__v32qi)_mm256_cvt2ph_hf8(__A, __B),
344344
(__v32qi)(__m256i)_mm256_setzero_si256());
345345
}
346346

@@ -371,13 +371,13 @@ _mm256_cvts2ph_hf8(__m256h __A, __m256h __B) {
371371
static __inline__ __m256i __DEFAULT_FN_ATTRS256
372372
_mm256_mask_cvts2ph_hf8(__m256i __W, __mmask32 __U, __m256h __A, __m256h __B) {
373373
return (__m256i)__builtin_ia32_selectb_256(
374-
(__mmask16)__U, (__v32qi)_mm256_cvts2ph_hf8(__A, __B), (__v32qi)__W);
374+
(__mmask32)__U, (__v32qi)_mm256_cvts2ph_hf8(__A, __B), (__v32qi)__W);
375375
}
376376

377377
static __inline__ __m256i __DEFAULT_FN_ATTRS256
378378
_mm256_maskz_cvts2ph_hf8(__mmask32 __U, __m256h __A, __m256h __B) {
379379
return (__m256i)__builtin_ia32_selectb_256(
380-
(__mmask16)__U, (__v32qi)_mm256_cvts2ph_hf8(__A, __B),
380+
(__mmask32)__U, (__v32qi)_mm256_cvts2ph_hf8(__A, __B),
381381
(__v32qi)(__m256i)_mm256_setzero_si256());
382382
}
383383

clang/lib/Sema/HeuristicResolver.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,11 @@ QualType HeuristicResolverImpl::simplifyType(QualType Type, const Expr *E,
247247
}
248248
return T;
249249
};
250-
while (!Type.isNull()) {
250+
// As an additional protection against infinite loops, bound the number of
251+
// simplification steps.
252+
size_t StepCount = 0;
253+
const size_t MaxSteps = 64;
254+
while (!Type.isNull() && StepCount++ < MaxSteps) {
251255
QualType New = SimplifyOneStep(Type);
252256
if (New == Type)
253257
break;

clang/lib/Sema/SemaAVR.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ void SemaAVR::handleInterruptAttr(Decl *D, const ParsedAttr &AL) {
3030
if (!AL.checkExactlyNumArgs(SemaRef, 0))
3131
return;
3232

33+
// AVR interrupt handlers must have no parameter and be void type.
34+
if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) {
35+
Diag(D->getLocation(), diag::warn_interrupt_signal_attribute_invalid)
36+
<< /*AVR*/ 3 << /*interrupt*/ 0 << 0;
37+
return;
38+
}
39+
if (!getFunctionOrMethodResultType(D)->isVoidType()) {
40+
Diag(D->getLocation(), diag::warn_interrupt_signal_attribute_invalid)
41+
<< /*AVR*/ 3 << /*interrupt*/ 0 << 1;
42+
return;
43+
}
44+
3345
handleSimpleAttribute<AVRInterruptAttr>(*this, D, AL);
3446
}
3547

@@ -43,6 +55,18 @@ void SemaAVR::handleSignalAttr(Decl *D, const ParsedAttr &AL) {
4355
if (!AL.checkExactlyNumArgs(SemaRef, 0))
4456
return;
4557

58+
// AVR signal handlers must have no parameter and be void type.
59+
if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) {
60+
Diag(D->getLocation(), diag::warn_interrupt_signal_attribute_invalid)
61+
<< /*AVR*/ 3 << /*signal*/ 1 << 0;
62+
return;
63+
}
64+
if (!getFunctionOrMethodResultType(D)->isVoidType()) {
65+
Diag(D->getLocation(), diag::warn_interrupt_signal_attribute_invalid)
66+
<< /*AVR*/ 3 << /*signal*/ 1 << 1;
67+
return;
68+
}
69+
4670
handleSimpleAttribute<AVRSignalAttr>(*this, D, AL);
4771
}
4872

clang/lib/Sema/SemaHLSL.cpp

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,11 @@ static bool isZeroSizedArray(const ConstantArrayType *CAT) {
269269
return CAT != nullptr;
270270
}
271271

272-
// Returns true if the record type is an HLSL resource class
273-
static bool isResourceRecordType(const Type *Ty) {
272+
// Returns true if the record type is an HLSL resource class or an array of
273+
// resource classes
274+
static bool isResourceRecordTypeOrArrayOf(const Type *Ty) {
275+
while (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(Ty))
276+
Ty = CAT->getArrayElementTypeNoTypeQual();
274277
return HLSLAttributedResourceType::findHandleTypeOnResource(Ty) != nullptr;
275278
}
276279

@@ -279,15 +282,15 @@ static bool isResourceRecordType(const Type *Ty) {
279282
// array, or a builtin intangible type. Returns false it is a valid leaf element
280283
// type or if it is a record type that needs to be inspected further.
281284
static bool isInvalidConstantBufferLeafElementType(const Type *Ty) {
282-
if (Ty->isRecordType()) {
283-
if (isResourceRecordType(Ty) || Ty->getAsCXXRecordDecl()->isEmpty())
284-
return true;
285-
return false;
286-
}
285+
Ty = Ty->getUnqualifiedDesugaredType();
286+
if (isResourceRecordTypeOrArrayOf(Ty))
287+
return true;
288+
if (Ty->isRecordType())
289+
return Ty->getAsCXXRecordDecl()->isEmpty();
287290
if (Ty->isConstantArrayType() &&
288291
isZeroSizedArray(cast<ConstantArrayType>(Ty)))
289292
return true;
290-
if (Ty->isHLSLBuiltinIntangibleType())
293+
if (Ty->isHLSLBuiltinIntangibleType() || Ty->isHLSLAttributedResourceType())
291294
return true;
292295
return false;
293296
}
@@ -339,7 +342,7 @@ static IdentifierInfo *getHostLayoutStructName(Sema &S, NamedDecl *BaseDecl,
339342
ASTContext &AST = S.getASTContext();
340343

341344
IdentifierInfo *NameBaseII = BaseDecl->getIdentifier();
342-
llvm::SmallString<64> Name("__layout_");
345+
llvm::SmallString<64> Name("__cblayout_");
343346
if (NameBaseII) {
344347
Name.append(NameBaseII->getName());
345348
} else {
@@ -393,7 +396,7 @@ static FieldDecl *createFieldForHostLayoutStruct(Sema &S, const Type *Ty,
393396
auto *Field = FieldDecl::Create(AST, LayoutStruct, SourceLocation(),
394397
SourceLocation(), II, QT, TSI, nullptr, false,
395398
InClassInitStyle::ICIS_NoInit);
396-
Field->setAccess(AccessSpecifier::AS_private);
399+
Field->setAccess(AccessSpecifier::AS_public);
397400
return Field;
398401
}
399402

@@ -417,9 +420,11 @@ static CXXRecordDecl *createHostLayoutStruct(Sema &S,
417420
if (CXXRecordDecl *RD = findRecordDeclInContext(II, DC))
418421
return RD;
419422

420-
CXXRecordDecl *LS = CXXRecordDecl::Create(
421-
AST, TagDecl::TagKind::Class, DC, SourceLocation(), SourceLocation(), II);
423+
CXXRecordDecl *LS =
424+
CXXRecordDecl::Create(AST, TagDecl::TagKind::Struct, DC, SourceLocation(),
425+
SourceLocation(), II);
422426
LS->setImplicit(true);
427+
LS->addAttr(PackedAttr::CreateImplicit(AST));
423428
LS->startDefinition();
424429

425430
// copy base struct, create HLSL Buffer compatible version if needed
@@ -461,25 +466,27 @@ static CXXRecordDecl *createHostLayoutStruct(Sema &S,
461466

462467
// Creates host layout struct for HLSL Buffer. The struct will include only
463468
// fields of types that are allowed in HLSL buffer and it will filter out:
464-
// - static variable declarations
469+
// - static or groupshared variable declarations
465470
// - resource classes
466471
// - empty structs
467472
// - zero-sized arrays
468473
// - non-variable declarations
469-
// The layour struct will be added to the HLSLBufferDecl declarations.
474+
// The layout struct will be added to the HLSLBufferDecl declarations.
470475
void createHostLayoutStructForBuffer(Sema &S, HLSLBufferDecl *BufDecl) {
471476
ASTContext &AST = S.getASTContext();
472477
IdentifierInfo *II = getHostLayoutStructName(S, BufDecl, true);
473478

474479
CXXRecordDecl *LS =
475-
CXXRecordDecl::Create(AST, TagDecl::TagKind::Class, BufDecl,
480+
CXXRecordDecl::Create(AST, TagDecl::TagKind::Struct, BufDecl,
476481
SourceLocation(), SourceLocation(), II);
482+
LS->addAttr(PackedAttr::CreateImplicit(AST));
477483
LS->setImplicit(true);
478484
LS->startDefinition();
479485

480486
for (Decl *D : BufDecl->decls()) {
481487
VarDecl *VD = dyn_cast<VarDecl>(D);
482-
if (!VD || VD->getStorageClass() == SC_Static)
488+
if (!VD || VD->getStorageClass() == SC_Static ||
489+
VD->getType().getAddressSpace() == LangAS::hlsl_groupshared)
483490
continue;
484491
const Type *Ty = VD->getType()->getUnqualifiedDesugaredType();
485492
if (FieldDecl *FD =

clang/lib/Sema/SemaInit.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4576,7 +4576,9 @@ static void TryConstructorInitialization(Sema &S,
45764576
if (!IsListInit &&
45774577
(Kind.getKind() == InitializationKind::IK_Default ||
45784578
Kind.getKind() == InitializationKind::IK_Direct) &&
4579-
DestRecordDecl != nullptr && DestRecordDecl->isAggregate() &&
4579+
DestRecordDecl != nullptr &&
4580+
!(CtorDecl->isCopyOrMoveConstructor() && CtorDecl->isImplicit()) &&
4581+
DestRecordDecl->isAggregate() &&
45804582
DestRecordDecl->hasUninitializedExplicitInitFields()) {
45814583
S.Diag(Kind.getLocation(), diag::warn_field_requires_explicit_init)
45824584
<< /* Var-in-Record */ 1 << DestRecordDecl;

clang/lib/Sema/SemaMIPS.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,14 +271,14 @@ void SemaMIPS::handleInterruptAttr(Decl *D, const ParsedAttr &AL) {
271271
}
272272

273273
if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) {
274-
Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid)
275-
<< /*MIPS*/ 0 << 0;
274+
Diag(D->getLocation(), diag::warn_interrupt_signal_attribute_invalid)
275+
<< /*MIPS*/ 0 << /*interrupt*/ 0 << 0;
276276
return;
277277
}
278278

279279
if (!getFunctionOrMethodResultType(D)->isVoidType()) {
280-
Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid)
281-
<< /*MIPS*/ 0 << 1;
280+
Diag(D->getLocation(), diag::warn_interrupt_signal_attribute_invalid)
281+
<< /*MIPS*/ 0 << /*interrupt*/ 0 << 1;
282282
return;
283283
}
284284

clang/lib/Sema/SemaMSP430.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ void SemaMSP430::handleInterruptAttr(Decl *D, const ParsedAttr &AL) {
3232
}
3333

3434
if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) {
35-
Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid)
36-
<< /*MSP430*/ 1 << 0;
35+
Diag(D->getLocation(), diag::warn_interrupt_signal_attribute_invalid)
36+
<< /*MSP430*/ 1 << /*interrupt*/ 0 << 0;
3737
return;
3838
}
3939

4040
if (!getFunctionOrMethodResultType(D)->isVoidType()) {
41-
Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid)
42-
<< /*MSP430*/ 1 << 1;
41+
Diag(D->getLocation(), diag::warn_interrupt_signal_attribute_invalid)
42+
<< /*MSP430*/ 1 << /*interrupt*/ 0 << 1;
4343
return;
4444
}
4545

clang/lib/Sema/SemaRISCV.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,14 +1457,14 @@ void SemaRISCV::handleInterruptAttr(Decl *D, const ParsedAttr &AL) {
14571457
}
14581458

14591459
if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) {
1460-
Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid)
1461-
<< /*RISC-V*/ 2 << 0;
1460+
Diag(D->getLocation(), diag::warn_interrupt_signal_attribute_invalid)
1461+
<< /*RISC-V*/ 2 << /*interrupt*/ 0 << 0;
14621462
return;
14631463
}
14641464

14651465
if (!getFunctionOrMethodResultType(D)->isVoidType()) {
1466-
Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid)
1467-
<< /*RISC-V*/ 2 << 1;
1466+
Diag(D->getLocation(), diag::warn_interrupt_signal_attribute_invalid)
1467+
<< /*RISC-V*/ 2 << /*interrupt*/ 0 << 1;
14681468
return;
14691469
}
14701470

0 commit comments

Comments
 (0)