1 // RUN: %clang_cc1 %s -triple x86_64-unknown-unknown -emit-llvm -o - | FileCheck %s
3 struct P1
{ char x
[6]; } g1
= { "foo" };
4 struct LP1
{ struct P1 p1
; };
6 struct P2
{ int a
, b
, c
; } g2
= { 1, 2, 3 };
7 struct LP2
{ struct P2 p2
; };
8 struct LP2P2
{ struct P2 p1
, p2
; };
9 union UP2
{ struct P2 p2
; };
11 struct LP3
{ struct P1 p1
[2]; } g3
= { { "dog" }, { "cat" } };
12 struct LLP3
{ struct LP3 l3
; };
13 union ULP3
{ struct LP3 l3
; };
18 // CHECK: call void @llvm.memcpy{{.*}}ptr align 1 @g1, i64 6, i1 false)
19 // CHECK: store i8 120, ptr %
21 struct LP1 l
= { .p1
= g1
, .p1
.x
[2] = 'x' };
27 // CHECK: call void @llvm.memcpy{{.*}}ptr align 1 @g1, i64 6, i1 false)
28 // CHECK: store i8 114, ptr %
30 struct LP1 l
= { .p1
= g1
, .p1
.x
[1] = 'r' };
36 // CHECK: call void @llvm.memcpy{{.*}}ptr align 4 @g2, i64 12, i1 false)
37 // CHECK: store i32 10, ptr %
39 struct LP2 l
= { .p2
= g2
, .p2
.b
= 10 };
42 // CHECK-LABEL: get235
43 struct P2
get235(void)
45 struct P2 p
= { 2, 3, 5 };
49 // CHECK-LABEL: get456789
50 struct LP2P2
get456789(void)
52 struct LP2P2 l
= { { 4, 5, 6 }, { 7, 8, 9 } };
56 // CHECK-LABEL: get123
57 union UP2
get123(void)
59 union UP2 u
= { { 1, 2, 3 } };
66 // CHECK: [[CALL:%[a-z0-9]+]] = call {{.*}}@get123()
67 // CHECK: store{{.*}}[[CALL]], {{.*}}[[TMP0:%[a-z0-9.]+]]
68 // CHECK: call void @llvm.memcpy{{.*}}[[TMP0]], i64 12, i1 false)
69 // CHECK: store i32 100, ptr %
71 struct LUP2
{ union UP2 up
; } var
= { get123(), .up
.p2
.a
= 100 };
78 // CHECK: call void @llvm.memcpy{{.*}}ptr align 1 @g3, i64 12, i1 false)
80 // .l3.p1 = { [0] = g1 } implicitly sets [1] to zero
81 // CHECK: call void @llvm.memcpy{{.*}}ptr align 1 @g1, i64 6, i1 false)
82 // CHECK: getelementptr{{.*}}%struct.P1, ptr{{.*}}i64 1
83 // CHECK: call void @llvm.memset{{.*}}i8 0, i64 6, i1 false)
85 // .l3.p1[1].x[1] = 'x'
86 // CHECK: store i8 120, ptr %
88 struct LLP3 var
= { .l3
= g3
, .l3
.p1
= { [0] = g1
}, .l3
.p1
[1].x
[1] = 'x' };
94 // CHECK: [[LP:%[a-z0-9]+]] = getelementptr{{.*}}%struct.LLP2P2, ptr{{.*}}, i32 0, i32 0
95 // CHECK: call {{.*}}get456789(ptr {{.*}}[[LP]])
97 // CHECK: [[CALL:%[a-z0-9]+]] = call {{.*}}@get235()
98 // CHECK: store{{.*}}[[CALL]], {{.*}}[[TMP0:%[a-z0-9.]+]]
99 // CHECK: call void @llvm.memcpy{{.*}}[[TMP0]], i64 12, i1 false)
101 // CHECK: store i32 10, ptr %
103 struct LLP2P2
{ struct LP2P2 lp
; } var
= { get456789(),