diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2012-05-03 16:53:59 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2012-05-03 16:53:59 +0000 |
commit | 6b9a6e390fbb92c40eb9c6ac9e7abbd88dd7a767 (patch) | |
tree | 2e51705e103e92c7be1b21e8bd8ffd5b5d0e4d52 /test/CodeGen | |
parent | dbe13110f59f48b4dbb7552b3ac2935acdeece7f (diff) | |
download | src-6b9a6e390fbb92c40eb9c6ac9e7abbd88dd7a767.tar.gz src-6b9a6e390fbb92c40eb9c6ac9e7abbd88dd7a767.zip |
Vendor import of clang release_31 branch r155985:vendor/clang/clang-release_31-r155985
Notes
Notes:
svn path=/vendor/clang/dist/; revision=234973
svn path=/vendor/clang/clang-release_31-r155985/; revision=234974; tag=vendor/clang/clang-release_31-r155985
Diffstat (limited to 'test/CodeGen')
-rw-r--r-- | test/CodeGen/arm-homogenous.c | 160 | ||||
-rw-r--r-- | test/CodeGen/avx-shuffle-builtins.c | 6 | ||||
-rw-r--r-- | test/CodeGen/avx2-builtins.c | 6 | ||||
-rw-r--r-- | test/CodeGen/builtins-x86.c | 3 | ||||
-rw-r--r-- | test/CodeGen/may-alias.c | 2 | ||||
-rw-r--r-- | test/CodeGen/packed-nest-unpacked.c | 18 | ||||
-rw-r--r-- | test/CodeGen/tbaa-for-vptr.cpp | 2 |
7 files changed, 188 insertions, 9 deletions
diff --git a/test/CodeGen/arm-homogenous.c b/test/CodeGen/arm-homogenous.c new file mode 100644 index 000000000000..eb3d5a6bd631 --- /dev/null +++ b/test/CodeGen/arm-homogenous.c @@ -0,0 +1,160 @@ +// RUN: %clang_cc1 -triple armv7---eabi -target-abi aapcs -mfloat-abi hard -emit-llvm %s -o - | FileCheck %s + +typedef long long int64_t; +typedef unsigned int uint32_t; + +/* This is not a homogenous aggregate - fundamental types are different */ +typedef union { + float f[4]; + uint32_t i[4]; +} union_with_first_floats; +union_with_first_floats g_u_f; + +extern void takes_union_with_first_floats(union_with_first_floats a); +extern union_with_first_floats returns_union_with_first_floats(void); + +void test_union_with_first_floats(void) { + takes_union_with_first_floats(g_u_f); +} +// CHECK: declare arm_aapcs_vfpcc void @takes_union_with_first_floats([4 x i32]) + +void test_return_union_with_first_floats(void) { + g_u_f = returns_union_with_first_floats(); +} +// CHECK: declare arm_aapcs_vfpcc void @returns_union_with_first_floats(%union.union_with_first_floats* sret) + +/* This is not a homogenous aggregate - fundamental types are different */ +typedef union { + uint32_t i[4]; + float f[4]; +} union_with_non_first_floats; +union_with_non_first_floats g_u_nf_f; + +extern void takes_union_with_non_first_floats(union_with_non_first_floats a); +extern union_with_non_first_floats returns_union_with_non_first_floats(void); + +void test_union_with_non_first_floats(void) { + takes_union_with_non_first_floats(g_u_nf_f); +} +// CHECK: declare arm_aapcs_vfpcc void @takes_union_with_non_first_floats([4 x i32]) + +void test_return_union_with_non_first_floats(void) { + g_u_nf_f = returns_union_with_non_first_floats(); +} +// CHECK: declare arm_aapcs_vfpcc void @returns_union_with_non_first_floats(%union.union_with_non_first_floats* sret) + +/* This is not a homogenous aggregate - fundamental types are different */ +typedef struct { + float a; + union_with_first_floats b; +} struct_with_union_with_first_floats; +struct_with_union_with_first_floats g_s_f; + +extern void takes_struct_with_union_with_first_floats(struct_with_union_with_first_floats a); +extern struct_with_union_with_first_floats returns_struct_with_union_with_first_floats(void); + +void test_struct_with_union_with_first_floats(void) { + takes_struct_with_union_with_first_floats(g_s_f); +} +// CHECK: declare arm_aapcs_vfpcc void @takes_struct_with_union_with_first_floats([5 x i32]) + +void test_return_struct_with_union_with_first_floats(void) { + g_s_f = returns_struct_with_union_with_first_floats(); +} +// CHECK: declare arm_aapcs_vfpcc void @returns_struct_with_union_with_first_floats(%struct.struct_with_union_with_first_floats* sret) + +/* This is not a homogenous aggregate - fundamental types are different */ +typedef struct { + float a; + union_with_non_first_floats b; +} struct_with_union_with_non_first_floats; +struct_with_union_with_non_first_floats g_s_nf_f; + +extern void takes_struct_with_union_with_non_first_floats(struct_with_union_with_non_first_floats a); +extern struct_with_union_with_non_first_floats returns_struct_with_union_with_non_first_floats(void); + +void test_struct_with_union_with_non_first_floats(void) { + takes_struct_with_union_with_non_first_floats(g_s_nf_f); +} +// CHECK: declare arm_aapcs_vfpcc void @takes_struct_with_union_with_non_first_floats([5 x i32]) + +void test_return_struct_with_union_with_non_first_floats(void) { + g_s_nf_f = returns_struct_with_union_with_non_first_floats(); +} +// CHECK: declare arm_aapcs_vfpcc void @returns_struct_with_union_with_non_first_floats(%struct.struct_with_union_with_non_first_floats* sret) + +/* Plain array is not a homogenous aggregate */ +extern void takes_array_of_floats(float a[4]); +void test_array_of_floats(void) { + float a[4] = {1.0, 2.0, 3.0, 4.0}; + takes_array_of_floats(a); +} +// CHECK: declare arm_aapcs_vfpcc void @takes_array_of_floats(float*) + +/* Struct-type homogenous aggregate */ +typedef struct { + float x, y, z, w; +} struct_with_fundamental_elems; +struct_with_fundamental_elems g_s; + +extern void takes_struct_with_fundamental_elems(struct_with_fundamental_elems a); +extern struct_with_fundamental_elems returns_struct_with_fundamental_elems(void); + +void test_struct_with_fundamental_elems(void) { + takes_struct_with_fundamental_elems(g_s); +// CHECK: call arm_aapcs_vfpcc void @takes_struct_with_fundamental_elems(float {{.*}}, float {{.*}}, float{{.*}}, float {{.*}}) +} +// CHECK: declare arm_aapcs_vfpcc void @takes_struct_with_fundamental_elems(float, float, float, float) + +void test_return_struct_with_fundamental_elems(void) { + g_s = returns_struct_with_fundamental_elems(); +// CHECK: call arm_aapcs_vfpcc %struct.struct_with_fundamental_elems @returns_struct_with_fundamental_elems() +} +// CHECK: declare arm_aapcs_vfpcc %struct.struct_with_fundamental_elems @returns_struct_with_fundamental_elems() + +/* Array-type homogenous aggregate */ +typedef struct { + float xyzw[4]; +} struct_with_array; +struct_with_array g_s_a; + +extern void takes_struct_with_array(struct_with_array a); +extern struct_with_array returns_struct_with_array(void); + +void test_struct_with_array(void) { + takes_struct_with_array(g_s_a); +// CHECK: call arm_aapcs_vfpcc void @takes_struct_with_array(float {{.*}}, float {{.*}}, float {{.*}}, float {{.*}}) +} +// CHECK: declare arm_aapcs_vfpcc void @takes_struct_with_array(float, float, float, float) + +void test_return_struct_with_array(void) { + g_s_a = returns_struct_with_array(); +// CHECK: call arm_aapcs_vfpcc %struct.struct_with_array @returns_struct_with_array() +} +// CHECK: declare arm_aapcs_vfpcc %struct.struct_with_array @returns_struct_with_array() + +/* This union is a homogenous aggregate. Check that it's passed properly */ +typedef union { + struct_with_fundamental_elems xyzw; + float a[3]; +} union_with_struct_with_fundamental_elems; +union_with_struct_with_fundamental_elems g_u_s_fe; + +extern void takes_union_with_struct_with_fundamental_elems(union_with_struct_with_fundamental_elems a); +extern union_with_struct_with_fundamental_elems returns_union_with_struct_with_fundamental_elems(void); + +void test_union_with_struct_with_fundamental_elems(void) { + takes_union_with_struct_with_fundamental_elems(g_u_s_fe); +// CHECK: call arm_aapcs_vfpcc void @takes_union_with_struct_with_fundamental_elems(float {{.*}}, float {{.*}}, float {{.*}}, float {{.*}}) +} +// CHECK: declare arm_aapcs_vfpcc void @takes_union_with_struct_with_fundamental_elems(float, float, float, float) + +void test_return_union_with_struct_with_fundamental_elems(void) { + g_u_s_fe = returns_union_with_struct_with_fundamental_elems(); +// CHECK: call arm_aapcs_vfpcc %union.union_with_struct_with_fundamental_elems @returns_union_with_struct_with_fundamental_elems() +} +// CHECK: declare arm_aapcs_vfpcc %union.union_with_struct_with_fundamental_elems @returns_union_with_struct_with_fundamental_elems() + +// FIXME: Tests necessary: +// - Vectors +// - C++ stuff
\ No newline at end of file diff --git a/test/CodeGen/avx-shuffle-builtins.c b/test/CodeGen/avx-shuffle-builtins.c index 538ae50c938d..d071f825aa9e 100644 --- a/test/CodeGen/avx-shuffle-builtins.c +++ b/test/CodeGen/avx-shuffle-builtins.c @@ -48,18 +48,18 @@ __m256 test_mm256_permute_ps(__m256 a) { __m256d test_mm256_permute2f128_pd(__m256d a, __m256d b) { // Check if the mask is correct - // CHECK: shufflevector{{.*}}<i32 2, i32 3, i32 6, i32 7> + // CHECK: @llvm.x86.avx.vperm2f128.pd.256 return _mm256_permute2f128_pd(a, b, 0x31); } __m256 test_mm256_permute2f128_ps(__m256 a, __m256 b) { // Check if the mask is correct - // CHECK: shufflevector{{.*}}<i32 12, i32 13, i32 14, i32 15, i32 4, i32 5, i32 6, i32 7> + // CHECK: @llvm.x86.avx.vperm2f128.ps.256 return _mm256_permute2f128_ps(a, b, 0x13); } __m256i test_mm256_permute2f128_si256(__m256i a, __m256i b) { // Check if the mask is correct - // CHECK: shufflevector{{.*}}<i32 0, i32 1, i32 2, i32 3, i32 8, i32 9, i32 10, i32 11> + // CHECK: @llvm.x86.avx.vperm2f128.si.256 return _mm256_permute2f128_si256(a, b, 0x20); } diff --git a/test/CodeGen/avx2-builtins.c b/test/CodeGen/avx2-builtins.c index a5ddc8eb2ed8..7d166b562638 100644 --- a/test/CodeGen/avx2-builtins.c +++ b/test/CodeGen/avx2-builtins.c @@ -662,7 +662,7 @@ __m256i test_mm256_permutevar8x32_epi32(__m256i a, __m256i b) { } __m256d test_mm256_permute4x64_pd(__m256d a) { - // CHECK: @llvm.x86.avx2.permpd + // CHECK: shufflevector{{.*}}<i32 1, i32 2, i32 1, i32 0> return _mm256_permute4x64_pd(a, 25); } @@ -672,12 +672,12 @@ __m256 test_mm256_permutevar8x32_ps(__m256 a, __m256 b) { } __m256i test_mm256_permute4x64_epi64(__m256i a) { - // CHECK: @llvm.x86.avx2.permq + // CHECK: shufflevector{{.*}}<i32 3, i32 0, i32 2, i32 0> return _mm256_permute4x64_epi64(a, 35); } __m256i test_mm256_permute2x128_si256(__m256i a, __m256i b) { - // CHECK: shufflevector{{.*}}<i32 2, i32 3, i32 6, i32 7> + // CHECK: @llvm.x86.avx2.vperm2i128 return _mm256_permute2x128_si256(a, b, 0x31); } diff --git a/test/CodeGen/builtins-x86.c b/test/CodeGen/builtins-x86.c index 30138d6374fd..acb5554db4d3 100644 --- a/test/CodeGen/builtins-x86.c +++ b/test/CodeGen/builtins-x86.c @@ -414,6 +414,9 @@ void f0() { tmp_V4i = __builtin_ia32_cvttpd2dq256(tmp_V4d); tmp_V4i = __builtin_ia32_cvtpd2dq256(tmp_V4d); tmp_V8i = __builtin_ia32_cvttps2dq256(tmp_V8f); + tmp_V4d = __builtin_ia32_vperm2f128_pd256(tmp_V4d, tmp_V4d, 0x7); + tmp_V8f = __builtin_ia32_vperm2f128_ps256(tmp_V8f, tmp_V8f, 0x7); + tmp_V8i = __builtin_ia32_vperm2f128_si256(tmp_V8i, tmp_V8i, 0x7); tmp_V4d = __builtin_ia32_vinsertf128_pd256(tmp_V4d, tmp_V2d, 0x7); tmp_V8f = __builtin_ia32_vinsertf128_ps256(tmp_V8f, tmp_V4f, 0x7); tmp_V8i = __builtin_ia32_vinsertf128_si256(tmp_V8i, tmp_V4i, 0x7); diff --git a/test/CodeGen/may-alias.c b/test/CodeGen/may-alias.c index 6171be763dc7..b73ee15f8745 100644 --- a/test/CodeGen/may-alias.c +++ b/test/CodeGen/may-alias.c @@ -26,5 +26,5 @@ void test1(struct Test1MA *p1, struct Test1 *p2) { // CHECK: !0 = metadata !{metadata !"any pointer", metadata !1} // CHECK: !1 = metadata !{metadata !"omnipotent char", metadata !2} -// CHECK: !2 = metadata !{metadata !"Simple C/C++ TBAA", null} +// CHECK: !2 = metadata !{metadata !"Simple C/C++ TBAA"} // CHECK: !3 = metadata !{metadata !"int", metadata !1} diff --git a/test/CodeGen/packed-nest-unpacked.c b/test/CodeGen/packed-nest-unpacked.c index af1508ae81de..0ccc0c41b7e6 100644 --- a/test/CodeGen/packed-nest-unpacked.c +++ b/test/CodeGen/packed-nest-unpacked.c @@ -1,11 +1,12 @@ // RUN: %clang_cc1 %s -triple x86_64-apple-macosx10.7.2 -emit-llvm -o - | FileCheck %s -// <rdar://problem/10463337> struct X { int x[6]; }; struct Y { char x[13]; struct X y; } __attribute((packed)); struct Y g; void f(struct X); +struct X foo(void); +// <rdar://problem/10463337> struct X test1() { // CHECK: @test1 // 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) @@ -24,8 +25,23 @@ void test3(struct X a) { g.y = a; } +// <rdar://problem/10530444> void test4() { // CHECK: @test4 // 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) f(g.y); } + +// PR12395 +int test5() { + // CHECK: @test5 + // CHECK: load i32* getelementptr inbounds (%struct.Y* @g, i32 0, i32 1, i32 0, i64 0), align 1 + return g.y.x[0]; +} + +// <rdar://problem/11220251> +void test6() { + // CHECK: @test6 + // 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) + g.y = foo(); +} diff --git a/test/CodeGen/tbaa-for-vptr.cpp b/test/CodeGen/tbaa-for-vptr.cpp index f4885f805d27..5ce6bf32edf3 100644 --- a/test/CodeGen/tbaa-for-vptr.cpp +++ b/test/CodeGen/tbaa-for-vptr.cpp @@ -16,4 +16,4 @@ void CallFoo(A *a) { // CHECK: %{{.*}} = load {{.*}} !tbaa !0 // CHECK: store {{.*}} !tbaa !0 // CHECK: !0 = metadata !{metadata !"vtable pointer", metadata !1} -// CHECK: !1 = metadata !{metadata !"Simple C/C++ TBAA", null} +// CHECK: !1 = metadata !{metadata !"Simple C/C++ TBAA"} |