Skip to content

Commit 17549ba

Browse files
SC llvm teamSC llvm team
SC llvm team
authored and
SC llvm team
committed
Merged main:066b4fcb8df2 into amd-gfx:504bb99465e5
Local branch amd-gfx 504bb99 Merged main:c441f65f9183 into amd-gfx:9f2c08e8b1bc Remote branch main 066b4fc [mlir] Update VectorToGPU to new memory space
2 parents 504bb99 + 066b4fc commit 17549ba

File tree

188 files changed

+9241
-1796
lines changed

Some content is hidden

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

188 files changed

+9241
-1796
lines changed

clang-tools-extra/clangd/fuzzer/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ clang_target_link_libraries(clangd-fuzzer
1414
clangBasic
1515
clangFormat
1616
clangFrontend
17+
clangIncludeCleaner
1718
clangSema
1819
clangTooling
1920
clangToolingCore

clang/docs/ReleaseNotes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,8 @@ Bug Fixes
350350
This fixes `Issue 59765 <https://github.com/llvm/llvm-project/issues/59765>`_
351351
- Reject in-class defaulting of previosly declared comparison operators. Fixes
352352
`Issue 51227 <https://github.com/llvm/llvm-project/issues/51227>`_.
353+
- Fix the bug of inserting the ``ZeroInitializationFixit`` before the template
354+
argument list of ``VarTemplateSpecializationDecl``.
353355

354356
Improvements to Clang's diagnostics
355357
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -772,6 +774,9 @@ C++20 Feature Support
772774
and `P1975R0: <https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1975r0.html>`_,
773775
which allows parenthesized aggregate-initialization.
774776

777+
- Fixed an issue with concept requirement evaluation, where we incorrectly allowed implicit
778+
conversions to bool for a requirement. This fixes `GH54524 <https://github.com/llvm/llvm-project/issues/54524>`_.
779+
775780
C++2b Feature Support
776781
^^^^^^^^^^^^^^^^^^^^^
777782

clang/include/clang/AST/DeclTemplate.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2926,6 +2926,14 @@ class VarTemplateSpecializationDecl : public VarDecl,
29262926
return ExplicitInfo ? ExplicitInfo->TemplateKeywordLoc : SourceLocation();
29272927
}
29282928

2929+
SourceRange getSourceRange() const override LLVM_READONLY {
2930+
if (isExplicitSpecialization()) {
2931+
if (const ASTTemplateArgumentListInfo *Info = getTemplateArgsInfo())
2932+
return SourceRange(getOuterLocStart(), Info->getRAngleLoc());
2933+
}
2934+
return VarDecl::getSourceRange();
2935+
}
2936+
29292937
void Profile(llvm::FoldingSetNodeID &ID) const {
29302938
Profile(ID, TemplateArgs->asArray(), getASTContext());
29312939
}
@@ -3083,6 +3091,14 @@ class VarTemplatePartialSpecializationDecl
30833091
return First->InstantiatedFromMember.setInt(true);
30843092
}
30853093

3094+
SourceRange getSourceRange() const override LLVM_READONLY {
3095+
if (isExplicitSpecialization()) {
3096+
if (const ASTTemplateArgumentListInfo *Info = getTemplateArgsAsWritten())
3097+
return SourceRange(getOuterLocStart(), Info->getRAngleLoc());
3098+
}
3099+
return VarDecl::getSourceRange();
3100+
}
3101+
30863102
void Profile(llvm::FoldingSetNodeID &ID) const {
30873103
Profile(ID, getTemplateArgs().asArray(), getTemplateParameters(),
30883104
getASTContext());

clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,20 @@ static Value *mergeDistinctValues(QualType Type, Value &Val1,
9393
Environment::ValueModel &Model) {
9494
// Join distinct boolean values preserving information about the constraints
9595
// in the respective path conditions.
96-
if (Type->isBooleanType()) {
97-
// FIXME: The type check above is a workaround and should be unnecessary.
98-
// However, right now we can end up with BoolValue's in integer-typed
99-
// variables due to our incorrect handling of boolean-to-integer casts (we
100-
// just propagate the BoolValue to the result of the cast). For example:
96+
if (isa<BoolValue>(&Val1) && isa<BoolValue>(&Val2)) {
97+
// FIXME: Checking both values should be unnecessary, since they should have
98+
// a consistent shape. However, right now we can end up with BoolValue's in
99+
// integer-typed variables due to our incorrect handling of
100+
// boolean-to-integer casts (we just propagate the BoolValue to the result
101+
// of the cast). So, a join can encounter an integer in one branch but a
102+
// bool in the other.
103+
// For example:
104+
// ```
101105
// std::optional<bool> o;
102-
//
103-
//
104106
// int x;
105-
// if (o.has_value()) {
107+
// if (o.has_value())
106108
// x = o.value();
107-
// }
109+
// ```
108110
auto *Expr1 = cast<BoolValue>(&Val1);
109111
auto *Expr2 = cast<BoolValue>(&Val2);
110112
auto &MergedVal = MergedEnv.makeAtomicBoolValue();
@@ -118,6 +120,8 @@ static Value *mergeDistinctValues(QualType Type, Value &Val1,
118120

119121
// FIXME: Consider destroying `MergedValue` immediately if `ValueModel::merge`
120122
// returns false to avoid storing unneeded values in `DACtx`.
123+
// FIXME: Creating the value based on the type alone creates misshapen values
124+
// for lvalues, since the type does not reflect the need for `ReferenceValue`.
121125
if (Value *MergedVal = MergedEnv.createValue(Type))
122126
if (Model.merge(Type, Val1, Env1, Val2, Env2, *MergedVal, MergedEnv))
123127
return MergedVal;

clang/lib/Analysis/FlowSensitive/Transfer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ static BoolValue &unpackValue(BoolValue &V, Environment &Env) {
110110
// Unpacks the value (if any) associated with `E` and updates `E` to the new
111111
// value, if any unpacking occured.
112112
static Value *maybeUnpackLValueExpr(const Expr &E, Environment &Env) {
113+
// FIXME: this is too flexible: it _allows_ a reference, while it should
114+
// _require_ one, since lvalues should always be wrapped in `ReferenceValue`.
113115
auto *Loc = Env.getStorageLocation(E, SkipPast::Reference);
114116
if (Loc == nullptr)
115117
return nullptr;

clang/lib/Basic/Targets/AArch64.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,43 +60,43 @@ void AArch64TargetInfo::setArchFeatures() {
6060
HasLSE = true;
6161
HasRDM = true;
6262
} else if (ArchInfo->Version.getMajor() == 8) {
63-
if (ArchInfo->Version.getMinor() >= 7) {
63+
if (ArchInfo->Version.getMinor() >= 7u) {
6464
HasWFxT = true;
6565
}
66-
if (ArchInfo->Version.getMinor() >= 6) {
66+
if (ArchInfo->Version.getMinor() >= 6u) {
6767
HasBFloat16 = true;
6868
HasMatMul = true;
6969
}
70-
if (ArchInfo->Version.getMinor() >= 5) {
70+
if (ArchInfo->Version.getMinor() >= 5u) {
7171
HasAlternativeNZCV = true;
7272
HasFRInt3264 = true;
7373
HasSSBS = true;
7474
HasSB = true;
7575
HasPredRes = true;
7676
HasBTI = true;
7777
}
78-
if (ArchInfo->Version.getMinor() >= 4) {
78+
if (ArchInfo->Version.getMinor() >= 4u) {
7979
HasDotProd = true;
8080
HasDIT = true;
8181
HasFlagM = true;
8282
}
83-
if (ArchInfo->Version.getMinor() >= 3) {
83+
if (ArchInfo->Version.getMinor() >= 3u) {
8484
HasRCPC = true;
8585
FPU |= NeonMode;
8686
}
87-
if (ArchInfo->Version.getMinor() >= 2) {
87+
if (ArchInfo->Version.getMinor() >= 2u) {
8888
HasCCPP = true;
8989
}
90-
if (ArchInfo->Version.getMinor() >= 1) {
90+
if (ArchInfo->Version.getMinor() >= 1u) {
9191
HasCRC = true;
9292
HasLSE = true;
9393
HasRDM = true;
9494
}
9595
} else if (ArchInfo->Version.getMajor() == 9) {
96-
if (ArchInfo->Version.getMinor() >= 2) {
96+
if (ArchInfo->Version.getMinor() >= 2u) {
9797
HasWFxT = true;
9898
}
99-
if (ArchInfo->Version.getMinor() >= 1) {
99+
if (ArchInfo->Version.getMinor() >= 1u) {
100100
HasBFloat16 = true;
101101
HasMatMul = true;
102102
}

clang/lib/Driver/ToolChains/AIX.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,25 @@ void aix::Linker::ConstructJob(Compilation &C, const JobAction &JA,
243243
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
244244
AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
245245

246+
// Add OpenMP runtime if -fopenmp is specified.
247+
if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
248+
options::OPT_fno_openmp, false)) {
249+
switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
250+
case Driver::OMPRT_OMP:
251+
CmdArgs.push_back("-lomp");
252+
break;
253+
case Driver::OMPRT_IOMP5:
254+
CmdArgs.push_back("-liomp5");
255+
break;
256+
case Driver::OMPRT_GOMP:
257+
CmdArgs.push_back("-lgomp");
258+
break;
259+
case Driver::OMPRT_Unknown:
260+
// Already diagnosed.
261+
break;
262+
}
263+
}
264+
246265
// Support POSIX threads if "-pthreads" or "-pthread" is present.
247266
if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
248267
CmdArgs.push_back("-lpthreads");

clang/lib/Sema/SemaConcept.cpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -329,14 +329,7 @@ static ExprResult calculateConstraintSatisfaction(
329329
Sema::SFINAETrap Trap(S);
330330
SubstitutedExpression =
331331
S.SubstConstraintExpr(const_cast<Expr *>(AtomicExpr), MLTAL);
332-
// Substitution might have stripped off a contextual conversion to
333-
// bool if this is the operand of an '&&' or '||'. For example, we
334-
// might lose an lvalue-to-rvalue conversion here. If so, put it back
335-
// before we try to evaluate.
336-
if (SubstitutedExpression.isUsable() &&
337-
!SubstitutedExpression.isInvalid())
338-
SubstitutedExpression =
339-
S.PerformContextuallyConvertToBool(SubstitutedExpression.get());
332+
340333
if (SubstitutedExpression.isInvalid() || Trap.hasErrorOccurred()) {
341334
// C++2a [temp.constr.atomic]p1
342335
// ...If substitution results in an invalid type or expression, the
@@ -373,6 +366,22 @@ static ExprResult calculateConstraintSatisfaction(
373366
if (!S.CheckConstraintExpression(SubstitutedExpression.get()))
374367
return ExprError();
375368

369+
// [temp.constr.atomic]p3: To determine if an atomic constraint is
370+
// satisfied, the parameter mapping and template arguments are first
371+
// substituted into its expression. If substitution results in an
372+
// invalid type or expression, the constraint is not satisfied.
373+
// Otherwise, the lvalue-to-rvalue conversion is performed if necessary,
374+
// and E shall be a constant expression of type bool.
375+
//
376+
// Perform the L to R Value conversion if necessary. We do so for all
377+
// non-PRValue categories, else we fail to extend the lifetime of
378+
// temporaries, and that fails the constant expression check.
379+
if (!SubstitutedExpression.get()->isPRValue())
380+
SubstitutedExpression = ImplicitCastExpr::Create(
381+
S.Context, SubstitutedExpression.get()->getType(),
382+
CK_LValueToRValue, SubstitutedExpression.get(),
383+
/*BasePath=*/nullptr, VK_PRValue, FPOptionsOverride());
384+
376385
return SubstitutedExpression;
377386
});
378387
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// RUN: %clang_cc1 -std=c++20 -x c++ -Wno-constant-logical-operand -verify %s
2+
3+
template<typename T> concept C =
4+
sizeof(T) == 4 && !true; // requires atomic constraints sizeof(T) == 4 and !true
5+
6+
template<typename T> concept C2 = sizeof(T); // expected-error{{atomic constraint must be of type 'bool' (found }}
7+
8+
template<typename T> struct S {
9+
constexpr operator bool() const { return true; }
10+
};
11+
12+
// expected-error@+3{{atomic constraint must be of type 'bool' (found 'S<int>')}}
13+
// expected-note@#FINST{{while checking constraint satisfaction}}
14+
// expected-note@#FINST{{in instantiation of function template specialization}}
15+
template<typename T> requires (S<T>{})
16+
void f(T);
17+
void f(int);
18+
19+
// Ensure this applies to operator && as well.
20+
// expected-error@+3{{atomic constraint must be of type 'bool' (found 'S<int>')}}
21+
// expected-note@#F2INST{{while checking constraint satisfaction}}
22+
// expected-note@#F2INST{{in instantiation of function template specialization}}
23+
template<typename T> requires (S<T>{} && true)
24+
void f2(T);
25+
void f2(int);
26+
27+
template<typename T> requires requires {
28+
requires S<T>{};
29+
// expected-error@-1{{atomic constraint must be of type 'bool' (found 'S<int>')}}
30+
// expected-note@-2{{while checking the satisfaction}}
31+
// expected-note@-3{{in instantiation of requirement}}
32+
// expected-note@-4{{while checking the satisfaction}}
33+
// expected-note@-6{{while substituting template arguments}}
34+
// expected-note@#F3INST{{while checking constraint satisfaction}}
35+
// expected-note@#F3INST{{in instantiation of function template specialization}}
36+
//
37+
}
38+
void f3(T);
39+
void f3(int);
40+
41+
// Doesn't diagnose, since this is no longer a compound requirement.
42+
template<typename T> requires (bool(1 && 2))
43+
void f4(T);
44+
void f4(int);
45+
46+
void g() {
47+
f(0); // #FINST
48+
f2(0); // #F2INST
49+
f3(0); // #F3INST
50+
f4(0);
51+
}
52+
53+
template<typename T>
54+
auto Nullptr = nullptr;
55+
56+
template<typename T> concept NullTy = Nullptr<T>;
57+
// expected-error@-1{{atomic constraint must be of type 'bool' (found }}
58+
// expected-note@+1{{while checking the satisfaction}}
59+
static_assert(NullTy<int>);
60+
61+
template<typename T>
62+
auto Struct = S<T>{};
63+
64+
template<typename T> concept StructTy = Struct<T>;
65+
// expected-error@-1{{atomic constraint must be of type 'bool' (found 'S<int>')}}
66+
// expected-note@+1{{while checking the satisfaction}}
67+
static_assert(StructTy<int>);

clang/test/CodeGen/aarch64-targetattr-arch.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#endif
99

1010
#include <arm_acle.h>
11+
#include <arm_fp16.h>
1112
#include <arm_sve.h>
1213

1314
__attribute__((target("arch=armv8.1-a")))
@@ -22,6 +23,12 @@ svint8_t test_svadd_attr(svbool_t pg, svint8_t op1, svint8_t op2)
2223
return svadd_s8_z(pg, op1, op2);
2324
}
2425

26+
__attribute__((target("arch=armv9-a")))
27+
float16_t test_fp16_on_v9(float16_t x, float16_t y)
28+
{
29+
return vabdh_f16(x, y);
30+
}
31+
2532
void test_errors()
2633
{
2734
#ifdef HAS8

clang/test/CodeGen/aarch64-targetattr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void nosimd() {}
9393
// CHECK: attributes #1 = { {{.*}} "target-features"="+crc,+fp-armv8,+fullfp16,+lse,+neon,+ras,+rdm,+sve,+v8.1a,+v8.2a,+v8a" }
9494
// CHECK: attributes #2 = { {{.*}} "target-features"="+crc,+fp-armv8,+fullfp16,+lse,+neon,+ras,+rdm,+sve,+sve2,+v8.1a,+v8.2a,+v8a" }
9595
// CHECK: attributes #3 = { {{.*}} "target-features"="+aes,+bf16,+crc,+dotprod,+fp-armv8,+fullfp16,+i8mm,+lse,+neon,+ras,+rcpc,+rdm,+sha2,+sha3,+sm4,+sve,+sve2,+v8.1a,+v8.2a,+v8.3a,+v8.4a,+v8.5a,+v8.6a,+v8a" }
96-
// CHECK: attributes #4 = { {{.*}} "target-cpu"="cortex-a710" "target-features"="+bf16,+crc,+dotprod,+flagm,+fp-armv8,+fp16fml,+i8mm,+lse,+mte,+neon,+pauth,+ras,+rcpc,+rdm,+sb,+sve,+sve2,+sve2-bitperm" }
96+
// CHECK: attributes #4 = { {{.*}} "target-cpu"="cortex-a710" "target-features"="+bf16,+crc,+dotprod,+flagm,+fp-armv8,+fp16fml,+fullfp16,+i8mm,+lse,+mte,+neon,+pauth,+ras,+rcpc,+rdm,+sb,+sve,+sve2,+sve2-bitperm" }
9797
// CHECK: attributes #5 = { {{.*}} "tune-cpu"="cortex-a710" }
9898
// CHECK: attributes #6 = { {{.*}} "target-cpu"="generic" }
9999
// CHECK: attributes #7 = { {{.*}} "tune-cpu"="generic" }

clang/test/Driver/aix-ld.c

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,3 +1016,68 @@
10161016
// CHECK-LD64-SHARED-EXPFULL: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc64.a"
10171017
// CHECK-LD64-SHARED-EXPFULL: "-lm"
10181018
// CHECK-LD64-SHARED-EXPFULL: "-lc"
1019+
1020+
// Check powerpc-ibm-aix7.1.0.0. -fopenmp to use default OpenMP runtime libomp.
1021+
// RUN: %clang %s -### 2>&1 \
1022+
// RUN: -resource-dir=%S/Inputs/resource_dir \
1023+
// RUN: --target=powerpc-ibm-aix7.1.0.0 \
1024+
// RUN: --sysroot %S/Inputs/aix_ppc_tree \
1025+
// RUN: --unwindlib=libunwind \
1026+
// RUN: -fopenmp \
1027+
// RUN: | FileCheck --check-prefixes=CHECK-FOPENMP,CHECK-FOPENMP-OMP %s
1028+
// CHECK-FOPENMP-NOT: warning:
1029+
// CHECK-FOPENMP: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
1030+
// CHECK-FOPENMP: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
1031+
// CHECK-FOPENMP: "-isysroot" "[[SYSROOT:[^"]+]]"
1032+
// CHECK-FOPENMP: "{{.*}}ld{{(.exe)?}}"
1033+
// CHECK-FOPENMP-NOT: "-bnso"
1034+
// CHECK-FOPENMP: "-b32"
1035+
// CHECK-FOPENMP: "-bpT:0x10000000" "-bpD:0x20000000"
1036+
// CHECK-FOPENMP: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0.o"
1037+
// CHECK-FOPENMP: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti.o"
1038+
// CHECK-FOPENMP-NOT: "-lc++"
1039+
// CHECK-FOPENMP-NOT: "-lc++abi"
1040+
// CHECK-FOPENMP: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc.a"
1041+
// CHECK-FOPENMP-NOT: "--as-needed"
1042+
// CHECK-FOPENMP: "-lunwind"
1043+
// CHECK-FOPENMP-NOT: "--no-as-needed"
1044+
// CHECK-FOPENMP-NOT: "-lm"
1045+
// CHECK-FOPENMP-OMP: "-lomp"
1046+
// CHECK-FOPENMP-IOMP5: "-liomp5"
1047+
// CHECK-FOPENMP-GOMP: "-lgomp"
1048+
// CHECK-FOPENMP: "-lc"
1049+
1050+
// Check powerpc-ibm-aix7.1.0.0. -fopenmp=libomp to specify libomp explicitly.
1051+
// RUN: %clang %s -### 2>&1 \
1052+
// RUN: -resource-dir=%S/Inputs/resource_dir \
1053+
// RUN: --target=powerpc-ibm-aix7.1.0.0 \
1054+
// RUN: --sysroot %S/Inputs/aix_ppc_tree \
1055+
// RUN: --unwindlib=libunwind \
1056+
// RUN: -fopenmp=libomp \
1057+
// RUN: | FileCheck --check-prefixes=CHECK-FOPENMP,CHECK-FOPENMP-OMP %s
1058+
1059+
// Check powerpc-ibm-aix7.1.0.0. -fopenmp=libiomp5 to specify libgomp explicitly.
1060+
// RUN: %clang %s -### 2>&1 \
1061+
// RUN: -resource-dir=%S/Inputs/resource_dir \
1062+
// RUN: --target=powerpc-ibm-aix7.1.0.0 \
1063+
// RUN: --sysroot %S/Inputs/aix_ppc_tree \
1064+
// RUN: --unwindlib=libunwind \
1065+
// RUN: -fopenmp=libiomp5 \
1066+
// RUN: | FileCheck --check-prefixes=CHECK-FOPENMP,CHECK-FOPENMP-IOMP5 %s
1067+
1068+
// Check powerpc-ibm-aix7.1.0.0. -fopenmp=libgomp to specify libgomp explicitly.
1069+
// RUN: %clang %s -### 2>&1 \
1070+
// RUN: -resource-dir=%S/Inputs/resource_dir \
1071+
// RUN: --target=powerpc-ibm-aix7.1.0.0 \
1072+
// RUN: --sysroot %S/Inputs/aix_ppc_tree \
1073+
// RUN: --unwindlib=libunwind \
1074+
// RUN: -fopenmp=libgomp \
1075+
// RUN: | FileCheck --check-prefixes=CHECK-FOPENMP,CHECK-FOPENMP-GOMP %s
1076+
1077+
// Check powerpc-ibm-aix7.1.0.0, 32-bit. -fopenmp=libfoo results an error.
1078+
// RUN: %clang %s 2>&1 -### \
1079+
// RUN: --target=powerpc-ibm-aix7.1.0.0 \
1080+
// RUN: --sysroot %S/Inputs/aix_ppc_tree \
1081+
// RUN: -fopenmp=libfoo \
1082+
// RUN: | FileCheck --check-prefixes=CHECK-FOPENMP-FOO %s
1083+
// CHECK-FOPENMP-FOO: error: unsupported argument 'libfoo' to option '-fopenmp='

0 commit comments

Comments
 (0)