Skip to content

Commit

Permalink
Merged main:066b4fcb8df2 into amd-gfx:504bb99465e5
Browse files Browse the repository at this point in the history
Local branch amd-gfx 504bb99 Merged main:c441f65f9183 into amd-gfx:9f2c08e8b1bc
Remote branch main 066b4fc [mlir] Update VectorToGPU to new memory space
  • Loading branch information
SC llvm team authored and SC llvm team committed Jan 19, 2023
2 parents 504bb99 + 066b4fc commit 17549ba
Show file tree
Hide file tree
Showing 188 changed files with 9,241 additions and 1,796 deletions.
1 change: 1 addition & 0 deletions clang-tools-extra/clangd/fuzzer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ clang_target_link_libraries(clangd-fuzzer
clangBasic
clangFormat
clangFrontend
clangIncludeCleaner
clangSema
clangTooling
clangToolingCore
Expand Down
5 changes: 5 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@ Bug Fixes
This fixes `Issue 59765 <https://github.com/llvm/llvm-project/issues/59765>`_
- Reject in-class defaulting of previosly declared comparison operators. Fixes
`Issue 51227 <https://github.com/llvm/llvm-project/issues/51227>`_.
- Fix the bug of inserting the ``ZeroInitializationFixit`` before the template
argument list of ``VarTemplateSpecializationDecl``.

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

- Fixed an issue with concept requirement evaluation, where we incorrectly allowed implicit
conversions to bool for a requirement. This fixes `GH54524 <https://github.com/llvm/llvm-project/issues/54524>`_.

C++2b Feature Support
^^^^^^^^^^^^^^^^^^^^^

Expand Down
16 changes: 16 additions & 0 deletions clang/include/clang/AST/DeclTemplate.h
Original file line number Diff line number Diff line change
Expand Up @@ -2926,6 +2926,14 @@ class VarTemplateSpecializationDecl : public VarDecl,
return ExplicitInfo ? ExplicitInfo->TemplateKeywordLoc : SourceLocation();
}

SourceRange getSourceRange() const override LLVM_READONLY {
if (isExplicitSpecialization()) {
if (const ASTTemplateArgumentListInfo *Info = getTemplateArgsInfo())
return SourceRange(getOuterLocStart(), Info->getRAngleLoc());
}
return VarDecl::getSourceRange();
}

void Profile(llvm::FoldingSetNodeID &ID) const {
Profile(ID, TemplateArgs->asArray(), getASTContext());
}
Expand Down Expand Up @@ -3083,6 +3091,14 @@ class VarTemplatePartialSpecializationDecl
return First->InstantiatedFromMember.setInt(true);
}

SourceRange getSourceRange() const override LLVM_READONLY {
if (isExplicitSpecialization()) {
if (const ASTTemplateArgumentListInfo *Info = getTemplateArgsAsWritten())
return SourceRange(getOuterLocStart(), Info->getRAngleLoc());
}
return VarDecl::getSourceRange();
}

void Profile(llvm::FoldingSetNodeID &ID) const {
Profile(ID, getTemplateArgs().asArray(), getTemplateParameters(),
getASTContext());
Expand Down
22 changes: 13 additions & 9 deletions clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,20 @@ static Value *mergeDistinctValues(QualType Type, Value &Val1,
Environment::ValueModel &Model) {
// Join distinct boolean values preserving information about the constraints
// in the respective path conditions.
if (Type->isBooleanType()) {
// FIXME: The type check above is a workaround and should be unnecessary.
// However, right now we can end up with BoolValue's in integer-typed
// variables due to our incorrect handling of boolean-to-integer casts (we
// just propagate the BoolValue to the result of the cast). For example:
if (isa<BoolValue>(&Val1) && isa<BoolValue>(&Val2)) {
// FIXME: Checking both values should be unnecessary, since they should have
// a consistent shape. However, right now we can end up with BoolValue's in
// integer-typed variables due to our incorrect handling of
// boolean-to-integer casts (we just propagate the BoolValue to the result
// of the cast). So, a join can encounter an integer in one branch but a
// bool in the other.
// For example:
// ```
// std::optional<bool> o;
//
//
// int x;
// if (o.has_value()) {
// if (o.has_value())
// x = o.value();
// }
// ```
auto *Expr1 = cast<BoolValue>(&Val1);
auto *Expr2 = cast<BoolValue>(&Val2);
auto &MergedVal = MergedEnv.makeAtomicBoolValue();
Expand All @@ -118,6 +120,8 @@ static Value *mergeDistinctValues(QualType Type, Value &Val1,

// FIXME: Consider destroying `MergedValue` immediately if `ValueModel::merge`
// returns false to avoid storing unneeded values in `DACtx`.
// FIXME: Creating the value based on the type alone creates misshapen values
// for lvalues, since the type does not reflect the need for `ReferenceValue`.
if (Value *MergedVal = MergedEnv.createValue(Type))
if (Model.merge(Type, Val1, Env1, Val2, Env2, *MergedVal, MergedEnv))
return MergedVal;
Expand Down
2 changes: 2 additions & 0 deletions clang/lib/Analysis/FlowSensitive/Transfer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ static BoolValue &unpackValue(BoolValue &V, Environment &Env) {
// Unpacks the value (if any) associated with `E` and updates `E` to the new
// value, if any unpacking occured.
static Value *maybeUnpackLValueExpr(const Expr &E, Environment &Env) {
// FIXME: this is too flexible: it _allows_ a reference, while it should
// _require_ one, since lvalues should always be wrapped in `ReferenceValue`.
auto *Loc = Env.getStorageLocation(E, SkipPast::Reference);
if (Loc == nullptr)
return nullptr;
Expand Down
18 changes: 9 additions & 9 deletions clang/lib/Basic/Targets/AArch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,43 +60,43 @@ void AArch64TargetInfo::setArchFeatures() {
HasLSE = true;
HasRDM = true;
} else if (ArchInfo->Version.getMajor() == 8) {
if (ArchInfo->Version.getMinor() >= 7) {
if (ArchInfo->Version.getMinor() >= 7u) {
HasWFxT = true;
}
if (ArchInfo->Version.getMinor() >= 6) {
if (ArchInfo->Version.getMinor() >= 6u) {
HasBFloat16 = true;
HasMatMul = true;
}
if (ArchInfo->Version.getMinor() >= 5) {
if (ArchInfo->Version.getMinor() >= 5u) {
HasAlternativeNZCV = true;
HasFRInt3264 = true;
HasSSBS = true;
HasSB = true;
HasPredRes = true;
HasBTI = true;
}
if (ArchInfo->Version.getMinor() >= 4) {
if (ArchInfo->Version.getMinor() >= 4u) {
HasDotProd = true;
HasDIT = true;
HasFlagM = true;
}
if (ArchInfo->Version.getMinor() >= 3) {
if (ArchInfo->Version.getMinor() >= 3u) {
HasRCPC = true;
FPU |= NeonMode;
}
if (ArchInfo->Version.getMinor() >= 2) {
if (ArchInfo->Version.getMinor() >= 2u) {
HasCCPP = true;
}
if (ArchInfo->Version.getMinor() >= 1) {
if (ArchInfo->Version.getMinor() >= 1u) {
HasCRC = true;
HasLSE = true;
HasRDM = true;
}
} else if (ArchInfo->Version.getMajor() == 9) {
if (ArchInfo->Version.getMinor() >= 2) {
if (ArchInfo->Version.getMinor() >= 2u) {
HasWFxT = true;
}
if (ArchInfo->Version.getMinor() >= 1) {
if (ArchInfo->Version.getMinor() >= 1u) {
HasBFloat16 = true;
HasMatMul = true;
}
Expand Down
19 changes: 19 additions & 0 deletions clang/lib/Driver/ToolChains/AIX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,25 @@ void aix::Linker::ConstructJob(Compilation &C, const JobAction &JA,
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
AddRunTimeLibs(ToolChain, D, CmdArgs, Args);

// Add OpenMP runtime if -fopenmp is specified.
if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
options::OPT_fno_openmp, false)) {
switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
case Driver::OMPRT_OMP:
CmdArgs.push_back("-lomp");
break;
case Driver::OMPRT_IOMP5:
CmdArgs.push_back("-liomp5");
break;
case Driver::OMPRT_GOMP:
CmdArgs.push_back("-lgomp");
break;
case Driver::OMPRT_Unknown:
// Already diagnosed.
break;
}
}

// Support POSIX threads if "-pthreads" or "-pthread" is present.
if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
CmdArgs.push_back("-lpthreads");
Expand Down
25 changes: 17 additions & 8 deletions clang/lib/Sema/SemaConcept.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,14 +329,7 @@ static ExprResult calculateConstraintSatisfaction(
Sema::SFINAETrap Trap(S);
SubstitutedExpression =
S.SubstConstraintExpr(const_cast<Expr *>(AtomicExpr), MLTAL);
// Substitution might have stripped off a contextual conversion to
// bool if this is the operand of an '&&' or '||'. For example, we
// might lose an lvalue-to-rvalue conversion here. If so, put it back
// before we try to evaluate.
if (SubstitutedExpression.isUsable() &&
!SubstitutedExpression.isInvalid())
SubstitutedExpression =
S.PerformContextuallyConvertToBool(SubstitutedExpression.get());

if (SubstitutedExpression.isInvalid() || Trap.hasErrorOccurred()) {
// C++2a [temp.constr.atomic]p1
// ...If substitution results in an invalid type or expression, the
Expand Down Expand Up @@ -373,6 +366,22 @@ static ExprResult calculateConstraintSatisfaction(
if (!S.CheckConstraintExpression(SubstitutedExpression.get()))
return ExprError();

// [temp.constr.atomic]p3: To determine if an atomic constraint is
// satisfied, the parameter mapping and template arguments are first
// substituted into its expression. If substitution results in an
// invalid type or expression, the constraint is not satisfied.
// Otherwise, the lvalue-to-rvalue conversion is performed if necessary,
// and E shall be a constant expression of type bool.
//
// Perform the L to R Value conversion if necessary. We do so for all
// non-PRValue categories, else we fail to extend the lifetime of
// temporaries, and that fails the constant expression check.
if (!SubstitutedExpression.get()->isPRValue())
SubstitutedExpression = ImplicitCastExpr::Create(
S.Context, SubstitutedExpression.get()->getType(),
CK_LValueToRValue, SubstitutedExpression.get(),
/*BasePath=*/nullptr, VK_PRValue, FPOptionsOverride());

return SubstitutedExpression;
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// RUN: %clang_cc1 -std=c++20 -x c++ -Wno-constant-logical-operand -verify %s

template<typename T> concept C =
sizeof(T) == 4 && !true; // requires atomic constraints sizeof(T) == 4 and !true

template<typename T> concept C2 = sizeof(T); // expected-error{{atomic constraint must be of type 'bool' (found }}

template<typename T> struct S {
constexpr operator bool() const { return true; }
};

// expected-error@+3{{atomic constraint must be of type 'bool' (found 'S<int>')}}
// expected-note@#FINST{{while checking constraint satisfaction}}
// expected-note@#FINST{{in instantiation of function template specialization}}
template<typename T> requires (S<T>{})
void f(T);
void f(int);

// Ensure this applies to operator && as well.
// expected-error@+3{{atomic constraint must be of type 'bool' (found 'S<int>')}}
// expected-note@#F2INST{{while checking constraint satisfaction}}
// expected-note@#F2INST{{in instantiation of function template specialization}}
template<typename T> requires (S<T>{} && true)
void f2(T);
void f2(int);

template<typename T> requires requires {
requires S<T>{};
// expected-error@-1{{atomic constraint must be of type 'bool' (found 'S<int>')}}
// expected-note@-2{{while checking the satisfaction}}
// expected-note@-3{{in instantiation of requirement}}
// expected-note@-4{{while checking the satisfaction}}
// expected-note@-6{{while substituting template arguments}}
// expected-note@#F3INST{{while checking constraint satisfaction}}
// expected-note@#F3INST{{in instantiation of function template specialization}}
//
}
void f3(T);
void f3(int);

// Doesn't diagnose, since this is no longer a compound requirement.
template<typename T> requires (bool(1 && 2))
void f4(T);
void f4(int);

void g() {
f(0); // #FINST
f2(0); // #F2INST
f3(0); // #F3INST
f4(0);
}

template<typename T>
auto Nullptr = nullptr;

template<typename T> concept NullTy = Nullptr<T>;
// expected-error@-1{{atomic constraint must be of type 'bool' (found }}
// expected-note@+1{{while checking the satisfaction}}
static_assert(NullTy<int>);

template<typename T>
auto Struct = S<T>{};

template<typename T> concept StructTy = Struct<T>;
// expected-error@-1{{atomic constraint must be of type 'bool' (found 'S<int>')}}
// expected-note@+1{{while checking the satisfaction}}
static_assert(StructTy<int>);
7 changes: 7 additions & 0 deletions clang/test/CodeGen/aarch64-targetattr-arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#endif

#include <arm_acle.h>
#include <arm_fp16.h>
#include <arm_sve.h>

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

__attribute__((target("arch=armv9-a")))
float16_t test_fp16_on_v9(float16_t x, float16_t y)
{
return vabdh_f16(x, y);
}

void test_errors()
{
#ifdef HAS8
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CodeGen/aarch64-targetattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void nosimd() {}
// CHECK: attributes #1 = { {{.*}} "target-features"="+crc,+fp-armv8,+fullfp16,+lse,+neon,+ras,+rdm,+sve,+v8.1a,+v8.2a,+v8a" }
// CHECK: attributes #2 = { {{.*}} "target-features"="+crc,+fp-armv8,+fullfp16,+lse,+neon,+ras,+rdm,+sve,+sve2,+v8.1a,+v8.2a,+v8a" }
// 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" }
// 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" }
// 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" }
// CHECK: attributes #5 = { {{.*}} "tune-cpu"="cortex-a710" }
// CHECK: attributes #6 = { {{.*}} "target-cpu"="generic" }
// CHECK: attributes #7 = { {{.*}} "tune-cpu"="generic" }
Expand Down
65 changes: 65 additions & 0 deletions clang/test/Driver/aix-ld.c
Original file line number Diff line number Diff line change
Expand Up @@ -1016,3 +1016,68 @@
// CHECK-LD64-SHARED-EXPFULL: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc64.a"
// CHECK-LD64-SHARED-EXPFULL: "-lm"
// CHECK-LD64-SHARED-EXPFULL: "-lc"

// Check powerpc-ibm-aix7.1.0.0. -fopenmp to use default OpenMP runtime libomp.
// RUN: %clang %s -### 2>&1 \
// RUN: -resource-dir=%S/Inputs/resource_dir \
// RUN: --target=powerpc-ibm-aix7.1.0.0 \
// RUN: --sysroot %S/Inputs/aix_ppc_tree \
// RUN: --unwindlib=libunwind \
// RUN: -fopenmp \
// RUN: | FileCheck --check-prefixes=CHECK-FOPENMP,CHECK-FOPENMP-OMP %s
// CHECK-FOPENMP-NOT: warning:
// CHECK-FOPENMP: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
// CHECK-FOPENMP: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
// CHECK-FOPENMP: "-isysroot" "[[SYSROOT:[^"]+]]"
// CHECK-FOPENMP: "{{.*}}ld{{(.exe)?}}"
// CHECK-FOPENMP-NOT: "-bnso"
// CHECK-FOPENMP: "-b32"
// CHECK-FOPENMP: "-bpT:0x10000000" "-bpD:0x20000000"
// CHECK-FOPENMP: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0.o"
// CHECK-FOPENMP: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti.o"
// CHECK-FOPENMP-NOT: "-lc++"
// CHECK-FOPENMP-NOT: "-lc++abi"
// CHECK-FOPENMP: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aix{{/|\\\\}}libclang_rt.builtins-powerpc.a"
// CHECK-FOPENMP-NOT: "--as-needed"
// CHECK-FOPENMP: "-lunwind"
// CHECK-FOPENMP-NOT: "--no-as-needed"
// CHECK-FOPENMP-NOT: "-lm"
// CHECK-FOPENMP-OMP: "-lomp"
// CHECK-FOPENMP-IOMP5: "-liomp5"
// CHECK-FOPENMP-GOMP: "-lgomp"
// CHECK-FOPENMP: "-lc"

// Check powerpc-ibm-aix7.1.0.0. -fopenmp=libomp to specify libomp explicitly.
// RUN: %clang %s -### 2>&1 \
// RUN: -resource-dir=%S/Inputs/resource_dir \
// RUN: --target=powerpc-ibm-aix7.1.0.0 \
// RUN: --sysroot %S/Inputs/aix_ppc_tree \
// RUN: --unwindlib=libunwind \
// RUN: -fopenmp=libomp \
// RUN: | FileCheck --check-prefixes=CHECK-FOPENMP,CHECK-FOPENMP-OMP %s

// Check powerpc-ibm-aix7.1.0.0. -fopenmp=libiomp5 to specify libgomp explicitly.
// RUN: %clang %s -### 2>&1 \
// RUN: -resource-dir=%S/Inputs/resource_dir \
// RUN: --target=powerpc-ibm-aix7.1.0.0 \
// RUN: --sysroot %S/Inputs/aix_ppc_tree \
// RUN: --unwindlib=libunwind \
// RUN: -fopenmp=libiomp5 \
// RUN: | FileCheck --check-prefixes=CHECK-FOPENMP,CHECK-FOPENMP-IOMP5 %s

// Check powerpc-ibm-aix7.1.0.0. -fopenmp=libgomp to specify libgomp explicitly.
// RUN: %clang %s -### 2>&1 \
// RUN: -resource-dir=%S/Inputs/resource_dir \
// RUN: --target=powerpc-ibm-aix7.1.0.0 \
// RUN: --sysroot %S/Inputs/aix_ppc_tree \
// RUN: --unwindlib=libunwind \
// RUN: -fopenmp=libgomp \
// RUN: | FileCheck --check-prefixes=CHECK-FOPENMP,CHECK-FOPENMP-GOMP %s

// Check powerpc-ibm-aix7.1.0.0, 32-bit. -fopenmp=libfoo results an error.
// RUN: %clang %s 2>&1 -### \
// RUN: --target=powerpc-ibm-aix7.1.0.0 \
// RUN: --sysroot %S/Inputs/aix_ppc_tree \
// RUN: -fopenmp=libfoo \
// RUN: | FileCheck --check-prefixes=CHECK-FOPENMP-FOO %s
// CHECK-FOPENMP-FOO: error: unsupported argument 'libfoo' to option '-fopenmp='
Loading

0 comments on commit 17549ba

Please sign in to comment.