xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/x86_64-arguments-nacl-x32.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -triple x86_64-unknown-nacl -emit-llvm -o - %s | FileCheck %s
2*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnux32 -emit-llvm -o - %s | FileCheck %s
3*0a6a1f1dSLionel Sambuc 
4*0a6a1f1dSLionel Sambuc struct test_struct {};
5*0a6a1f1dSLionel Sambuc typedef int test_struct::* test_struct_mdp;
6*0a6a1f1dSLionel Sambuc typedef int (test_struct::*test_struct_mfp)();
7*0a6a1f1dSLionel Sambuc 
8*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define i32 @{{.*}}f_mdp{{.*}}(i32 %a)
f_mdp(test_struct_mdp a)9*0a6a1f1dSLionel Sambuc test_struct_mdp f_mdp(test_struct_mdp a) { return a; }
10*0a6a1f1dSLionel Sambuc 
11*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define {{.*}} @{{.*}}f_mfp{{.*}}(i64 %a.coerce)
f_mfp(test_struct_mfp a)12*0a6a1f1dSLionel Sambuc test_struct_mfp f_mfp(test_struct_mfp a) { return a; }
13*0a6a1f1dSLionel Sambuc 
14*0a6a1f1dSLionel Sambuc // A struct with <= 12 bytes before a member data pointer should still
15*0a6a1f1dSLionel Sambuc // be allowed in registers, since the member data pointer is only 4 bytes.
16*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define void @{{.*}}f_struct_with_mdp{{.*}}(i64 %a.coerce0, i64 %a.coerce1)
17*0a6a1f1dSLionel Sambuc struct struct_with_mdp { char *a; char *b; char *c; test_struct_mdp d; };
f_struct_with_mdp(struct_with_mdp a)18*0a6a1f1dSLionel Sambuc void f_struct_with_mdp(struct_with_mdp a) { (void)a; }
19*0a6a1f1dSLionel Sambuc 
20*0a6a1f1dSLionel Sambuc struct struct_with_mdp_too_much {
21*0a6a1f1dSLionel Sambuc   char *a; char *b; char *c; char *d; test_struct_mdp e;
22*0a6a1f1dSLionel Sambuc };
23*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define void @{{.*}}f_struct_with_mdp_too_much{{.*}}({{.*}} byval {{.*}} %a)
f_struct_with_mdp_too_much(struct_with_mdp_too_much a)24*0a6a1f1dSLionel Sambuc void f_struct_with_mdp_too_much(struct_with_mdp_too_much a) {
25*0a6a1f1dSLionel Sambuc   (void)a;
26*0a6a1f1dSLionel Sambuc }
27*0a6a1f1dSLionel Sambuc 
28*0a6a1f1dSLionel Sambuc // A struct with <= 8 bytes before a member function pointer should still
29*0a6a1f1dSLionel Sambuc // be allowed in registers, since the member function pointer is only 8 bytes.
30*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define void @{{.*}}f_struct_with_mfp_0{{.*}}(i64 %a.coerce0, i32 %a.coerce1)
31*0a6a1f1dSLionel Sambuc struct struct_with_mfp_0 { char *a; test_struct_mfp b; };
f_struct_with_mfp_0(struct_with_mfp_0 a)32*0a6a1f1dSLionel Sambuc void f_struct_with_mfp_0(struct_with_mfp_0 a) { (void)a; }
33*0a6a1f1dSLionel Sambuc 
34*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define void @{{.*}}f_struct_with_mfp_1{{.*}}(i64 %a.coerce0, i64 %a.coerce1)
35*0a6a1f1dSLionel Sambuc struct struct_with_mfp_1 { char *a; char *b; test_struct_mfp c; };
f_struct_with_mfp_1(struct_with_mfp_1 a)36*0a6a1f1dSLionel Sambuc void f_struct_with_mfp_1(struct_with_mfp_1 a) { (void)a; }
37*0a6a1f1dSLionel Sambuc 
38*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define void @{{.*}}f_struct_with_mfp_too_much{{.*}}({{.*}} byval {{.*}} %a, i32 %x)
39*0a6a1f1dSLionel Sambuc struct struct_with_mfp_too_much {
40*0a6a1f1dSLionel Sambuc   char *a; char *b; char *c; test_struct_mfp d;
41*0a6a1f1dSLionel Sambuc };
f_struct_with_mfp_too_much(struct_with_mfp_too_much a,int x)42*0a6a1f1dSLionel Sambuc void f_struct_with_mfp_too_much(struct_with_mfp_too_much a, int x) {
43*0a6a1f1dSLionel Sambuc   (void)a;
44*0a6a1f1dSLionel Sambuc }
45