blob: e542e4a9348cfe94cb7702924b8244c1539ddea3 [file] [log] [blame]
Fariborz Jahaniana7db6a22013-01-26 01:25:32 +00001// RUN: %clang_cc1 -O0 -triple=x86_64-apple-darwin -emit-llvm -o - %s | FileCheck %s
Fariborz Jahanian3ac83d62013-01-25 23:57:05 +00002// rdar://11861085
3
4struct s {
5 char filler [128];
6 volatile int x;
7};
8
9struct s gs;
10
11void foo (void) {
12 struct s ls;
13 ls = ls;
14 gs = gs;
15 ls = gs;
16}
Fariborz Jahaniana7db6a22013-01-26 01:25:32 +000017// CHECK: define void @_Z3foov()
18// CHECK: %[[LS:.*]] = alloca %struct.s, align 4
19// CHECK-NEXT: %[[ZERO:.*]] = bitcast %struct.s* %[[LS]] to i8*
20// CHECK-NEXT: %[[ONE:.*]] = bitcast %struct.s* %[[LS]] to i8*
21// CHECK-NEXT: call void @llvm.memcpy.{{.*}}(i8* %[[ZERO]], i8* %[[ONE]], i64 132, i32 4, i1 true)
22// CHECK-NEXT: call void @llvm.memcpy.{{.*}}(i8* getelementptr inbounds (%struct.s* @gs, i32 0, i32 0, i32 0), i8* getelementptr inbounds (%struct.s* @gs, i32 0, i32 0, i32 0), i64 132, i32 4, i1 true)
23// CHECK-NEXT: %[[TWO:.*]] = bitcast %struct.s* %[[LS]] to i8*
24// CHECK-NEXT: call void @llvm.memcpy.{{.*}}(i8* %[[TWO]], i8* getelementptr inbounds (%struct.s* @gs, i32 0, i32 0, i32 0), i64 132, i32 4, i1 true)
25
Fariborz Jahanian3ac83d62013-01-25 23:57:05 +000026
27struct s1 {
28 struct s y;
29};
30
31struct s1 s;
32
33void fee (void) {
34 s = s;
35 s.y = gs;
36}
Fariborz Jahaniana7db6a22013-01-26 01:25:32 +000037// CHECK: define void @_Z3feev()
38// CHECK: call void @llvm.memcpy.{{.*}}(i8* getelementptr inbounds (%struct.s1* @s, i32 0, i32 0, i32 0, i32 0), i8* getelementptr inbounds (%struct.s1* @s, i32 0, i32 0, i32 0, i32 0), i64 132, i32 4, i1 true)
39// CHECK-NEXT: call void @llvm.memcpy.{{.*}}(i8* getelementptr inbounds (%struct.s1* @s, i32 0, i32 0, i32 0, i32 0), i8* getelementptr inbounds (%struct.s* @gs, i32 0, i32 0, i32 0), i64 132, i32 4, i1 true)
Fariborz Jahanian3ac83d62013-01-25 23:57:05 +000040
41struct d : s1 {
42};
43
44d gd;
45
46void gorf(void) {
47 gd = gd;
48}
Fariborz Jahaniana7db6a22013-01-26 01:25:32 +000049// CHECK: define void @_Z4gorfv()
50// CHECK: call void @llvm.memcpy.{{.*}}(i8* getelementptr inbounds (%struct.d* @gd, i32 0, i32 0, i32 0, i32 0, i32 0), i8* getelementptr inbounds (%struct.d* @gd, i32 0, i32 0, i32 0, i32 0, i32 0), i64 132, i32 4, i1 true)