53 lines · c
1// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin10 < %s | FileCheck %s2 3struct Test1S {4 long NumDecls;5 long X;6 long Y;7};8struct Test2S {9 long NumDecls;10 long X;11};12 13// Make sure we don't generate extra memcpy for lvalues14void test1a(struct Test1S, struct Test2S);15// CHECK-LABEL: define{{.*}} void @test1(16// CHECK-NOT: memcpy17// CHECK: call void @test1a18void test1(struct Test1S *A, struct Test2S *B) {19 test1a(*A, *B);20}21 22// The above gets tricker when the byval argument requires higher alignment23// than the natural alignment of the type in question.24 25// Make sure we do generate a memcpy when we cannot guarantee alignment.26struct Test3S {27 int a,b,c,d,e,f,g,h,i,j,k,l;28};29void test2a(struct Test3S q);30// CHECK-LABEL: define{{.*}} void @test2(31// CHECK: alloca %struct.Test3S, align 832// CHECK: memcpy33// CHECK: call void @test2a34void test2(struct Test3S *q) {35 test2a(*q);36}37 38// But make sure we don't generate a memcpy when we can guarantee alignment.39void fooey(void);40// CHECK-LABEL: define{{.*}} void @test3(41// CHECK: alloca %struct.Test3S, align 842// CHECK: call void @fooey43// CHECK-NOT: memcpy44// CHECK: call void @test2a45// CHECK-NOT: memcpy46// CHECK: call void @test2a47void test3(struct Test3S a) {48 struct Test3S b = a;49 fooey();50 test2a(a);51 test2a(b);52}53