Skip to content

Commit d7a876f

Browse files
committed
merge main into amd-staging
Change-Id: I5af07e86eb5e25c35e6277b4385a14fcdb4bc9c8
2 parents 1407193 + 768b0b4 commit d7a876f

File tree

1,423 files changed

+28545
-23990
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,423 files changed

+28545
-23990
lines changed

clang-tools-extra/clang-include-fixer/InMemorySymbolIndex.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ InMemorySymbolIndex::InMemorySymbolIndex(
2121

2222
std::vector<SymbolAndSignals>
2323
InMemorySymbolIndex::search(llvm::StringRef Identifier) {
24-
auto I = LookupTable.find(std::string(Identifier));
24+
auto I = LookupTable.find(Identifier);
2525
if (I != LookupTable.end())
2626
return I->second;
2727
return {};

clang-tools-extra/clang-include-fixer/InMemorySymbolIndex.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ class InMemorySymbolIndex : public SymbolIndex {
2727
search(llvm::StringRef Identifier) override;
2828

2929
private:
30-
std::map<std::string, std::vector<find_all_symbols::SymbolAndSignals>>
30+
std::map<std::string, std::vector<find_all_symbols::SymbolAndSignals>,
31+
std::less<>>
3132
LookupTable;
3233
};
3334

clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ std::optional<DurationScale> getScaleForDurationInverse(llvm::StringRef Name) {
244244
{"ToDoubleNanoseconds", DurationScale::Nanoseconds},
245245
{"ToInt64Nanoseconds", DurationScale::Nanoseconds}});
246246

247-
auto ScaleIter = ScaleMap.find(std::string(Name));
247+
auto ScaleIter = ScaleMap.find(Name);
248248
if (ScaleIter == ScaleMap.end())
249249
return std::nullopt;
250250

@@ -260,7 +260,7 @@ std::optional<DurationScale> getScaleForTimeInverse(llvm::StringRef Name) {
260260
{"ToUnixMicros", DurationScale::Microseconds},
261261
{"ToUnixNanos", DurationScale::Nanoseconds}});
262262

263-
auto ScaleIter = ScaleMap.find(std::string(Name));
263+
auto ScaleIter = ScaleMap.find(Name);
264264
if (ScaleIter == ScaleMap.end())
265265
return std::nullopt;
266266

clang/docs/OpenMPSupport.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,8 @@ implementation.
284284
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
285285
| memory management | alignment for allocate directive and clause | :good:`done` | D115683 |
286286
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
287+
| memory management | 'allocator' modifier for allocate clause | :good:`done` | https://github.com/llvm/llvm-project/pull/114883 |
288+
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
287289
| memory management | new memory management routines | :none:`unclaimed` | |
288290
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
289291
| memory management | changes to omp_alloctrait_key enum | :none:`unclaimed` | |

clang/docs/ReleaseNotes.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -601,9 +601,6 @@ Bug Fixes to C++ Support
601601
in certain friend declarations. (#GH93099)
602602
- Clang now instantiates the correct lambda call operator when a lambda's class type is
603603
merged across modules. (#GH110401)
604-
- Clang now uses the correct set of template argument lists when comparing the constraints of
605-
out-of-line definitions and member templates explicitly specialized for a given implicit instantiation of
606-
a class template. (#GH102320)
607604
- Fix a crash when parsing a pseudo destructor involving an invalid type. (#GH111460)
608605
- Fixed an assertion failure when invoking recovery call expressions with explicit attributes
609606
and undeclared templates. (#GH107047), (#GH49093)

clang/include/clang/AST/DeclTemplate.h

Lines changed: 51 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -787,11 +787,15 @@ class RedeclarableTemplateDecl : public TemplateDecl,
787787
EntryType *Entry, void *InsertPos);
788788

789789
struct CommonBase {
790-
CommonBase() {}
790+
CommonBase() : InstantiatedFromMember(nullptr, false) {}
791791

792792
/// The template from which this was most
793793
/// directly instantiated (or null).
794-
RedeclarableTemplateDecl *InstantiatedFromMember = nullptr;
794+
///
795+
/// The boolean value indicates whether this template
796+
/// was explicitly specialized.
797+
llvm::PointerIntPair<RedeclarableTemplateDecl *, 1, bool>
798+
InstantiatedFromMember;
795799

796800
/// If non-null, points to an array of specializations (including
797801
/// partial specializations) known only by their external declaration IDs.
@@ -802,19 +806,14 @@ class RedeclarableTemplateDecl : public TemplateDecl,
802806
};
803807

804808
/// Pointer to the common data shared by all declarations of this
805-
/// template, and a flag indicating if the template is a member
806-
/// specialization.
807-
mutable llvm::PointerIntPair<CommonBase *, 1, bool> Common;
808-
809-
CommonBase *getCommonPtrInternal() const { return Common.getPointer(); }
809+
/// template.
810+
mutable CommonBase *Common = nullptr;
810811

811812
/// Retrieves the "common" pointer shared by all (re-)declarations of
812813
/// the same template. Calling this routine may implicitly allocate memory
813814
/// for the common pointer.
814815
CommonBase *getCommonPtr() const;
815816

816-
void setCommonPtr(CommonBase *C) const { Common.setPointer(C); }
817-
818817
virtual CommonBase *newCommon(ASTContext &C) const = 0;
819818

820819
// Construct a template decl with name, parameters, and templated element.
@@ -855,12 +854,15 @@ class RedeclarableTemplateDecl : public TemplateDecl,
855854
/// template<> template<typename T>
856855
/// struct X<int>::Inner { /* ... */ };
857856
/// \endcode
858-
bool isMemberSpecialization() const { return Common.getInt(); }
857+
bool isMemberSpecialization() const {
858+
return getCommonPtr()->InstantiatedFromMember.getInt();
859+
}
859860

860861
/// Note that this member template is a specialization.
861862
void setMemberSpecialization() {
862-
assert(!isMemberSpecialization() && "already a member specialization");
863-
Common.setInt(true);
863+
assert(getCommonPtr()->InstantiatedFromMember.getPointer() &&
864+
"Only member templates can be member template specializations");
865+
getCommonPtr()->InstantiatedFromMember.setInt(true);
864866
}
865867

866868
/// Retrieve the member template from which this template was
@@ -900,12 +902,12 @@ class RedeclarableTemplateDecl : public TemplateDecl,
900902
/// void X<T>::f(T, U);
901903
/// \endcode
902904
RedeclarableTemplateDecl *getInstantiatedFromMemberTemplate() const {
903-
return getCommonPtr()->InstantiatedFromMember;
905+
return getCommonPtr()->InstantiatedFromMember.getPointer();
904906
}
905907

906908
void setInstantiatedFromMemberTemplate(RedeclarableTemplateDecl *TD) {
907-
assert(!getCommonPtr()->InstantiatedFromMember);
908-
getCommonPtr()->InstantiatedFromMember = TD;
909+
assert(!getCommonPtr()->InstantiatedFromMember.getPointer());
910+
getCommonPtr()->InstantiatedFromMember.setPointer(TD);
909911
}
910912

911913
/// Retrieve the "injected" template arguments that correspond to the
@@ -1955,7 +1957,13 @@ class ClassTemplateSpecializationDecl : public CXXRecordDecl,
19551957
/// specialization which was specialized by this.
19561958
llvm::PointerUnion<ClassTemplateDecl *,
19571959
ClassTemplatePartialSpecializationDecl *>
1958-
getSpecializedTemplateOrPartial() const;
1960+
getSpecializedTemplateOrPartial() const {
1961+
if (const auto *PartialSpec =
1962+
SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
1963+
return PartialSpec->PartialSpecialization;
1964+
1965+
return SpecializedTemplate.get<ClassTemplateDecl*>();
1966+
}
19591967

19601968
/// Retrieve the set of template arguments that should be used
19611969
/// to instantiate members of the class template or class template partial
@@ -1981,8 +1989,6 @@ class ClassTemplateSpecializationDecl : public CXXRecordDecl,
19811989
/// template arguments have been deduced.
19821990
void setInstantiationOf(ClassTemplatePartialSpecializationDecl *PartialSpec,
19831991
const TemplateArgumentList *TemplateArgs) {
1984-
assert(!isa<ClassTemplatePartialSpecializationDecl>(this) &&
1985-
"A partial specialization cannot be instantiated from a template");
19861992
assert(!SpecializedTemplate.is<SpecializedPartialSpecialization*>() &&
19871993
"Already set to a class template partial specialization!");
19881994
auto *PS = new (getASTContext()) SpecializedPartialSpecialization();
@@ -1994,8 +2000,6 @@ class ClassTemplateSpecializationDecl : public CXXRecordDecl,
19942000
/// Note that this class template specialization is an instantiation
19952001
/// of the given class template.
19962002
void setInstantiationOf(ClassTemplateDecl *TemplDecl) {
1997-
assert(!isa<ClassTemplatePartialSpecializationDecl>(this) &&
1998-
"A partial specialization cannot be instantiated from a template");
19992003
assert(!SpecializedTemplate.is<SpecializedPartialSpecialization*>() &&
20002004
"Previously set to a class template partial specialization!");
20012005
SpecializedTemplate = TemplDecl;
@@ -2189,11 +2193,18 @@ class ClassTemplatePartialSpecializationDecl
21892193
/// struct X<int>::Inner<T*> { /* ... */ };
21902194
/// \endcode
21912195
bool isMemberSpecialization() const {
2192-
return InstantiatedFromMember.getInt();
2196+
const auto *First =
2197+
cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
2198+
return First->InstantiatedFromMember.getInt();
21932199
}
21942200

21952201
/// Note that this member template is a specialization.
2196-
void setMemberSpecialization() { return InstantiatedFromMember.setInt(true); }
2202+
void setMemberSpecialization() {
2203+
auto *First = cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
2204+
assert(First->InstantiatedFromMember.getPointer() &&
2205+
"Only member templates can be member template specializations");
2206+
return First->InstantiatedFromMember.setInt(true);
2207+
}
21972208

21982209
/// Retrieves the injected specialization type for this partial
21992210
/// specialization. This is not the same as the type-decl-type for
@@ -2263,6 +2274,8 @@ class ClassTemplateDecl : public RedeclarableTemplateDecl {
22632274
return static_cast<Common *>(RedeclarableTemplateDecl::getCommonPtr());
22642275
}
22652276

2277+
void setCommonPtr(Common *C) { RedeclarableTemplateDecl::Common = C; }
2278+
22662279
public:
22672280

22682281
friend class ASTDeclReader;
@@ -2713,7 +2726,13 @@ class VarTemplateSpecializationDecl : public VarDecl,
27132726
/// Retrieve the variable template or variable template partial
27142727
/// specialization which was specialized by this.
27152728
llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
2716-
getSpecializedTemplateOrPartial() const;
2729+
getSpecializedTemplateOrPartial() const {
2730+
if (const auto *PartialSpec =
2731+
SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
2732+
return PartialSpec->PartialSpecialization;
2733+
2734+
return SpecializedTemplate.get<VarTemplateDecl *>();
2735+
}
27172736

27182737
/// Retrieve the set of template arguments that should be used
27192738
/// to instantiate the initializer of the variable template or variable
@@ -2739,8 +2758,6 @@ class VarTemplateSpecializationDecl : public VarDecl,
27392758
/// template arguments have been deduced.
27402759
void setInstantiationOf(VarTemplatePartialSpecializationDecl *PartialSpec,
27412760
const TemplateArgumentList *TemplateArgs) {
2742-
assert(!isa<VarTemplatePartialSpecializationDecl>(this) &&
2743-
"A partial specialization cannot be instantiated from a template");
27442761
assert(!SpecializedTemplate.is<SpecializedPartialSpecialization *>() &&
27452762
"Already set to a variable template partial specialization!");
27462763
auto *PS = new (getASTContext()) SpecializedPartialSpecialization();
@@ -2752,8 +2769,6 @@ class VarTemplateSpecializationDecl : public VarDecl,
27522769
/// Note that this variable template specialization is an instantiation
27532770
/// of the given variable template.
27542771
void setInstantiationOf(VarTemplateDecl *TemplDecl) {
2755-
assert(!isa<VarTemplatePartialSpecializationDecl>(this) &&
2756-
"A partial specialization cannot be instantiated from a template");
27572772
assert(!SpecializedTemplate.is<SpecializedPartialSpecialization *>() &&
27582773
"Previously set to a variable template partial specialization!");
27592774
SpecializedTemplate = TemplDecl;
@@ -2944,11 +2959,18 @@ class VarTemplatePartialSpecializationDecl
29442959
/// U* X<int>::Inner<T*> = (T*)(0) + 1;
29452960
/// \endcode
29462961
bool isMemberSpecialization() const {
2947-
return InstantiatedFromMember.getInt();
2962+
const auto *First =
2963+
cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
2964+
return First->InstantiatedFromMember.getInt();
29482965
}
29492966

29502967
/// Note that this member template is a specialization.
2951-
void setMemberSpecialization() { return InstantiatedFromMember.setInt(true); }
2968+
void setMemberSpecialization() {
2969+
auto *First = cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
2970+
assert(First->InstantiatedFromMember.getPointer() &&
2971+
"Only member templates can be member template specializations");
2972+
return First->InstantiatedFromMember.setInt(true);
2973+
}
29522974

29532975
SourceRange getSourceRange() const override LLVM_READONLY;
29542976

@@ -3119,9 +3141,6 @@ class VarTemplateDecl : public RedeclarableTemplateDecl {
31193141
return makeSpecIterator(getSpecializations(), true);
31203142
}
31213143

3122-
/// Merge \p Prev with our RedeclarableTemplateDecl::Common.
3123-
void mergePrevDecl(VarTemplateDecl *Prev);
3124-
31253144
// Implement isa/cast/dyncast support
31263145
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
31273146
static bool classofKind(Kind K) { return K == VarTemplate; }

clang/include/clang/AST/SYCLKernelInfo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#ifndef LLVM_CLANG_AST_SYCLKERNELINFO_H
1414
#define LLVM_CLANG_AST_SYCLKERNELINFO_H
1515

16+
#include "clang/AST/CanonicalType.h"
1617
#include "clang/AST/Decl.h"
1718
#include "clang/AST/Type.h"
1819

clang/include/clang/Basic/Builtins.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4798,6 +4798,12 @@ def HLSLDot4AddI8Packed : LangBuiltin<"HLSL_LANG"> {
47984798
let Prototype = "int(unsigned int, unsigned int, int)";
47994799
}
48004800

4801+
def HLSLFirstBitHigh : LangBuiltin<"HLSL_LANG"> {
4802+
let Spellings = ["__builtin_hlsl_elementwise_firstbithigh"];
4803+
let Attributes = [NoThrow, Const];
4804+
let Prototype = "void(...)";
4805+
}
4806+
48014807
def HLSLFrac : LangBuiltin<"HLSL_LANG"> {
48024808
let Spellings = ["__builtin_hlsl_elementwise_frac"];
48034809
let Attributes = [NoThrow, Const];

clang/include/clang/Basic/BuiltinsAMDGPU.def

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -439,15 +439,15 @@ TARGET_BUILTIN(__builtin_amdgcn_s_sleep_var, "vUi", "n", "gfx12-insts")
439439
TARGET_BUILTIN(__builtin_amdgcn_permlane16_var, "UiUiUiUiIbIb", "nc", "gfx12-insts")
440440
TARGET_BUILTIN(__builtin_amdgcn_permlanex16_var, "UiUiUiUiIbIb", "nc", "gfx12-insts")
441441
TARGET_BUILTIN(__builtin_amdgcn_s_barrier_signal, "vIi", "n", "gfx12-insts")
442-
TARGET_BUILTIN(__builtin_amdgcn_s_barrier_signal_var, "vi", "n", "gfx12-insts")
442+
TARGET_BUILTIN(__builtin_amdgcn_s_barrier_signal_var, "vv*i", "n", "gfx12-insts")
443443
TARGET_BUILTIN(__builtin_amdgcn_s_barrier_wait, "vIs", "n", "gfx12-insts")
444444
TARGET_BUILTIN(__builtin_amdgcn_s_barrier_signal_isfirst, "bIi", "n", "gfx12-insts")
445-
TARGET_BUILTIN(__builtin_amdgcn_s_barrier_signal_isfirst_var, "bi", "n", "gfx12-insts")
446-
TARGET_BUILTIN(__builtin_amdgcn_s_barrier_init, "vii", "n", "gfx12-insts")
447-
TARGET_BUILTIN(__builtin_amdgcn_s_barrier_join, "vi", "n", "gfx12-insts")
448-
TARGET_BUILTIN(__builtin_amdgcn_s_wakeup_barrier, "vi", "n", "gfx12-insts")
449-
TARGET_BUILTIN(__builtin_amdgcn_s_barrier_leave, "b", "n", "gfx12-insts")
445+
TARGET_BUILTIN(__builtin_amdgcn_s_barrier_init, "vv*i", "n", "gfx12-insts")
446+
TARGET_BUILTIN(__builtin_amdgcn_s_barrier_join, "vv*", "n", "gfx12-insts")
447+
TARGET_BUILTIN(__builtin_amdgcn_s_wakeup_barrier, "vv*", "n", "gfx12-insts")
448+
TARGET_BUILTIN(__builtin_amdgcn_s_barrier_leave, "vIs", "n", "gfx12-insts")
450449
TARGET_BUILTIN(__builtin_amdgcn_s_get_barrier_state, "Uii", "n", "gfx12-insts")
450+
TARGET_BUILTIN(__builtin_amdgcn_s_get_named_barrier_state, "Uiv*", "n", "gfx12-insts")
451451
TARGET_BUILTIN(__builtin_amdgcn_s_prefetch_data, "vvC*Ui", "nc", "gfx12-insts")
452452
TARGET_BUILTIN(__builtin_amdgcn_s_buffer_prefetch_data, "vQbIiUi", "nc", "gfx12-insts")
453453

clang/include/clang/Sema/Sema.h

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11328,9 +11328,9 @@ class Sema final : public SemaBase {
1132811328
CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc,
1132911329
const ParsedAttributesView &Attr, TemplateParameterList *TemplateParams,
1133011330
AccessSpecifier AS, SourceLocation ModulePrivateLoc,
11331-
SourceLocation FriendLoc,
11332-
ArrayRef<TemplateParameterList *> OuterTemplateParamLists,
11333-
bool IsMemberSpecialization, SkipBodyInfo *SkipBody = nullptr);
11331+
SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists,
11332+
TemplateParameterList **OuterTemplateParamLists,
11333+
SkipBodyInfo *SkipBody = nullptr);
1133411334

1133511335
/// Translates template arguments as provided by the parser
1133611336
/// into template arguments used by semantic analysis.
@@ -11369,8 +11369,7 @@ class Sema final : public SemaBase {
1136911369
DeclResult ActOnVarTemplateSpecialization(
1137011370
Scope *S, Declarator &D, TypeSourceInfo *DI, LookupResult &Previous,
1137111371
SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams,
11372-
StorageClass SC, bool IsPartialSpecialization,
11373-
bool IsMemberSpecialization);
11372+
StorageClass SC, bool IsPartialSpecialization);
1137411373

1137511374
/// Get the specialization of the given variable template corresponding to
1137611375
/// the specified argument list, or a null-but-valid result if the arguments
@@ -13012,14 +13011,28 @@ class Sema final : public SemaBase {
1301213011
/// dealing with a specialization. This is only relevant for function
1301313012
/// template specializations.
1301413013
///
13014+
/// \param Pattern If non-NULL, indicates the pattern from which we will be
13015+
/// instantiating the definition of the given declaration, \p ND. This is
13016+
/// used to determine the proper set of template instantiation arguments for
13017+
/// friend function template specializations.
13018+
///
1301513019
/// \param ForConstraintInstantiation when collecting arguments,
1301613020
/// ForConstraintInstantiation indicates we should continue looking when
1301713021
/// encountering a lambda generic call operator, and continue looking for
1301813022
/// arguments on an enclosing class template.
13023+
///
13024+
/// \param SkipForSpecialization when specified, any template specializations
13025+
/// in a traversal would be ignored.
13026+
/// \param ForDefaultArgumentSubstitution indicates we should continue looking
13027+
/// when encountering a specialized member function template, rather than
13028+
/// returning immediately.
1301913029
MultiLevelTemplateArgumentList getTemplateInstantiationArgs(
1302013030
const NamedDecl *D, const DeclContext *DC = nullptr, bool Final = false,
1302113031
std::optional<ArrayRef<TemplateArgument>> Innermost = std::nullopt,
13022-
bool RelativeToPrimary = false, bool ForConstraintInstantiation = false);
13032+
bool RelativeToPrimary = false, const FunctionDecl *Pattern = nullptr,
13033+
bool ForConstraintInstantiation = false,
13034+
bool SkipForSpecialization = false,
13035+
bool ForDefaultArgumentSubstitution = false);
1302313036

1302413037
/// RAII object to handle the state changes required to synthesize
1302513038
/// a function body.

clang/lib/AST/ASTImporter.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6190,8 +6190,7 @@ ExpectedDecl ASTNodeImporter::VisitClassTemplateDecl(ClassTemplateDecl *D) {
61906190
ExpectedDecl ASTNodeImporter::VisitClassTemplateSpecializationDecl(
61916191
ClassTemplateSpecializationDecl *D) {
61926192
ClassTemplateDecl *ClassTemplate;
6193-
if (Error Err = importInto(ClassTemplate,
6194-
D->getSpecializedTemplate()->getCanonicalDecl()))
6193+
if (Error Err = importInto(ClassTemplate, D->getSpecializedTemplate()))
61956194
return std::move(Err);
61966195

61976196
// Import the context of this declaration.

0 commit comments

Comments
 (0)