• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 %s -triple x86_64-apple-macosx10.7.2 -emit-llvm -o - | FileCheck %s
2 
3 struct X { int x[6]; };
4 struct Y { char x[13]; struct X y; } __attribute((packed));
5 struct Y g;
6 void f(struct X);
7 struct X foo(void);
8 
9 // <rdar://problem/10463337>
test1()10 struct X test1() {
11   // CHECK: @test1
12   // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* bitcast (%struct.X* getelementptr inbounds (%struct.Y* @g, i32 0, i32 1) to i8*), i64 24, i32 1, i1 false)
13   return g.y;
14 }
test2()15 struct X test2() {
16   // CHECK: @test2
17   // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* bitcast (%struct.X* getelementptr inbounds (%struct.Y* @g, i32 0, i32 1) to i8*), i64 24, i32 1, i1 false)
18   struct X a = g.y;
19   return a;
20 }
21 
test3(struct X a)22 void test3(struct X a) {
23   // CHECK: @test3
24   // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* bitcast (%struct.X* getelementptr inbounds (%struct.Y* @g, i32 0, i32 1) to i8*), i8* {{.*}}, i64 24, i32 1, i1 false)
25   g.y = a;
26 }
27 
28 // <rdar://problem/10530444>
test4()29 void test4() {
30   // CHECK: @test4
31   // FIXME: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* bitcast (%struct.X* getelementptr inbounds (%struct.Y* @g, i32 0, i32 1) to i8*), i64 24, i32 1, i1 false)
32   f(g.y);
33 }
34 
35 // PR12395
test5()36 int test5() {
37   // CHECK: @test5
38   // CHECK: load i32* getelementptr inbounds (%struct.Y* @g, i32 0, i32 1, i32 0, i64 0), align 1
39   return g.y.x[0];
40 }
41 
42 // <rdar://problem/11220251>
test6()43 void test6() {
44   // CHECK: @test6
45   // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* bitcast (%struct.X* getelementptr inbounds (%struct.Y* @g, i32 0, i32 1) to i8*), i8* %{{.*}}, i64 24, i32 1, i1 false)
46   g.y = foo();
47 }
48