1*67e74705SXin Li // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-nacl -emit-llvm -o - %s | FileCheck %s
2*67e74705SXin Li // RUN: %clang_cc1 -std=c++11 -triple=x86_64-unknown-linux-gnux32 -emit-llvm -o - %s | FileCheck %s
3*67e74705SXin Li
4*67e74705SXin Li struct test_struct {};
5*67e74705SXin Li typedef int test_struct::* test_struct_mdp;
6*67e74705SXin Li typedef int (test_struct::*test_struct_mfp)();
7*67e74705SXin Li
8*67e74705SXin Li // CHECK-LABEL: define i32 @{{.*}}f_mdp{{.*}}(i32 %a)
f_mdp(test_struct_mdp a)9*67e74705SXin Li test_struct_mdp f_mdp(test_struct_mdp a) { return a; }
10*67e74705SXin Li
11*67e74705SXin Li // CHECK-LABEL: define {{.*}} @{{.*}}f_mfp{{.*}}(i64 %a.coerce)
f_mfp(test_struct_mfp a)12*67e74705SXin Li test_struct_mfp f_mfp(test_struct_mfp a) { return a; }
13*67e74705SXin Li
14*67e74705SXin Li // A struct with <= 12 bytes before a member data pointer should still
15*67e74705SXin Li // be allowed in registers, since the member data pointer is only 4 bytes.
16*67e74705SXin Li // CHECK-LABEL: define void @{{.*}}f_struct_with_mdp{{.*}}(i64 %a.coerce0, i64 %a.coerce1)
17*67e74705SXin Li struct struct_with_mdp { char *a; char *b; char *c; test_struct_mdp d; };
f_struct_with_mdp(struct_with_mdp a)18*67e74705SXin Li void f_struct_with_mdp(struct_with_mdp a) { (void)a; }
19*67e74705SXin Li
20*67e74705SXin Li struct struct_with_mdp_too_much {
21*67e74705SXin Li char *a; char *b; char *c; char *d; test_struct_mdp e;
22*67e74705SXin Li };
23*67e74705SXin Li // 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*67e74705SXin Li void f_struct_with_mdp_too_much(struct_with_mdp_too_much a) {
25*67e74705SXin Li (void)a;
26*67e74705SXin Li }
27*67e74705SXin Li
28*67e74705SXin Li // A struct with <= 8 bytes before a member function pointer should still
29*67e74705SXin Li // be allowed in registers, since the member function pointer is only 8 bytes.
30*67e74705SXin Li // CHECK-LABEL: define void @{{.*}}f_struct_with_mfp_0{{.*}}(i64 %a.coerce0, i32 %a.coerce1)
31*67e74705SXin Li struct struct_with_mfp_0 { char *a; test_struct_mfp b; };
f_struct_with_mfp_0(struct_with_mfp_0 a)32*67e74705SXin Li void f_struct_with_mfp_0(struct_with_mfp_0 a) { (void)a; }
33*67e74705SXin Li
34*67e74705SXin Li // CHECK-LABEL: define void @{{.*}}f_struct_with_mfp_1{{.*}}(i64 %a.coerce0, i64 %a.coerce1)
35*67e74705SXin Li struct struct_with_mfp_1 { char *a; char *b; test_struct_mfp c; };
f_struct_with_mfp_1(struct_with_mfp_1 a)36*67e74705SXin Li void f_struct_with_mfp_1(struct_with_mfp_1 a) { (void)a; }
37*67e74705SXin Li
38*67e74705SXin Li // CHECK-LABEL: define void @{{.*}}f_struct_with_mfp_too_much{{.*}}({{.*}} byval {{.*}} %a, i32 %x)
39*67e74705SXin Li struct struct_with_mfp_too_much {
40*67e74705SXin Li char *a; char *b; char *c; test_struct_mfp d;
41*67e74705SXin Li };
f_struct_with_mfp_too_much(struct_with_mfp_too_much a,int x)42*67e74705SXin Li void f_struct_with_mfp_too_much(struct_with_mfp_too_much a, int x) {
43*67e74705SXin Li (void)a;
44*67e74705SXin Li }
45*67e74705SXin Li
46*67e74705SXin Li /* Struct containing an empty struct */
47*67e74705SXin Li typedef struct { int* a; test_struct x; double *b; } struct_with_empty;
48*67e74705SXin Li
49*67e74705SXin Li // CHECK-LABEL: define void @{{.*}}f_pass_struct_with_empty{{.*}}(i64 %x{{.*}}, double* %x
f_pass_struct_with_empty(struct_with_empty x)50*67e74705SXin Li void f_pass_struct_with_empty(struct_with_empty x) {
51*67e74705SXin Li (void) x;
52*67e74705SXin Li }
53*67e74705SXin Li
54*67e74705SXin Li // CHECK-LABEL: define { i64, double* } @{{.*}}f_return_struct_with_empty
f_return_struct_with_empty()55*67e74705SXin Li struct_with_empty f_return_struct_with_empty() {
56*67e74705SXin Li return {0, {}, 0};
57*67e74705SXin Li }
58