diff options
author | Gabor Buella <gabor.buella@intel.com> | 2018-06-07 08:48:36 +0000 |
---|---|---|
committer | Gabor Buella <gabor.buella@intel.com> | 2018-06-07 08:48:36 +0000 |
commit | 1a83d067687e2f5eb04b9692d2a59b283d3371eb (patch) | |
tree | 29b90bce3cb9cd9c858f979dc40b069a2261d6f5 /clang/test/CodeGen/target-features-error-2.c | |
parent | b4b2ccea6d8d1be57abf82f39b51137206fd7ada (diff) | |
download | bcm5719-llvm-1a83d067687e2f5eb04b9692d2a59b283d3371eb.tar.gz bcm5719-llvm-1a83d067687e2f5eb04b9692d2a59b283d3371eb.zip |
[CodeGen] Improve diagnostics related to target attributes
Summary:
When requirement imposed by __target__ attributes on functions
are not satisfied, prefer printing those requirements, which
are explicitly mentioned in the attributes.
This makes such messages more useful, e.g. printing avx512f instead of avx2
in the following scenario:
```
$ cat foo.c
static inline void __attribute__((__always_inline__, __target__("avx512f")))
x(void)
{
}
int main(void)
{
x();
}
$ clang foo.c
foo.c:7:2: error: always_inline function 'x' requires target feature 'avx2', but would be inlined into function 'main' that is compiled without support for 'avx2'
x();
^
1 error generated.
```
bugzilla: https://bugs.llvm.org/show_bug.cgi?id=37338
Reviewers: craig.topper, echristo, dblaikie
Reviewed By: craig.topper, echristo
Differential Revision: https://reviews.llvm.org/D46541
llvm-svn: 334174
Diffstat (limited to 'clang/test/CodeGen/target-features-error-2.c')
-rw-r--r-- | clang/test/CodeGen/target-features-error-2.c | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/clang/test/CodeGen/target-features-error-2.c b/clang/test/CodeGen/target-features-error-2.c index 40279fb6dea..60586fb57f1 100644 --- a/clang/test/CodeGen/target-features-error-2.c +++ b/clang/test/CodeGen/target-features-error-2.c @@ -1,38 +1,46 @@ -// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_SSE42 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX_1 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX_2 -// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX_3 -// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX_4 +// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX512f +// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -target-feature +movdir64b -S -verify -o - -D NEED_MOVDIRI +// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -target-feature +avx512vnni -target-feature +movdiri -S -verify -o - -D NEED_CLWB #define __MM_MALLOC_H #include <x86intrin.h> -#if NEED_SSE42 +#if NEED_AVX_1 int baz(__m256i a) { return _mm256_extract_epi32(a, 3); // expected-error {{'__builtin_ia32_vec_ext_v8si' needs target feature avx}} } #endif -#if NEED_AVX_1 +#if NEED_AVX_2 __m128 need_avx(__m128 a, __m128 b) { return _mm_cmp_ps(a, b, 0); // expected-error {{'__builtin_ia32_cmpps' needs target feature avx}} } #endif -#if NEED_AVX_2 -__m128 need_avx(__m128 a, __m128 b) { - return _mm_cmp_ss(a, b, 0); // expected-error {{'__builtin_ia32_cmpss' needs target feature avx}} +#if NEED_AVX512f +unsigned short need_avx512f(unsigned short a, unsigned short b) { + return __builtin_ia32_korhi(a, b); // expected-error {{'__builtin_ia32_korhi' needs target feature avx512f}} } #endif -#if NEED_AVX_3 -__m128d need_avx(__m128d a, __m128d b) { - return _mm_cmp_pd(a, b, 0); // expected-error {{'__builtin_ia32_cmppd' needs target feature avx}} +#if NEED_MOVDIRI +void need_movdiri(unsigned int *a, unsigned int b) { + __builtin_ia32_directstore_u32(a, b); // expected-error {{'__builtin_ia32_directstore_u32' needs target feature movdiri}} } #endif -#if NEED_AVX_4 -__m128d need_avx(__m128d a, __m128d b) { - return _mm_cmp_sd(a, b, 0); // expected-error {{'__builtin_ia32_cmpsd' needs target feature avx}} +#if NEED_CLWB +static __inline__ void + __attribute__((__always_inline__, __nodebug__, __target__("avx512vnni,clwb,movdiri,movdir64b"))) + func(unsigned int *a, unsigned int b) +{ + __builtin_ia32_directstore_u32(a, b); +} + +void need_clwb(unsigned int *a, unsigned int b) { + func(a, b); // expected-error {{always_inline function 'func' requires target feature 'clwb', but would be inlined into function 'need_clwb' that is compiled without support for 'clwb'}} + } #endif |