diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index a612dcd4b4d03..907a05a5d1b49 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -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 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; } } } diff --git a/clang/test/CodeGen/aarch64-targetattr-arch.c b/clang/test/CodeGen/aarch64-targetattr-arch.c index ed731d0378625..5de73d6027845 100644 --- a/clang/test/CodeGen/aarch64-targetattr-arch.c +++ b/clang/test/CodeGen/aarch64-targetattr-arch.c @@ -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(); } diff --git a/clang/test/CodeGen/aarch64_neon_sve_bridge_intrinsics/target.c b/clang/test/CodeGen/aarch64_neon_sve_bridge_intrinsics/target.c index a08c452fdc7fe..bc5f01e7ce0ff 100644 --- a/clang/test/CodeGen/aarch64_neon_sve_bridge_intrinsics/target.c +++ b/clang/test/CodeGen/aarch64_neon_sve_bridge_intrinsics/target.c @@ -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); } diff --git a/clang/test/CodeGenCXX/aarch64-mangle-sve-vectors.cpp b/clang/test/CodeGenCXX/aarch64-mangle-sve-vectors.cpp index f87a254f5ae72..752b2beca3881 100644 --- a/clang/test/CodeGenCXX/aarch64-mangle-sve-vectors.cpp +++ b/clang/test/CodeGenCXX/aarch64-mangle-sve-vectors.cpp @@ -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); diff --git a/clang/test/Sema/aarch64-sme2-sve2p1-diagnostics.c b/clang/test/Sema/aarch64-sme2-sve2p1-diagnostics.c index 2012221b48041..97cdd6d9fb3a8 100644 --- a/clang/test/Sema/aarch64-sme2-sve2p1-diagnostics.c +++ b/clang/test/Sema/aarch64-sme2-sve2p1-diagnostics.c @@ -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); } diff --git a/clang/test/Sema/arm-sve-target.cpp b/clang/test/Sema/arm-sve-target.cpp index a753f772cc372..1567475e681da 100644 --- a/clang/test/Sema/arm-sve-target.cpp +++ b/clang/test/Sema/arm-sve-target.cpp @@ -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")))