1 // RUN: %clang_cc1 -w -triple i386-pc-win32 -emit-llvm -o - %s | FileCheck %s
2 
3 // CHECK-LABEL: define dso_local i64 @f1_1()
4 // CHECK-LABEL: define dso_local void @f1_2(i32 %a0.0, i32 %a0.1)
5 struct s1 {
6   int a;
7   int b;
8 };
f1_1(void)9 struct s1 f1_1(void) { while (1) {} }
f1_2(struct s1 a0)10 void f1_2(struct s1 a0) {}
11 
12 // CHECK-LABEL: define dso_local i32 @f2_1()
13 struct s2 {
14   short a;
15   short b;
16 };
f2_1(void)17 struct s2 f2_1(void) { while (1) {} }
18 
19 // CHECK-LABEL: define dso_local i16 @f3_1()
20 struct s3 {
21   char a;
22   char b;
23 };
f3_1(void)24 struct s3 f3_1(void) { while (1) {} }
25 
26 // CHECK-LABEL: define dso_local i8 @f4_1()
27 struct s4 {
28   char a:4;
29   char b:4;
30 };
f4_1(void)31 struct s4 f4_1(void) { while (1) {} }
32 
33 // CHECK-LABEL: define dso_local i64 @f5_1()
34 // CHECK-LABEL: define dso_local void @f5_2(double %a0.0)
35 struct s5 {
36   double a;
37 };
f5_1(void)38 struct s5 f5_1(void) { while (1) {} }
f5_2(struct s5 a0)39 void f5_2(struct s5 a0) {}
40 
41 // CHECK-LABEL: define dso_local i32 @f6_1()
42 // CHECK-LABEL: define dso_local void @f6_2(float %a0.0)
43 struct s6 {
44   float a;
45 };
f6_1(void)46 struct s6 f6_1(void) { while (1) {} }
f6_2(struct s6 a0)47 void f6_2(struct s6 a0) {}
48 
49 
50 // MSVC passes up to three vectors in registers, and the rest indirectly.  We
51 // (arbitrarily) pass oversized vectors indirectly, since that is the safest way
52 // to do it.
53 typedef float __m128 __attribute__((__vector_size__(16), __aligned__(16)));
54 typedef float __m256 __attribute__((__vector_size__(32), __aligned__(32)));
55 typedef float __m512 __attribute__((__vector_size__(64), __aligned__(64)));
56 typedef float __m1024 __attribute__((__vector_size__(128), __aligned__(128)));
57 
58 __m128 gv128;
59 __m256 gv256;
60 __m512 gv512;
61 __m1024 gv1024;
62 
receive_vec_128(__m128 x,__m128 y,__m128 z,__m128 w,__m128 q)63 void receive_vec_128(__m128 x, __m128 y, __m128 z, __m128 w, __m128 q) {
64   gv128 = x + y + z + w + q;
65 }
receive_vec_256(__m256 x,__m256 y,__m256 z,__m256 w,__m256 q)66 void receive_vec_256(__m256 x, __m256 y, __m256 z, __m256 w, __m256 q) {
67   gv256 = x + y + z + w + q;
68 }
receive_vec_512(__m512 x,__m512 y,__m512 z,__m512 w,__m512 q)69 void receive_vec_512(__m512 x, __m512 y, __m512 z, __m512 w, __m512 q) {
70   gv512 = x + y + z + w + q;
71 }
receive_vec_1024(__m1024 x,__m1024 y,__m1024 z,__m1024 w,__m1024 q)72 void receive_vec_1024(__m1024 x, __m1024 y, __m1024 z, __m1024 w, __m1024 q) {
73   gv1024 = x + y + z + w + q;
74 }
75 // CHECK-LABEL: define dso_local void @receive_vec_128(<4 x float> inreg %x, <4 x float> inreg %y, <4 x float> inreg %z, <4 x float>* %0, <4 x float>* %1)
76 // CHECK-LABEL: define dso_local void @receive_vec_256(<8 x float> inreg %x, <8 x float> inreg %y, <8 x float> inreg %z, <8 x float>* %0, <8 x float>* %1)
77 // CHECK-LABEL: define dso_local void @receive_vec_512(<16 x float> inreg %x, <16 x float> inreg %y, <16 x float> inreg %z, <16 x float>* %0, <16 x float>* %1)
78 // CHECK-LABEL: define dso_local void @receive_vec_1024(<32 x float>* %0, <32 x float>* %1, <32 x float>* %2, <32 x float>* %3, <32 x float>* %4)
79 
pass_vec_128()80 void pass_vec_128() {
81   __m128 z = {0};
82   receive_vec_128(z, z, z, z, z);
83 }
84 
85 // CHECK-LABEL: define dso_local void @pass_vec_128()
86 // CHECK: call void @receive_vec_128(<4 x float> inreg %{{[^,)]*}}, <4 x float> inreg %{{[^,)]*}}, <4 x float> inreg %{{[^,)]*}}, <4 x float>* %{{[^,)]*}}, <4 x float>* %{{[^,)]*}})
87 
88 
fastcall_indirect_vec(__m128 x,__m128 y,__m128 z,__m128 w,int edx,__m128 q)89 void __fastcall fastcall_indirect_vec(__m128 x, __m128 y, __m128 z, __m128 w, int edx, __m128 q) {
90   gv128 = x + y + z + w + q;
91 }
92 // CHECK-LABEL: define dso_local x86_fastcallcc void @"\01@fastcall_indirect_vec@84"(<4 x float> inreg %x, <4 x float> inreg %y, <4 x float> inreg %z, <4 x float>* inreg %0, i32 inreg %edx, <4 x float>* %1)
93