blob: 3751473331310f300be4cfb5eaff6d16d9f821b4 [file] [log] [blame]
Eli Friedmanbd7d8282011-12-05 22:23:28 +00001// RUN: %clang_cc1 %s -triple x86_64-apple-macosx10.7.2 -emit-llvm -o - | FileCheck %s
Eli Friedmanbd7d8282011-12-05 22:23:28 +00002
3struct X { int x[6]; };
4struct Y { char x[13]; struct X y; } __attribute((packed));
5struct Y g;
6void f(struct X);
7
Eli Friedman377ecc72012-04-16 03:54:45 +00008// <rdar://problem/10463337>
Eli Friedmanbd7d8282011-12-05 22:23:28 +00009struct X test1() {
10 // CHECK: @test1
11 // 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)
12 return g.y;
13}
14struct X test2() {
15 // CHECK: @test2
16 // 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)
17 struct X a = g.y;
18 return a;
19}
20
21void test3(struct X a) {
22 // CHECK: @test3
23 // 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)
24 g.y = a;
25}
26
Eli Friedman377ecc72012-04-16 03:54:45 +000027// <rdar://problem/10530444>
Eli Friedmanbd7d8282011-12-05 22:23:28 +000028void test4() {
29 // CHECK: @test4
30 // 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)
31 f(g.y);
32}
Eli Friedman377ecc72012-04-16 03:54:45 +000033
34// PR12395
35int test5() {
36 // CHECK: @test5
37 // CHECK: load i32* getelementptr inbounds (%struct.Y* @g, i32 0, i32 1, i32 0, i64 0), align 1
38 return g.y.x[0];
39}