Debian Codegraph @

clang/test/CodeGen/sysv_abi.c

raw
1 // RUN: %clang_cc1 -triple x86_64-pc-win32 -emit-llvm -target-cpu skylake-avx512 < %s | FileCheck %s --check-prefixes=CHECK,AVX
2 // RUN: %clang_cc1 -triple x86_64-mingw -emit-llvm -target-cpu skylake-avx512 < %s | FileCheck %s --check-prefixes=CHECK,AVX
3 // RUN: %clang_cc1 -triple x86_64-cygwin -emit-llvm -target-cpu skylake-avx512 < %s | FileCheck %s --check-prefixes=CHECK,AVX
4 // RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -target-cpu skylake-avx512 < %s | FileCheck %s --check-prefixes=CHECK,AVX
5 // RUN: %clang_cc1 -triple x86_64-uefi -emit-llvm -target-cpu skylake-avx512 < %s | FileCheck %s --check-prefixes=CHECK,AVX
6 // RUN: %clang_cc1 -triple x86_64-pc-win32 -emit-llvm < %s | FileCheck %s --check-prefixes=CHECK,NOAVX
7 // RUN: %clang_cc1 -triple x86_64-mingw -emit-llvm < %s | FileCheck %s --check-prefixes=CHECK,NOAVX
8 // RUN: %clang_cc1 -triple x86_64-cygwin -emit-llvm < %s | FileCheck %s --check-prefixes=CHECK,NOAVX
9 // RUN: %clang_cc1 -triple x86_64-linux -emit-llvm < %s | FileCheck %s --check-prefixes=CHECK,NOAVX
10 // RUN: %clang_cc1 -triple x86_64-uefi -emit-llvm < %s | FileCheck %s --check-prefixes=CHECK,NOAVX
11
12 #define SYSV_CC __attribute__((sysv_abi))
13
14 // Make sure we coerce structs according to the SysV rules instead of passing
15 // them indirectly as we would for Win64.
16 struct StringRef {
17 char *Str;
18 __SIZE_TYPE__ Size;
19 };
20 extern volatile char gc;
21 void SYSV_CC take_stringref(struct StringRef s);
22 void callit(void) {
23 struct StringRef s = {"asdf", 4};
24 take_stringref(s);
25 }
26 // CHECK: define {{(dso_local )?}}void @callit()
27 // CHECK: call {{(x86_64_sysvcc )?}}void @take_stringref(ptr {{[^,]*}}, i64 {{[^,]*}})
28 // CHECK: declare {{(dso_local )?}}{{(x86_64_sysvcc )?}}void @take_stringref(ptr, i64)
29
30 // Check that we pass vectors directly if the target feature is enabled, and
31 // not otherwise.
32 typedef __attribute__((vector_size(32))) float my_m256;
33 typedef __attribute__((vector_size(64))) float my_m512;
34
35 my_m256 SYSV_CC get_m256(void);
36 void SYSV_CC take_m256(my_m256);
37 my_m512 SYSV_CC get_m512(void);
38 void SYSV_CC take_m512(my_m512);
39
40 void use_vectors(void) {
41 my_m256 v1 = get_m256();
42 take_m256(v1);
43 my_m512 v2 = get_m512();
44 take_m512(v2);
45 }
46
47 // CHECK: define {{(dso_local )?}}void @use_vectors()
48 // AVX: call {{(x86_64_sysvcc )?}}<8 x float> @get_m256()
49 // AVX: call {{(x86_64_sysvcc )?}}void @take_m256(<8 x float> noundef %{{.*}})
50 // AVX: call {{(x86_64_sysvcc )?}}<16 x float> @get_m512()
51 // AVX: call {{(x86_64_sysvcc )?}}void @take_m512(<16 x float> noundef %{{.*}})
52 // NOAVX: call {{(x86_64_sysvcc )?}}<8 x float> @get_m256()
53 // NOAVX: call {{(x86_64_sysvcc )?}}void @take_m256(ptr noundef byval(<8 x float>) align 32 %{{.*}})
54 // NOAVX: call {{(x86_64_sysvcc )?}}<16 x float> @get_m512()
55 // NOAVX: call {{(x86_64_sysvcc )?}}void @take_m512(ptr noundef byval(<16 x float>) align 64 %{{.*}})