https://github.com/llvm/llvm-project/pull/193298 was reverted because of a compile time regression (see results [here](https://llvm-compile-time-tracker.com/compare.php?from=b9869c8c920a7dfa983e215bc30729b13d8b353b&to=464b46a73b7592c95222cf2e64b34ffe6f2cf251&stat=instructions:u)) I added a conditional statement so that getFunctionFeatureMap and the subsequent string lookup is only called if FD->hasAttr<TargetAttr>() evaluates to true which should be very rare. --------- Co-authored-by: Aaron Ballman <aaron@aaronballman.com>
73 lines
3.5 KiB
C
73 lines
3.5 KiB
C
// RUN: %clang_cc1 -triple x86_64-pc-win32 -emit-llvm -target-cpu skylake-avx512 < %s | FileCheck %s --check-prefixes=CHECK,AVX
|
|
// RUN: %clang_cc1 -triple x86_64-mingw -emit-llvm -target-cpu skylake-avx512 < %s | FileCheck %s --check-prefixes=CHECK,AVX
|
|
// RUN: %clang_cc1 -triple x86_64-cygwin -emit-llvm -target-cpu skylake-avx512 < %s | FileCheck %s --check-prefixes=CHECK,AVX
|
|
// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -target-cpu skylake-avx512 < %s | FileCheck %s --check-prefixes=CHECK,AVX
|
|
// RUN: %clang_cc1 -triple x86_64-uefi -emit-llvm -target-cpu skylake-avx512 < %s | FileCheck %s --check-prefixes=CHECK,AVX
|
|
// RUN: %clang_cc1 -triple x86_64-pc-win32 -emit-llvm < %s | FileCheck %s --check-prefixes=CHECK,NOAVX
|
|
// RUN: %clang_cc1 -triple x86_64-mingw -emit-llvm < %s | FileCheck %s --check-prefixes=CHECK,NOAVX
|
|
// RUN: %clang_cc1 -triple x86_64-cygwin -emit-llvm < %s | FileCheck %s --check-prefixes=CHECK,NOAVX
|
|
// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm < %s | FileCheck %s --check-prefixes=CHECK,NOAVX
|
|
// RUN: %clang_cc1 -triple x86_64-uefi -emit-llvm < %s | FileCheck %s --check-prefixes=CHECK,NOAVX
|
|
|
|
#define SYSV_CC __attribute__((sysv_abi))
|
|
|
|
// Make sure we coerce structs according to the SysV rules instead of passing
|
|
// them indirectly as we would for Win64.
|
|
struct StringRef {
|
|
char *Str;
|
|
__SIZE_TYPE__ Size;
|
|
};
|
|
extern volatile char gc;
|
|
void SYSV_CC take_stringref(struct StringRef s);
|
|
void callit(void) {
|
|
struct StringRef s = {"asdf", 4};
|
|
take_stringref(s);
|
|
}
|
|
// CHECK: define {{(dso_local )?}}void @callit()
|
|
// CHECK: call {{(x86_64_sysvcc )?}}void @take_stringref(ptr {{[^,]*}}, i64 {{[^,]*}})
|
|
// CHECK: declare {{(dso_local )?}}{{(x86_64_sysvcc )?}}void @take_stringref(ptr, i64)
|
|
|
|
// Check that we pass vectors directly if the target feature is enabled, and
|
|
// not otherwise.
|
|
typedef __attribute__((vector_size(32))) float my_m256;
|
|
typedef __attribute__((vector_size(64))) float my_m512;
|
|
|
|
my_m256 SYSV_CC get_m256(void);
|
|
void SYSV_CC take_m256(my_m256);
|
|
my_m512 SYSV_CC get_m512(void);
|
|
void SYSV_CC take_m512(my_m512);
|
|
|
|
void use_vectors(void) {
|
|
my_m256 v1 = get_m256();
|
|
take_m256(v1);
|
|
my_m512 v2 = get_m512();
|
|
take_m512(v2);
|
|
}
|
|
|
|
// CHECK: define {{(dso_local )?}}void @use_vectors()
|
|
// AVX: call {{(x86_64_sysvcc )?}}<8 x float> @get_m256()
|
|
// AVX: call {{(x86_64_sysvcc )?}}void @take_m256(<8 x float> noundef %{{.*}})
|
|
// AVX: call {{(x86_64_sysvcc )?}}<16 x float> @get_m512()
|
|
// AVX: call {{(x86_64_sysvcc )?}}void @take_m512(<16 x float> noundef %{{.*}})
|
|
// NOAVX: call {{(x86_64_sysvcc )?}}<8 x float> @get_m256()
|
|
// NOAVX: call {{(x86_64_sysvcc )?}}void @take_m256(ptr noundef byval(<8 x float>) align 32 %{{.*}})
|
|
// NOAVX: call {{(x86_64_sysvcc )?}}<16 x float> @get_m512()
|
|
// NOAVX: call {{(x86_64_sysvcc )?}}void @take_m512(ptr noundef byval(<16 x float>) align 64 %{{.*}})
|
|
|
|
// Added test to explicitly cover the case when __attribute__((target("avx"))) is used
|
|
// with __attribute__((sysv_abi))
|
|
|
|
__attribute__((target("avx"))) my_m256 SYSV_CC get_avx_m256(void);
|
|
__attribute__((target("avx"))) void SYSV_CC take_avx_m256(my_m256);
|
|
|
|
__attribute__((target("avx")))
|
|
void use_target_attr_vectors(void) {
|
|
my_m256 v = get_avx_m256();
|
|
take_avx_m256(v);
|
|
}
|
|
|
|
// CHECK: define {{(dso_local )?}}void @use_target_attr_vectors()
|
|
// AVX: call {{(x86_64_sysvcc )?}}<8 x float> @get_avx_m256()
|
|
// AVX: call {{(x86_64_sysvcc )?}}void @take_avx_m256(<8 x float> noundef %{{.*}})
|
|
// NOAVX: call {{(x86_64_sysvcc )?}}<8 x float> @get_avx_m256()
|
|
// NOAVX: call {{(x86_64_sysvcc )?}}void @take_avx_m256(<8 x float> noundef %{{.*}})
|