Skip to content

Commit 30d0d09

Browse files
authored
Merge branch 'main' into x86-demandedelts-vpermv-vpermv3
2 parents ff5f298 + 91f3965 commit 30d0d09

File tree

412 files changed

+14711
-9218
lines changed

Some content is hidden

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

412 files changed

+14711
-9218
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ Non-comprehensive list of changes in this release
167167

168168
- Support parsing the `cc` operand modifier and alias it to the `c` modifier (#GH127719).
169169
- Added `__builtin_elementwise_exp10`.
170+
- For AMDPGU targets, added `__builtin_v_cvt_off_f32_i4` that maps to the `v_cvt_off_f32_i4` instruction.
170171

171172
New Compiler Flags
172173
------------------
@@ -189,6 +190,8 @@ Modified Compiler Flags
189190

190191
- The compiler flag `-fbracket-depth` default value is increased from 256 to 2048. (#GH94728)
191192

193+
- `-Wpadded` option implemented for the `x86_64-windows-msvc` target. Fixes #61702
194+
192195
Removed Compiler Flags
193196
-------------------------
194197

@@ -362,6 +365,7 @@ Bug Fixes to Attribute Support
362365
Bug Fixes to C++ Support
363366
^^^^^^^^^^^^^^^^^^^^^^^^
364367

368+
- Clang now supports implicitly defined comparison operators for friend declarations. (#GH132249)
365369
- Clang now diagnoses copy constructors taking the class by value in template instantiations. (#GH130866)
366370
- Clang is now better at keeping track of friend function template instance contexts. (#GH55509)
367371
- Clang now prints the correct instantiation context for diagnostics suppressed

clang/include/clang/AST/ASTContext.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,10 +1795,10 @@ class ASTContext : public RefCountedBase<ASTContext> {
17951795
QualType Wrapped, QualType Contained,
17961796
const HLSLAttributedResourceType::Attributes &Attrs);
17971797

1798-
QualType
1799-
getSubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl,
1800-
unsigned Index,
1801-
std::optional<unsigned> PackIndex) const;
1798+
QualType getSubstTemplateTypeParmType(QualType Replacement,
1799+
Decl *AssociatedDecl, unsigned Index,
1800+
std::optional<unsigned> PackIndex,
1801+
bool Final) const;
18021802
QualType getSubstTemplateTypeParmPackType(Decl *AssociatedDecl,
18031803
unsigned Index, bool Final,
18041804
const TemplateArgument &ArgPack);
@@ -2393,10 +2393,11 @@ class ASTContext : public RefCountedBase<ASTContext> {
23932393
TemplateName
23942394
getDependentTemplateName(const DependentTemplateStorage &Name) const;
23952395

2396-
TemplateName
2397-
getSubstTemplateTemplateParm(TemplateName replacement, Decl *AssociatedDecl,
2398-
unsigned Index,
2399-
std::optional<unsigned> PackIndex) const;
2396+
TemplateName getSubstTemplateTemplateParm(TemplateName replacement,
2397+
Decl *AssociatedDecl,
2398+
unsigned Index,
2399+
std::optional<unsigned> PackIndex,
2400+
bool Final) const;
24002401
TemplateName getSubstTemplateTemplateParmPack(const TemplateArgument &ArgPack,
24012402
Decl *AssociatedDecl,
24022403
unsigned Index,

clang/include/clang/AST/ExprCXX.h

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4514,7 +4514,9 @@ class SubstNonTypeTemplateParmExpr : public Expr {
45144514
llvm::PointerIntPair<Decl *, 1, bool> AssociatedDeclAndRef;
45154515

45164516
unsigned Index : 15;
4517-
unsigned PackIndex : 16;
4517+
unsigned PackIndex : 15;
4518+
LLVM_PREFERRED_TYPE(bool)
4519+
unsigned Final : 1;
45184520

45194521
explicit SubstNonTypeTemplateParmExpr(EmptyShell Empty)
45204522
: Expr(SubstNonTypeTemplateParmExprClass, Empty) {}
@@ -4523,11 +4525,12 @@ class SubstNonTypeTemplateParmExpr : public Expr {
45234525
SubstNonTypeTemplateParmExpr(QualType Ty, ExprValueKind ValueKind,
45244526
SourceLocation Loc, Expr *Replacement,
45254527
Decl *AssociatedDecl, unsigned Index,
4526-
std::optional<unsigned> PackIndex, bool RefParam)
4528+
std::optional<unsigned> PackIndex, bool RefParam,
4529+
bool Final)
45274530
: Expr(SubstNonTypeTemplateParmExprClass, Ty, ValueKind, OK_Ordinary),
45284531
Replacement(Replacement),
45294532
AssociatedDeclAndRef(AssociatedDecl, RefParam), Index(Index),
4530-
PackIndex(PackIndex ? *PackIndex + 1 : 0) {
4533+
PackIndex(PackIndex ? *PackIndex + 1 : 0), Final(Final) {
45314534
assert(AssociatedDecl != nullptr);
45324535
SubstNonTypeTemplateParmExprBits.NameLoc = Loc;
45334536
setDependence(computeDependence(this));
@@ -4555,6 +4558,10 @@ class SubstNonTypeTemplateParmExpr : public Expr {
45554558
return PackIndex - 1;
45564559
}
45574560

4561+
// This substitution is Final, which means the substitution is fully
4562+
// sugared: it doesn't need to be resugared later.
4563+
bool getFinal() const { return Final; }
4564+
45584565
NonTypeTemplateParmDecl *getParameter() const;
45594566

45604567
bool isReferenceParameter() const { return AssociatedDeclAndRef.getInt(); }
@@ -4598,7 +4605,10 @@ class SubstNonTypeTemplateParmPackExpr : public Expr {
45984605
const TemplateArgument *Arguments;
45994606

46004607
/// The number of template arguments in \c Arguments.
4601-
unsigned NumArguments : 16;
4608+
unsigned NumArguments : 15;
4609+
4610+
LLVM_PREFERRED_TYPE(bool)
4611+
unsigned Final : 1;
46024612

46034613
unsigned Index : 16;
46044614

@@ -4612,7 +4622,8 @@ class SubstNonTypeTemplateParmPackExpr : public Expr {
46124622
SubstNonTypeTemplateParmPackExpr(QualType T, ExprValueKind ValueKind,
46134623
SourceLocation NameLoc,
46144624
const TemplateArgument &ArgPack,
4615-
Decl *AssociatedDecl, unsigned Index);
4625+
Decl *AssociatedDecl, unsigned Index,
4626+
bool Final);
46164627

46174628
/// A template-like entity which owns the whole pattern being substituted.
46184629
/// This will own a set of template parameters.
@@ -4622,6 +4633,10 @@ class SubstNonTypeTemplateParmPackExpr : public Expr {
46224633
/// This should match the result of `getParameterPack()->getIndex()`.
46234634
unsigned getIndex() const { return Index; }
46244635

4636+
// This substitution will be Final, which means the substitution will be fully
4637+
// sugared: it doesn't need to be resugared later.
4638+
bool getFinal() const { return Final; }
4639+
46254640
/// Retrieve the non-type template parameter pack being substituted.
46264641
NonTypeTemplateParmDecl *getParameterPack() const;
46274642

clang/include/clang/AST/PropertiesBase.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,9 @@ let Class = PropertyTypeCase<TemplateName, "SubstTemplateTemplateParm"> in {
730730
def : Property<"packIndex", Optional<UInt32>> {
731731
let Read = [{ parm->getPackIndex() }];
732732
}
733+
def : Property<"final", Bool> { let Read = [{ parm->getFinal() }]; }
733734
def : Creator<[{
734-
return ctx.getSubstTemplateTemplateParm(replacement, associatedDecl, index, packIndex);
735+
return ctx.getSubstTemplateTemplateParm(replacement, associatedDecl, index, packIndex, final);
735736
}]>;
736737
}
737738
let Class = PropertyTypeCase<TemplateName, "SubstTemplateTemplateParmPack"> in {

clang/include/clang/AST/StmtOpenACC.h

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -829,24 +829,42 @@ class OpenACCUpdateConstruct final
829829

830830
// This class represents the 'atomic' construct, which has an associated
831831
// statement, but no clauses.
832-
class OpenACCAtomicConstruct final : public OpenACCAssociatedStmtConstruct {
832+
class OpenACCAtomicConstruct final
833+
: public OpenACCAssociatedStmtConstruct,
834+
private llvm::TrailingObjects<OpenACCAtomicConstruct,
835+
const OpenACCClause *> {
833836

834837
friend class ASTStmtReader;
838+
friend TrailingObjects;
835839
OpenACCAtomicKind AtomicKind = OpenACCAtomicKind::None;
836840

837-
OpenACCAtomicConstruct(EmptyShell)
841+
OpenACCAtomicConstruct(unsigned NumClauses)
838842
: OpenACCAssociatedStmtConstruct(
839843
OpenACCAtomicConstructClass, OpenACCDirectiveKind::Atomic,
840844
SourceLocation{}, SourceLocation{}, SourceLocation{},
841-
/*AssociatedStmt=*/nullptr) {}
845+
/*AssociatedStmt=*/nullptr) {
846+
std::uninitialized_value_construct(
847+
getTrailingObjects<const OpenACCClause *>(),
848+
getTrailingObjects<const OpenACCClause *>() + NumClauses);
849+
setClauseList(MutableArrayRef(getTrailingObjects<const OpenACCClause *>(),
850+
NumClauses));
851+
}
842852

843853
OpenACCAtomicConstruct(SourceLocation Start, SourceLocation DirectiveLoc,
844854
OpenACCAtomicKind AtKind, SourceLocation End,
855+
ArrayRef<const OpenACCClause *> Clauses,
845856
Stmt *AssociatedStmt)
846857
: OpenACCAssociatedStmtConstruct(OpenACCAtomicConstructClass,
847858
OpenACCDirectiveKind::Atomic, Start,
848859
DirectiveLoc, End, AssociatedStmt),
849-
AtomicKind(AtKind) {}
860+
AtomicKind(AtKind) {
861+
// Initialize the trailing storage.
862+
std::uninitialized_copy(Clauses.begin(), Clauses.end(),
863+
getTrailingObjects<const OpenACCClause *>());
864+
865+
setClauseList(MutableArrayRef(getTrailingObjects<const OpenACCClause *>(),
866+
Clauses.size()));
867+
}
850868

851869
void setAssociatedStmt(Stmt *S) {
852870
OpenACCAssociatedStmtConstruct::setAssociatedStmt(S);
@@ -857,10 +875,12 @@ class OpenACCAtomicConstruct final : public OpenACCAssociatedStmtConstruct {
857875
return T->getStmtClass() == OpenACCAtomicConstructClass;
858876
}
859877

860-
static OpenACCAtomicConstruct *CreateEmpty(const ASTContext &C);
878+
static OpenACCAtomicConstruct *CreateEmpty(const ASTContext &C,
879+
unsigned NumClauses);
861880
static OpenACCAtomicConstruct *
862881
Create(const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc,
863-
OpenACCAtomicKind AtKind, SourceLocation End, Stmt *AssociatedStmt);
882+
OpenACCAtomicKind AtKind, SourceLocation End,
883+
ArrayRef<const OpenACCClause *> Clauses, Stmt *AssociatedStmt);
864884

865885
OpenACCAtomicKind getAtomicKind() const { return AtomicKind; }
866886
const Stmt *getAssociatedStmt() const {

clang/include/clang/AST/TemplateName.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,11 @@ class SubstTemplateTemplateParmStorage
414414

415415
SubstTemplateTemplateParmStorage(TemplateName Replacement,
416416
Decl *AssociatedDecl, unsigned Index,
417-
std::optional<unsigned> PackIndex)
417+
std::optional<unsigned> PackIndex,
418+
bool Final)
418419
: UncommonTemplateNameStorage(SubstTemplateTemplateParm, Index,
419-
PackIndex ? *PackIndex + 1 : 0),
420+
((PackIndex ? *PackIndex + 1 : 0) << 1) |
421+
Final),
420422
Replacement(Replacement), AssociatedDecl(AssociatedDecl) {
421423
assert(AssociatedDecl != nullptr);
422424
}
@@ -430,10 +432,15 @@ class SubstTemplateTemplateParmStorage
430432
/// This should match the result of `getParameter()->getIndex()`.
431433
unsigned getIndex() const { return Bits.Index; }
432434

435+
// This substitution is Final, which means the substitution is fully
436+
// sugared: it doesn't need to be resugared later.
437+
bool getFinal() const { return Bits.Data & 1; }
438+
433439
std::optional<unsigned> getPackIndex() const {
434-
if (Bits.Data == 0)
440+
auto Data = Bits.Data >> 1;
441+
if (Data == 0)
435442
return std::nullopt;
436-
return Bits.Data - 1;
443+
return Data - 1;
437444
}
438445

439446
TemplateTemplateParmDecl *getParameter() const;
@@ -443,7 +450,7 @@ class SubstTemplateTemplateParmStorage
443450

444451
static void Profile(llvm::FoldingSetNodeID &ID, TemplateName Replacement,
445452
Decl *AssociatedDecl, unsigned Index,
446-
std::optional<unsigned> PackIndex);
453+
std::optional<unsigned> PackIndex, bool Final);
447454
};
448455

449456
class DeducedTemplateStorage : public UncommonTemplateNameStorage,

clang/include/clang/AST/Type.h

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2158,12 +2158,15 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
21582158
// The index of the template parameter this substitution represents.
21592159
unsigned Index : 15;
21602160

2161+
LLVM_PREFERRED_TYPE(bool)
2162+
unsigned Final : 1;
2163+
21612164
/// Represents the index within a pack if this represents a substitution
21622165
/// from a pack expansion. This index starts at the end of the pack and
21632166
/// increments towards the beginning.
21642167
/// Positive non-zero number represents the index + 1.
21652168
/// Zero means this is not substituted from an expansion.
2166-
unsigned PackIndex : 16;
2169+
unsigned PackIndex : 15;
21672170
};
21682171

21692172
class SubstTemplateTypeParmPackTypeBitfields {
@@ -6397,7 +6400,8 @@ class SubstTemplateTypeParmType final
63976400
Decl *AssociatedDecl;
63986401

63996402
SubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl,
6400-
unsigned Index, std::optional<unsigned> PackIndex);
6403+
unsigned Index, std::optional<unsigned> PackIndex,
6404+
bool Final);
64016405

64026406
public:
64036407
/// Gets the type that was substituted for the template
@@ -6420,6 +6424,10 @@ class SubstTemplateTypeParmType final
64206424
/// This should match the result of `getReplacedParameter()->getIndex()`.
64216425
unsigned getIndex() const { return SubstTemplateTypeParmTypeBits.Index; }
64226426

6427+
// This substitution is Final, which means the substitution is fully
6428+
// sugared: it doesn't need to be resugared later.
6429+
unsigned getFinal() const { return SubstTemplateTypeParmTypeBits.Final; }
6430+
64236431
std::optional<unsigned> getPackIndex() const {
64246432
if (SubstTemplateTypeParmTypeBits.PackIndex == 0)
64256433
return std::nullopt;
@@ -6431,17 +6439,12 @@ class SubstTemplateTypeParmType final
64316439

64326440
void Profile(llvm::FoldingSetNodeID &ID) {
64336441
Profile(ID, getReplacementType(), getAssociatedDecl(), getIndex(),
6434-
getPackIndex());
6442+
getPackIndex(), getFinal());
64356443
}
64366444

64376445
static void Profile(llvm::FoldingSetNodeID &ID, QualType Replacement,
64386446
const Decl *AssociatedDecl, unsigned Index,
6439-
std::optional<unsigned> PackIndex) {
6440-
Replacement.Profile(ID);
6441-
ID.AddPointer(AssociatedDecl);
6442-
ID.AddInteger(Index);
6443-
ID.AddInteger(PackIndex ? *PackIndex - 1 : 0);
6444-
}
6447+
std::optional<unsigned> PackIndex, bool Final);
64456448

64466449
static bool classof(const Type *T) {
64476450
return T->getTypeClass() == SubstTemplateTypeParm;
@@ -6488,7 +6491,8 @@ class SubstTemplateTypeParmPackType : public Type, public llvm::FoldingSetNode {
64886491
/// This should match the result of `getReplacedParameter()->getIndex()`.
64896492
unsigned getIndex() const { return SubstTemplateTypeParmPackTypeBits.Index; }
64906493

6491-
// When true the substitution will be 'Final' (subst node won't be placed).
6494+
// This substitution will be Final, which means the substitution will be fully
6495+
// sugared: it doesn't need to be resugared later.
64926496
bool getFinal() const;
64936497

64946498
unsigned getNumArgs() const {

clang/include/clang/AST/TypeProperties.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -842,11 +842,11 @@ let Class = SubstTemplateTypeParmType in {
842842
def : Property<"PackIndex", Optional<UInt32>> {
843843
let Read = [{ node->getPackIndex() }];
844844
}
845+
def : Property<"Final", Bool> { let Read = [{ node->getFinal() }]; }
845846

846-
// The call to getCanonicalType here existed in ASTReader.cpp, too.
847847
def : Creator<[{
848848
return ctx.getSubstTemplateTypeParmType(
849-
replacementType, associatedDecl, Index, PackIndex);
849+
replacementType, associatedDecl, Index, PackIndex, Final);
850850
}]>;
851851
}
852852

clang/include/clang/Basic/Attr.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,8 @@ def PatchableFunctionEntry
936936
"riscv64", "x86", "x86_64", "ppc", "ppc64"]>> {
937937
let Spellings = [GCC<"patchable_function_entry">];
938938
let Subjects = SubjectList<[Function, ObjCMethod]>;
939-
let Args = [UnsignedArgument<"Count">, DefaultIntArgument<"Offset", 0>];
939+
let Args = [UnsignedArgument<"Count">, DefaultIntArgument<"Offset", 0>,
940+
StringArgument<"Section", /* optional */ 1>];
940941
let Documentation = [PatchableFunctionEntryDocs];
941942
}
942943

clang/include/clang/Basic/AttrDocs.td

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6502,10 +6502,12 @@ only N==1 is supported.
65026502
def PatchableFunctionEntryDocs : Documentation {
65036503
let Category = DocCatFunction;
65046504
let Content = [{
6505-
``__attribute__((patchable_function_entry(N,M)))`` is used to generate M NOPs
6506-
before the function entry and N-M NOPs after the function entry. This attribute
6507-
takes precedence over the command line option ``-fpatchable-function-entry=N,M``.
6508-
``M`` defaults to 0 if omitted.
6505+
``__attribute__((patchable_function_entry(N,M,Section)))`` is used to generate M
6506+
NOPs before the function entry and N-M NOPs after the function entry, with a record of
6507+
the entry stored in section ``Section``. This attribute takes precedence over the
6508+
command line option ``-fpatchable-function-entry=N,M,Section``. ``M`` defaults to 0
6509+
if omitted.``Section`` defaults to the ``-fpatchable-function-entry`` section name if
6510+
set, or to ``__patchable_function_entries`` otherwise.
65096511

65106512
This attribute is only supported on
65116513
aarch64/aarch64-be/loongarch32/loongarch64/riscv32/riscv64/i386/x86-64/ppc/ppc64 targets.

clang/include/clang/Basic/BuiltinsAMDGPU.def

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ BUILTIN(__builtin_amdgcn_cvt_pknorm_u16, "E2Usff", "nc")
140140
BUILTIN(__builtin_amdgcn_cvt_pk_i16, "E2sii", "nc")
141141
BUILTIN(__builtin_amdgcn_cvt_pk_u16, "E2UsUiUi", "nc")
142142
BUILTIN(__builtin_amdgcn_cvt_pk_u8_f32, "UifUiUi", "nc")
143+
BUILTIN(__builtin_amdgcn_cvt_off_f32_i4, "fi", "nc")
143144
BUILTIN(__builtin_amdgcn_sad_u8, "UiUiUiUi", "nc")
144145
BUILTIN(__builtin_amdgcn_msad_u8, "UiUiUiUi", "nc")
145146
BUILTIN(__builtin_amdgcn_sad_hi_u8, "UiUiUiUi", "nc")
@@ -254,7 +255,7 @@ TARGET_BUILTIN(__builtin_amdgcn_flat_atomic_fadd_v2bf16, "V2sV2s*0V2s", "t", "at
254255
TARGET_BUILTIN(__builtin_amdgcn_global_atomic_fadd_v2bf16, "V2sV2s*1V2s", "t", "atomic-global-pk-add-bf16-inst")
255256
TARGET_BUILTIN(__builtin_amdgcn_ds_atomic_fadd_v2bf16, "V2sV2s*3V2s", "t", "atomic-ds-pk-add-16-insts")
256257
TARGET_BUILTIN(__builtin_amdgcn_ds_atomic_fadd_v2f16, "V2hV2h*3V2h", "t", "atomic-ds-pk-add-16-insts")
257-
TARGET_BUILTIN(__builtin_amdgcn_global_load_lds, "vv*1v*3IUiIiIUi", "t", "gfx940-insts")
258+
TARGET_BUILTIN(__builtin_amdgcn_global_load_lds, "vv*1v*3IUiIiIUi", "t", "vmem-to-lds-load-insts")
258259

259260
//===----------------------------------------------------------------------===//
260261
// Deep learning builtins.

clang/include/clang/Basic/CodeGenOptions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,10 @@ class CodeGenOptions : public CodeGenOptionsBase {
281281
/// -fprofile-generate, and -fcs-profile-generate.
282282
std::string InstrProfileOutput;
283283

284+
/// Name of the patchable function entry section with
285+
/// -fpatchable-function-entry.
286+
std::string PatchableFunctionEntrySection;
287+
284288
/// Name of the profile file to use with -fprofile-sample-use.
285289
std::string SampleProfileFile;
286290

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,12 +377,13 @@ def CXX11WarnSuggestOverride : DiagGroup<"suggest-override">;
377377
def WarnUnnecessaryVirtualSpecifier : DiagGroup<"unnecessary-virtual-specifier"> {
378378
code Documentation = [{
379379
Warns when a ``final`` class contains a virtual method (including virtual
380-
destructors) that does not override anything. Since ``final`` classes cannot be
381-
subclassed, their methods cannot be overridden, so there is no point to
382-
introducing new ``virtual`` methods.
380+
destructors). Since ``final`` classes cannot be subclassed, their methods
381+
cannot be overridden, and hence the ``virtual`` specifier is useless.
383382

384383
The warning also detects virtual methods in classes whose destructor is
385384
``final``, for the same reason.
385+
386+
The warning does not fire on virtual methods which are also marked ``override``.
386387
}];
387388
}
388389

0 commit comments

Comments
 (0)