Eli Friedman | bd7d828 | 2011-12-05 22:23:28 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -triple x86_64-apple-macosx10.7.2 -emit-llvm -o - | FileCheck %s |
Eli Friedman | bd7d828 | 2011-12-05 22:23:28 +0000 | [diff] [blame] | 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 | |
Eli Friedman | 377ecc7 | 2012-04-16 03:54:45 +0000 | [diff] [blame^] | 8 | // <rdar://problem/10463337> |
Eli Friedman | bd7d828 | 2011-12-05 22:23:28 +0000 | [diff] [blame] | 9 | struct 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 | } |
| 14 | struct 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 | |
| 21 | void 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 Friedman | 377ecc7 | 2012-04-16 03:54:45 +0000 | [diff] [blame^] | 27 | // <rdar://problem/10530444> |
Eli Friedman | bd7d828 | 2011-12-05 22:23:28 +0000 | [diff] [blame] | 28 | void 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 Friedman | 377ecc7 | 2012-04-16 03:54:45 +0000 | [diff] [blame^] | 33 | |
| 34 | // PR12395 |
| 35 | int 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 | } |