1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fms-extensions -emit-llvm -o - %s | FileCheck %s
2*f4a2713aSLionel Sambuc
3*f4a2713aSLionel Sambuc // CHECK: %struct.test = type { i32, %struct.nested2, i32 }
4*f4a2713aSLionel Sambuc // CHECK: %struct.nested2 = type { i32, %struct.nested1, i32 }
5*f4a2713aSLionel Sambuc // CHECK: %struct.nested1 = type { i32, i32 }
6*f4a2713aSLionel Sambuc typedef struct nested1 {
7*f4a2713aSLionel Sambuc int a1;
8*f4a2713aSLionel Sambuc int b1;
9*f4a2713aSLionel Sambuc } NESTED1;
10*f4a2713aSLionel Sambuc
11*f4a2713aSLionel Sambuc struct nested2 {
12*f4a2713aSLionel Sambuc int a;
13*f4a2713aSLionel Sambuc NESTED1;
14*f4a2713aSLionel Sambuc int b;
15*f4a2713aSLionel Sambuc };
16*f4a2713aSLionel Sambuc
17*f4a2713aSLionel Sambuc struct test {
18*f4a2713aSLionel Sambuc int x;
19*f4a2713aSLionel Sambuc struct nested2;
20*f4a2713aSLionel Sambuc int y;
21*f4a2713aSLionel Sambuc };
22*f4a2713aSLionel Sambuc
23*f4a2713aSLionel Sambuc
foo()24*f4a2713aSLionel Sambuc void foo()
25*f4a2713aSLionel Sambuc {
26*f4a2713aSLionel Sambuc // CHECK: %var = alloca %struct.test, align 4
27*f4a2713aSLionel Sambuc struct test var;
28*f4a2713aSLionel Sambuc
29*f4a2713aSLionel Sambuc // CHECK: getelementptr inbounds %struct.test* %var, i32 0, i32 1
30*f4a2713aSLionel Sambuc // CHECK-NEXT: getelementptr inbounds %struct.nested2* %{{.*}}, i32 0, i32 0
31*f4a2713aSLionel Sambuc // CHECK-NEXT: load i32* %{{.*}}, align 4
32*f4a2713aSLionel Sambuc var.a;
33*f4a2713aSLionel Sambuc
34*f4a2713aSLionel Sambuc // CHECK-NEXT: getelementptr inbounds %struct.test* %var, i32 0, i32 1
35*f4a2713aSLionel Sambuc // CHECK-NEXT: getelementptr inbounds %struct.nested2* %{{.*}}, i32 0, i32 2
36*f4a2713aSLionel Sambuc // CHECK-NEXT: load i32* %{{.*}}, align 4
37*f4a2713aSLionel Sambuc var.b;
38*f4a2713aSLionel Sambuc
39*f4a2713aSLionel Sambuc // CHECK-NEXT: getelementptr inbounds %struct.test* %var, i32 0, i32 1
40*f4a2713aSLionel Sambuc // CHECK-NEXT: getelementptr inbounds %struct.nested2* %{{.*}}, i32 0, i32 1
41*f4a2713aSLionel Sambuc // CHECK-NEXT: getelementptr inbounds %struct.nested1* %{{.*}}, i32 0, i32 0
42*f4a2713aSLionel Sambuc // CHECK-NEXT: load i32* %{{.*}}, align 4
43*f4a2713aSLionel Sambuc var.a1;
44*f4a2713aSLionel Sambuc
45*f4a2713aSLionel Sambuc // CHECK-NEXT: getelementptr inbounds %struct.test* %{{.*}}var, i32 0, i32 1
46*f4a2713aSLionel Sambuc // CHECK-NEXT: getelementptr inbounds %struct.nested2* %{{.*}}, i32 0, i32 1
47*f4a2713aSLionel Sambuc // CHECK-NEXT: getelementptr inbounds %struct.nested1* %{{.*}}, i32 0, i32 1
48*f4a2713aSLionel Sambuc // CHECK-NEXT: load i32* %{{.*}}, align 4
49*f4a2713aSLionel Sambuc var.b1;
50*f4a2713aSLionel Sambuc
51*f4a2713aSLionel Sambuc // CHECK-NEXT: getelementptr inbounds %struct.test* %var, i32 0, i32 0
52*f4a2713aSLionel Sambuc // CHECK-NEXT: load i32* %{{.*}}, align 4
53*f4a2713aSLionel Sambuc var.x;
54*f4a2713aSLionel Sambuc
55*f4a2713aSLionel Sambuc // CHECK-NEXT: getelementptr inbounds %struct.test* %var, i32 0, i32 2
56*f4a2713aSLionel Sambuc // CHECK-NEXT: load i32* %{{.*}}, align 4
57*f4a2713aSLionel Sambuc var.y;
58*f4a2713aSLionel Sambuc }
59*f4a2713aSLionel Sambuc
foo2(struct test * var)60*f4a2713aSLionel Sambuc void foo2(struct test* var)
61*f4a2713aSLionel Sambuc {
62*f4a2713aSLionel Sambuc // CHECK: alloca %struct.test*, align
63*f4a2713aSLionel Sambuc // CHECK-NEXT: store %struct.test* %var, %struct.test** %{{.*}}, align
64*f4a2713aSLionel Sambuc // CHECK-NEXT: load %struct.test** %{{.*}}, align
65*f4a2713aSLionel Sambuc // CHECK-NEXT: getelementptr inbounds %struct.test* %{{.*}}, i32 0, i32 1
66*f4a2713aSLionel Sambuc // CHECK-NEXT: getelementptr inbounds %struct.nested2* %{{.*}}, i32 0, i32 0
67*f4a2713aSLionel Sambuc // CHECK-NEXT: load i32* %{{.*}}, align 4
68*f4a2713aSLionel Sambuc var->a;
69*f4a2713aSLionel Sambuc
70*f4a2713aSLionel Sambuc // CHECK-NEXT: load %struct.test** %{{.*}}, align
71*f4a2713aSLionel Sambuc // CHECK-NEXT: getelementptr inbounds %struct.test* %{{.*}}, i32 0, i32 1
72*f4a2713aSLionel Sambuc // CHECK-NEXT: getelementptr inbounds %struct.nested2* %{{.*}}, i32 0, i32 2
73*f4a2713aSLionel Sambuc // CHECK-NEXT: load i32* %{{.*}}, align 4
74*f4a2713aSLionel Sambuc var->b;
75*f4a2713aSLionel Sambuc
76*f4a2713aSLionel Sambuc // CHECK-NEXT: load %struct.test** %{{.*}}, align
77*f4a2713aSLionel Sambuc // CHECK-NEXT: getelementptr inbounds %struct.test* %{{.*}}, i32 0, i32 1
78*f4a2713aSLionel Sambuc // CHECK-NEXT: getelementptr inbounds %struct.nested2* %{{.*}}, i32 0, i32 1
79*f4a2713aSLionel Sambuc // CHECK-NEXT: getelementptr inbounds %struct.nested1* %{{.*}}, i32 0, i32 0
80*f4a2713aSLionel Sambuc // CHECK-NEXT: load i32* %{{.*}}, align 4
81*f4a2713aSLionel Sambuc var->a1;
82*f4a2713aSLionel Sambuc
83*f4a2713aSLionel Sambuc // CHECK-NEXT: load %struct.test** %{{.*}}, align
84*f4a2713aSLionel Sambuc // CHECK-NEXT: getelementptr inbounds %struct.test* %{{.*}}, i32 0, i32 1
85*f4a2713aSLionel Sambuc // CHECK-NEXT: getelementptr inbounds %struct.nested2* %{{.*}}, i32 0, i32 1
86*f4a2713aSLionel Sambuc // CHECK-NEXT: getelementptr inbounds %struct.nested1* %{{.*}}, i32 0, i32 1
87*f4a2713aSLionel Sambuc // CHECK-NEXT: load i32* %{{.*}}, align 4
88*f4a2713aSLionel Sambuc var->b1;
89*f4a2713aSLionel Sambuc
90*f4a2713aSLionel Sambuc // CHECK-NEXT: load %struct.test** %{{.*}}, align
91*f4a2713aSLionel Sambuc // CHECK-NEXT: getelementptr inbounds %struct.test* %{{.*}}, i32 0, i32 0
92*f4a2713aSLionel Sambuc // CHECK-NEXT: load i32* %{{.*}}, align 4
93*f4a2713aSLionel Sambuc var->x;
94*f4a2713aSLionel Sambuc
95*f4a2713aSLionel Sambuc // CHECK-NEXT: load %struct.test** %{{.*}}, align
96*f4a2713aSLionel Sambuc // CHECK-NEXT: getelementptr inbounds %struct.test* %{{.*}}, i32 0, i32 2
97*f4a2713aSLionel Sambuc // CHECK-NEXT: load i32* %{{.*}}, align 4
98*f4a2713aSLionel Sambuc var->y;
99*f4a2713aSLionel Sambuc }
100