Skip to content

Commit c273851

Browse files
authored
Merge pull request llvm#351 from AMD-Lightning-Internal/amd/merge/upstream_merge_20250128221800
merge main into amd-staging
2 parents 192914b + e2a7ccb commit c273851

File tree

126 files changed

+35342
-676
lines changed

Some content is hidden

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

126 files changed

+35342
-676
lines changed

clang/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ if(NOT DEFINED CLANG_VERSION_SUFFIX)
356356
set(CLANG_VERSION_SUFFIX ${LLVM_VERSION_SUFFIX})
357357
endif()
358358
set(CLANG_VERSION "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION_PATCHLEVEL}${CLANG_VERSION_SUFFIX}")
359+
set(MAX_CLANG_ABI_COMPAT_VERSION "${LLVM_VERSION_MAJOR}")
359360
message(STATUS "Clang version: ${CLANG_VERSION}")
360361

361362
# Configure the Version.inc file.

clang/docs/HIPSupport.rst

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ AMD GPU Support
2727
Clang provides HIP support on AMD GPUs via the ROCm platform `<https://rocm.docs.amd.com/en/latest/#>`_.
2828
The ROCm runtime forms the base for HIP host APIs, while HIP device APIs are realized through HIP header
2929
files and the ROCm device library. The Clang driver uses the HIPAMD toolchain to compile HIP device code
30-
to AMDGPU ISA via the AMDGPU backend. The compiled code is then bundled and embedded in the host executables.
30+
to AMDGPU ISA via the AMDGPU backend, or SPIR-V via the workflow outlined below.
31+
The compiled code is then bundled and embedded in the host executables.
3132

3233
Intel GPU Support
3334
=================
@@ -307,7 +308,7 @@ The `parallel_unsequenced_policy <https://en.cppreference.com/w/cpp/algorithm/ex
307308
maps relatively well to the execution model of AMD GPUs. This, coupled with the
308309
the availability and maturity of GPU accelerated algorithm libraries that
309310
implement most / all corresponding algorithms in the standard library
310-
(e.g. `rocThrust <https://github.com/ROCmSoftwarePlatform/rocThrust>`_), makes
311+
(e.g. `rocThrust <https://github.com/ROCmSoftwarePlatform/rocThrust>`__), makes
311312
it feasible to provide seamless accelerator offload for supported algorithms,
312313
when an accelerated version exists. Thus, it becomes possible to easily access
313314
the computational resources of an AMD accelerator, via a well specified,
@@ -339,8 +340,8 @@ transparent on-demand paging (such as e.g. that provided in Linux via
339340
the ``--hipstdpar-interpose-alloc`` flag. If the accelerator specific algorithm
340341
library ``foo`` uses doesn't have an implementation of a particular algorithm,
341342
execution seamlessly falls back to the host CPU. It is legal to specify multiple
342-
``--offload-arch``s. All the flags we introduce, as well as a thorough view of
343-
various restrictions and their implications will be provided below.
343+
``--offload-arch``\s. All the flags we introduce, as well as a thorough view of
344+
various restrictions an their implementations, will be provided below.
344345

345346
Implementation - General View
346347
=============================
@@ -462,7 +463,7 @@ such as GPUs, work.
462463
allocation / deallocation functions with accelerator-aware equivalents,
463464
based on a pre-established table; the list of functions that can be
464465
interposed is available
465-
`here <https://github.com/ROCmSoftwarePlatform/roc-stdpar#allocation--deallocation-interposition-status>`_;
466+
`here <https://github.com/ROCmSoftwarePlatform/roc-stdpar#allocation--deallocation-interposition-status>`__;
466467
- This is only run when compiling for the host.
467468

468469
The second pass is optional.
@@ -599,6 +600,9 @@ Linux operating system. Support is synthesised in the following table:
599600
* - GCN GFX11 (RDNA 3)
600601
- *NO*
601602
- YES
603+
* - GCN GFX12 (RDNA 4)
604+
- *NO*
605+
- YES
602606

603607
The minimum Linux kernel version for running in HMM mode is 6.4.
604608

@@ -708,13 +712,6 @@ Using ``--offload-arch=amdgcnspirv``
708712
- **Clang Offload Bundler**: The resulting SPIR-V is embedded in the Clang
709713
offload bundler with the bundle ID ``hip-spirv64-amd-amdhsa--amdgcnspirv``.
710714

711-
Mixed with Normal ``--offload-arch``
712-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
713-
714-
**Mixing ``amdgcnspirv`` and concrete ``gfx###`` targets via ``--offload-arch``
715-
is not currently supported; this limitation is temporary and will be removed in
716-
a future release**
717-
718715
Architecture Specific Macros
719716
----------------------------
720717

clang/docs/ReleaseNotes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,7 @@ Improvements to Clang's diagnostics
855855
}
856856

857857
- Fix -Wdangling false positives on conditional operators (#120206).
858+
- Clang now diagnoses unused private fields with the ``[[warn_unused]]`` attribute (#GH62472).
858859

859860
- Fixed a bug where Clang hung on an unsupported optional scope specifier ``::`` when parsing
860861
Objective-C. Clang now emits a diagnostic message instead of hanging.
@@ -1065,6 +1066,10 @@ Bug Fixes to C++ Support
10651066
- Fix immediate escalation not propagating through inherited constructors. (#GH112677)
10661067
- Fixed assertions or false compiler diagnostics in the case of C++ modules for
10671068
lambda functions or inline friend functions defined inside templates (#GH122493).
1069+
- Fix template argument checking so that converted template arguments are
1070+
converted again. This fixes some issues with partial ordering involving
1071+
template template parameters with non-type template parameters.
1072+
- Fix nondeduced mismatch with nullptr template arguments.
10681073
- Clang now rejects declaring an alias template with the same name as its template parameter. (#GH123423)
10691074
- Fixed the rejection of valid code when referencing an enumerator of an unscoped enum member with a prior declaration. (#GH124405)
10701075
- Fixed immediate escalation of non-dependent expressions. (#GH123405)

clang/include/clang/Basic/BuiltinsNVPTX.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ class PTX<string version, PTXFeatures newer> : PTXFeatures {
4848
let Features = !strconcat("ptx", version, "|", newer.Features);
4949
}
5050

51-
let Features = "ptx86" in def PTX86 : PTXFeatures;
51+
let Features = "ptx87" in def PTX87 : PTXFeatures;
5252

53+
def PTX86 : PTX<"86", PTX87>;
5354
def PTX85 : PTX<"85", PTX86>;
5455
def PTX84 : PTX<"84", PTX85>;
5556
def PTX83 : PTX<"83", PTX84>;

clang/include/clang/Basic/Version.inc.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
#define CLANG_VERSION_MAJOR_STRING "@CLANG_VERSION_MAJOR@"
55
#define CLANG_VERSION_MINOR @CLANG_VERSION_MINOR@
66
#define CLANG_VERSION_PATCHLEVEL @CLANG_VERSION_PATCHLEVEL@
7+
#define MAX_CLANG_ABI_COMPAT_VERSION @MAX_CLANG_ABI_COMPAT_VERSION@

clang/include/clang/Sema/Sema.h

Lines changed: 45 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11651,6 +11651,33 @@ class Sema final : public SemaBase {
1165111651
CTAK_DeducedFromArrayBound
1165211652
};
1165311653

11654+
struct CheckTemplateArgumentInfo {
11655+
explicit CheckTemplateArgumentInfo(bool PartialOrdering = false,
11656+
bool MatchingTTP = false)
11657+
: PartialOrdering(PartialOrdering), MatchingTTP(MatchingTTP) {}
11658+
CheckTemplateArgumentInfo(const CheckTemplateArgumentInfo &) = delete;
11659+
CheckTemplateArgumentInfo &
11660+
operator=(const CheckTemplateArgumentInfo &) = delete;
11661+
11662+
/// The checked, converted argument will be added to the
11663+
/// end of these vectors.
11664+
SmallVector<TemplateArgument, 4> SugaredConverted, CanonicalConverted;
11665+
11666+
/// The check is being performed in the context of partial ordering.
11667+
bool PartialOrdering;
11668+
11669+
/// If true, assume these template arguments are
11670+
/// the injected template arguments for a template template parameter.
11671+
/// This will relax the requirement that all its possible uses are valid:
11672+
/// TTP checking is loose, and assumes that invalid uses will be diagnosed
11673+
/// during instantiation.
11674+
bool MatchingTTP;
11675+
11676+
/// Is set to true when, in the context of TTP matching, a pack parameter
11677+
/// matches non-pack arguments.
11678+
bool MatchedPackOnParmToNonPackOnArg = false;
11679+
};
11680+
1165411681
/// Check that the given template argument corresponds to the given
1165511682
/// template parameter.
1165611683
///
@@ -11670,22 +11697,16 @@ class Sema final : public SemaBase {
1167011697
/// \param ArgumentPackIndex The index into the argument pack where this
1167111698
/// argument will be placed. Only valid if the parameter is a parameter pack.
1167211699
///
11673-
/// \param Converted The checked, converted argument will be added to the
11674-
/// end of this small vector.
11675-
///
1167611700
/// \param CTAK Describes how we arrived at this particular template argument:
1167711701
/// explicitly written, deduced, etc.
1167811702
///
1167911703
/// \returns true on error, false otherwise.
11680-
bool
11681-
CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg,
11682-
NamedDecl *Template, SourceLocation TemplateLoc,
11683-
SourceLocation RAngleLoc, unsigned ArgumentPackIndex,
11684-
SmallVectorImpl<TemplateArgument> &SugaredConverted,
11685-
SmallVectorImpl<TemplateArgument> &CanonicalConverted,
11686-
CheckTemplateArgumentKind CTAK, bool PartialOrdering,
11687-
bool PartialOrderingTTP,
11688-
bool *MatchedPackOnParmToNonPackOnArg);
11704+
bool CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg,
11705+
NamedDecl *Template, SourceLocation TemplateLoc,
11706+
SourceLocation RAngleLoc,
11707+
unsigned ArgumentPackIndex,
11708+
CheckTemplateArgumentInfo &CTAI,
11709+
CheckTemplateArgumentKind CTAK);
1168911710

1169011711
/// Check that the given template arguments can be provided to
1169111712
/// the given template, converting the arguments along the way.
@@ -11718,22 +11739,15 @@ class Sema final : public SemaBase {
1171811739
/// \param DefaultArgs any default arguments from template specialization
1171911740
/// deduction.
1172011741
///
11721-
/// \param PartialOrderingTTP If true, assume these template arguments are
11722-
/// the injected template arguments for a template template parameter.
11723-
/// This will relax the requirement that all its possible uses are valid:
11724-
/// TTP checking is loose, and assumes that invalid uses will be diagnosed
11725-
/// during instantiation.
11726-
///
1172711742
/// \returns true if an error occurred, false otherwise.
11728-
bool CheckTemplateArgumentList(
11729-
TemplateDecl *Template, SourceLocation TemplateLoc,
11730-
TemplateArgumentListInfo &TemplateArgs,
11731-
const DefaultArguments &DefaultArgs, bool PartialTemplateArgs,
11732-
SmallVectorImpl<TemplateArgument> &SugaredConverted,
11733-
SmallVectorImpl<TemplateArgument> &CanonicalConverted,
11734-
bool UpdateArgsWithConversions = true,
11735-
bool *ConstraintsNotSatisfied = nullptr, bool PartialOrderingTTP = false,
11736-
bool *MatchedPackOnParmToNonPackOnArg = nullptr);
11743+
bool CheckTemplateArgumentList(TemplateDecl *Template,
11744+
SourceLocation TemplateLoc,
11745+
TemplateArgumentListInfo &TemplateArgs,
11746+
const DefaultArguments &DefaultArgs,
11747+
bool PartialTemplateArgs,
11748+
CheckTemplateArgumentInfo &CTAI,
11749+
bool UpdateArgsWithConversions = true,
11750+
bool *ConstraintsNotSatisfied = nullptr);
1173711751

1173811752
bool CheckTemplateTypeArgument(
1173911753
TemplateTypeParmDecl *Param, TemplateArgumentLoc &Arg,
@@ -11758,7 +11772,7 @@ class Sema final : public SemaBase {
1175811772
QualType InstantiatedParamType, Expr *Arg,
1175911773
TemplateArgument &SugaredConverted,
1176011774
TemplateArgument &CanonicalConverted,
11761-
bool PartialOrderingTTP,
11775+
bool MatchingTTP,
1176211776
CheckTemplateArgumentKind CTAK);
1176311777

1176411778
/// Check a template argument against its corresponding
@@ -11780,6 +11794,9 @@ class Sema final : public SemaBase {
1178011794
/// declaration and the type of its corresponding non-type template
1178111795
/// parameter, produce an expression that properly refers to that
1178211796
/// declaration.
11797+
/// FIXME: This is used in some contexts where the resulting expression
11798+
/// doesn't need to live too long. It would be useful if this function
11799+
/// could return a temporary expression.
1178311800
ExprResult BuildExpressionFromDeclTemplateArgument(
1178411801
const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc,
1178511802
NamedDecl *TemplateParam = nullptr);

clang/lib/AST/StmtPrinter.cpp

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,28 +1257,48 @@ void StmtPrinter::VisitConstantExpr(ConstantExpr *Node) {
12571257
}
12581258

12591259
void StmtPrinter::VisitDeclRefExpr(DeclRefExpr *Node) {
1260-
if (const auto *OCED = dyn_cast<OMPCapturedExprDecl>(Node->getDecl())) {
1260+
ValueDecl *VD = Node->getDecl();
1261+
if (const auto *OCED = dyn_cast<OMPCapturedExprDecl>(VD)) {
12611262
OCED->getInit()->IgnoreImpCasts()->printPretty(OS, nullptr, Policy);
12621263
return;
12631264
}
1264-
if (const auto *TPOD = dyn_cast<TemplateParamObjectDecl>(Node->getDecl())) {
1265+
if (const auto *TPOD = dyn_cast<TemplateParamObjectDecl>(VD)) {
12651266
TPOD->printAsExpr(OS, Policy);
12661267
return;
12671268
}
12681269
if (NestedNameSpecifier *Qualifier = Node->getQualifier())
12691270
Qualifier->print(OS, Policy);
12701271
if (Node->hasTemplateKeyword())
12711272
OS << "template ";
1272-
if (Policy.CleanUglifiedParameters &&
1273-
isa<ParmVarDecl, NonTypeTemplateParmDecl>(Node->getDecl()) &&
1274-
Node->getDecl()->getIdentifier())
1275-
OS << Node->getDecl()->getIdentifier()->deuglifiedName();
1276-
else
1277-
Node->getNameInfo().printName(OS, Policy);
1273+
DeclarationNameInfo NameInfo = Node->getNameInfo();
1274+
if (IdentifierInfo *ID = NameInfo.getName().getAsIdentifierInfo();
1275+
ID || NameInfo.getName().getNameKind() != DeclarationName::Identifier) {
1276+
if (Policy.CleanUglifiedParameters &&
1277+
isa<ParmVarDecl, NonTypeTemplateParmDecl>(VD) && ID)
1278+
OS << ID->deuglifiedName();
1279+
else
1280+
NameInfo.printName(OS, Policy);
1281+
} else {
1282+
switch (VD->getKind()) {
1283+
case Decl::NonTypeTemplateParm: {
1284+
auto *TD = cast<NonTypeTemplateParmDecl>(VD);
1285+
OS << "value-parameter-" << TD->getDepth() << '-' << TD->getIndex() << "";
1286+
break;
1287+
}
1288+
case Decl::ParmVar: {
1289+
auto *PD = cast<ParmVarDecl>(VD);
1290+
OS << "function-parameter-" << PD->getFunctionScopeDepth() << '-'
1291+
<< PD->getFunctionScopeIndex();
1292+
break;
1293+
}
1294+
default:
1295+
llvm_unreachable("Unhandled anonymous declaration kind");
1296+
}
1297+
}
12781298
if (Node->hasExplicitTemplateArgs()) {
12791299
const TemplateParameterList *TPL = nullptr;
12801300
if (!Node->hadMultipleCandidates())
1281-
if (auto *TD = dyn_cast<TemplateDecl>(Node->getDecl()))
1301+
if (auto *TD = dyn_cast<TemplateDecl>(VD))
12821302
TPL = TD->getTemplateParameters();
12831303
printTemplateArgumentList(OS, Node->template_arguments(), Policy, TPL);
12841304
}

clang/lib/AST/TextNodeDumper.cpp

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,41 @@ void TextNodeDumper::dumpBareDeclRef(const Decl *D) {
901901

902902
if (const NamedDecl *ND = dyn_cast<NamedDecl>(D)) {
903903
ColorScope Color(OS, ShowColors, DeclNameColor);
904-
OS << " '" << ND->getDeclName() << '\'';
904+
if (DeclarationName Name = ND->getDeclName())
905+
OS << " '" << Name << '\'';
906+
else
907+
switch (ND->getKind()) {
908+
case Decl::Decomposition: {
909+
auto *DD = cast<DecompositionDecl>(ND);
910+
OS << " first_binding '" << DD->bindings()[0]->getDeclName() << '\'';
911+
break;
912+
}
913+
case Decl::Field: {
914+
auto *FD = cast<FieldDecl>(ND);
915+
OS << " field_index " << FD->getFieldIndex();
916+
break;
917+
}
918+
case Decl::ParmVar: {
919+
auto *PD = cast<ParmVarDecl>(ND);
920+
OS << " depth " << PD->getFunctionScopeDepth() << " index "
921+
<< PD->getFunctionScopeIndex();
922+
break;
923+
}
924+
case Decl::TemplateTypeParm: {
925+
auto *TD = cast<TemplateTypeParmDecl>(ND);
926+
OS << " depth " << TD->getDepth() << " index " << TD->getIndex();
927+
break;
928+
}
929+
case Decl::NonTypeTemplateParm: {
930+
auto *TD = cast<NonTypeTemplateParmDecl>(ND);
931+
OS << " depth " << TD->getDepth() << " index " << TD->getIndex();
932+
break;
933+
}
934+
default:
935+
// Var, Namespace, (CXX)Record: Nothing else besides source location.
936+
dumpSourceRange(ND->getSourceRange());
937+
break;
938+
}
905939
}
906940

907941
if (const ValueDecl *VD = dyn_cast<ValueDecl>(D))

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2868,7 +2868,7 @@ static bool shouldOmitDefinition(llvm::codegenoptions::DebugInfoKind DebugKind,
28682868
// without any dllimport methods can be used in one DLL and constructed in
28692869
// another, but it is the current behavior of LimitedDebugInfo.
28702870
if (CXXDecl->hasDefinition() && CXXDecl->isDynamicClass() &&
2871-
!isClassOrMethodDLLImport(CXXDecl))
2871+
!isClassOrMethodDLLImport(CXXDecl) && !CXXDecl->hasAttr<MSNoVTableAttr>())
28722872
return true;
28732873

28742874
TemplateSpecializationKind Spec = TSK_Undeclared;

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4541,7 +4541,7 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
45414541
// y or y.0 (4 <= y <= current version).
45424542
if (!VerParts.first.starts_with("0") &&
45434543
!VerParts.first.getAsInteger(10, Major) && 3 <= Major &&
4544-
Major <= CLANG_VERSION_MAJOR &&
4544+
Major <= MAX_CLANG_ABI_COMPAT_VERSION &&
45454545
(Major == 3
45464546
? VerParts.second.size() == 1 &&
45474547
!VerParts.second.getAsInteger(10, Minor)

0 commit comments

Comments
 (0)