Skip to content

[AArch64] Extend SVE diagnostics. #94976

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions clang/lib/Sema/Sema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2093,16 +2093,15 @@ void Sema::checkTypeSupport(QualType Ty, SourceLocation Loc, ValueDecl *D) {
}

// Don't allow SVE types in functions without a SVE target.
if (Ty->isSVESizelessBuiltinType() && FD && FD->hasBody()) {
if (Ty->isSVESizelessBuiltinType() && FD) {
llvm::StringMap<bool> CallerFeatureMap;
Context.getFunctionFeatureMap(CallerFeatureMap, FD);
if (!Builtin::evaluateRequiredTargetFeatures("sve", CallerFeatureMap)) {
if (!Builtin::evaluateRequiredTargetFeatures("sme", CallerFeatureMap))
Diag(D->getLocation(), diag::err_sve_vector_in_non_sve_target) << Ty;
Diag(Loc, diag::err_sve_vector_in_non_sve_target) << Ty;
else if (!IsArmStreamingFunction(FD,
/*IncludeLocallyStreaming=*/true)) {
Diag(D->getLocation(), diag::err_sve_vector_in_non_streaming_function)
<< Ty;
Diag(Loc, diag::err_sve_vector_in_non_streaming_function) << Ty;
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions clang/test/CodeGen/aarch64-targetattr-arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,18 @@ float16_t test_fp16_on_v9(float16_t x, float16_t y)
return vabdh_f16(x, y);
}

void test_errors()
void test_error1()
{
#ifdef HAS8
// expected-error@+2{{always_inline function '__crc32cd' requires target feature 'crc'}}
#endif
__crc32cd(1, 1);
}

void test_error2()
{
#if defined(HAS8) || defined(HAS81)
// expected-error@+2{{'svundef_s8' needs target feature sve}}
// expected-error@+2{{SVE vector type 'svint8_t' (aka '__SVInt8_t') cannot be used in a target without sve}}
#endif
svundef_s8();
}
28 changes: 18 additions & 10 deletions clang/test/CodeGen/aarch64_neon_sve_bridge_intrinsics/target.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,23 @@ void target_svebf16(svbfloat16_t t, bfloat16x8_t m) {
}

void base(int8x16_t n, bfloat16x8_t m) {
// expected-error@+1 {{'svundef_s8' needs target feature sve}}
svset_neonq_s8(svundef_s8(), n); // expected-error {{'svset_neonq_s8' needs target feature sve}}
// expected-error@+1 {{'svundef_s8' needs target feature sve}}
svget_neonq_s8(svundef_s8()); // expected-error {{'svget_neonq_s8' needs target feature sve}}
svdup_neonq_s8(n); // expected-error {{'svdup_neonq_s8' needs target feature sve}}
// expected-error@+3 {{SVE vector type 'svint8_t' (aka '__SVInt8_t') cannot be used in a target without sve}}
// expected-error@+2 {{SVE vector type 'svint8_t' (aka '__SVInt8_t') cannot be used in a target without sve}}
// expected-error@+1 {{SVE vector type 'svint8_t' (aka '__SVInt8_t') cannot be used in a target without sve}}
svset_neonq_s8(svundef_s8(), n);
// expected-error@+2 {{SVE vector type 'svint8_t' (aka '__SVInt8_t') cannot be used in a target without sve}}
// expected-error@+1 {{SVE vector type 'svint8_t' (aka '__SVInt8_t') cannot be used in a target without sve}}
svget_neonq_s8(svundef_s8());
// expected-error@+1 {{SVE vector type 'svint8_t' (aka '__SVInt8_t') cannot be used in a target without sve}}
svdup_neonq_s8(n);

// expected-error@+1 {{'svundef_bf16' needs target feature sve}}
svset_neonq_bf16(svundef_bf16(), m); // expected-error {{'svset_neonq_bf16' needs target feature sve,bf16}}
// expected-error@+1 {{'svundef_bf16' needs target feature sve}}
svget_neonq_bf16(svundef_bf16()); // expected-error {{'svget_neonq_bf16' needs target feature sve,bf16}}
svdup_neonq_bf16(m); // expected-error {{'svdup_neonq_bf16' needs target feature sve,bf16}}
// expected-error@+3 {{SVE vector type 'svbfloat16_t' (aka '__SVBfloat16_t') cannot be used in a target without sve}}
// expected-error@+2 {{SVE vector type 'svbfloat16_t' (aka '__SVBfloat16_t') cannot be used in a target without sve}}
// expected-error@+1 {{SVE vector type 'svbfloat16_t' (aka '__SVBfloat16_t') cannot be used in a target without sve}}
svset_neonq_bf16(svundef_bf16(), m);
// expected-error@+2 {{SVE vector type 'svbfloat16_t' (aka '__SVBfloat16_t') cannot be used in a target without sve}}
// expected-error@+1 {{SVE vector type 'svbfloat16_t' (aka '__SVBfloat16_t') cannot be used in a target without sve}}
svget_neonq_bf16(svundef_bf16());
// expected-error@+1 {{SVE vector type 'svbfloat16_t' (aka '__SVBfloat16_t') cannot be used in a target without sve}}
svdup_neonq_bf16(m);
}
4 changes: 2 additions & 2 deletions clang/test/CodeGenCXX/aarch64-mangle-sve-vectors.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 3
// RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64-none-linux-gnu %s -emit-llvm -o - \
// RUN: -target-feature +sve,+bf16 | FileCheck %s
// RUN: -target-feature +sve -target-feature +bf16 | FileCheck %s
// RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64-none-linux-gnu %s -emit-llvm -o - \
// RUN: -target-feature +sve,+bf16 -fclang-abi-compat=17 | FileCheck %s --check-prefix=COMPAT_17
// RUN: -target-feature +sve -target-feature +bf16 -fclang-abi-compat=17 | FileCheck %s --check-prefix=COMPAT_17

void f(__SVInt8_t, __SVInt8_t);
void f(__SVInt16_t, __SVInt16_t);
Expand Down
3 changes: 3 additions & 0 deletions clang/test/Sema/aarch64-sme2-sve2p1-diagnostics.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
// expected-error@+2 {{SVE vector type 'svuint8x2_t' (aka '__clang_svuint8x2_t') cannot be used in a non-streaming function}}
__attribute__((target("+sme2")))
svuint8x2_t sme2_or_sve2p1_intrinsic_test_sme2_invalid(svcount_t png, const uint8_t *rn) {
// expected-error@+4 {{SVE vector type 'svcount_t' (aka '__SVCount_t') cannot be used in a non-streaming function}}
// expected-error@+3 {{SVE vector type 'svuint8x2_t' (aka '__clang_svuint8x2_t') cannot be used in a non-streaming function}}
// expected-error@+2 {{SVE vector type 'svcount_t' (aka '__SVCount_t') cannot be used in a non-streaming function}}
// expected-warning@+1 {{builtin call has undefined behaviour when called from a non-streaming function}}
return svldnt1_u8_x2(png, rn);
}
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Sema/arm-sve-target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void test_var_target3() {

__SVFloat32_t other_ret();
__SVFloat32_t test_ret() { // expected-error {{SVE vector type '__SVFloat32_t' cannot be used in a target without sve}}
return other_ret();
return other_ret(); // expected-error {{SVE vector type '__SVFloat32_t' cannot be used in a target without sve}}
}

__attribute__((target("sve")))
Expand Down
Loading