Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / CodeGen / alignment.c
blobb70297a389897909f33d1d151da07ca9f5a78c8f
1 // RUN: %clang_cc1 -triple i386-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,NONCOFF
2 // RUN: %clang_cc1 -triple i386-unknown-windows-pc -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,COFF
4 __attribute((aligned(16))) float a[128];
5 union {int a[4]; __attribute((aligned(16))) float b[4];} b;
7 // CHECK: @a = {{.*}}zeroinitializer, align 16
8 // CHECK: @b = {{.*}}zeroinitializer, align 16
10 long long int test5[1024];
11 // CHECK-DAG: @test5 = {{.*}}global [1024 x i64] zeroinitializer, align 8
13 // PR5279 - Reduced alignment on typedef.
14 typedef int myint __attribute__((aligned(1)));
16 void test1(myint *p) {
17 *p = 0;
19 // CHECK: @test1(
20 // CHECK: store i32 0, ptr {{.*}}, align 1
21 // CHECK: ret void
23 int test1a(myint *p) {
24 return *p;
26 // CHECK: @test1a(
27 // CHECK: load i32, ptr {{.*}}, align 1
28 // CHECK: ret i32
31 // PR5279 - Reduced alignment on typedef.
32 typedef float __attribute__((vector_size(16), aligned(4))) packedfloat4;
34 void test2(packedfloat4 *p) {
35 *p = (packedfloat4) { 3.2f, 2.3f, 0.1f, 0.0f };
37 // CHECK: @test2(
38 // CHECK: store <4 x float> {{.*}}, align 4
39 // CHECK: ret void
42 // PR5279 - Reduced alignment on typedef.
43 typedef float __attribute__((ext_vector_type(3), aligned(4))) packedfloat3;
44 void test3(packedfloat3 *p) {
45 *p = (packedfloat3) { 3.2f, 2.3f, 0.1f };
47 // CHECK: @test3(
48 // CHECK: store <4 x float> {{.*}}, align 4
49 // CHECK: ret void
53 typedef float __attribute__((vector_size(16), aligned(64))) float4align64;
55 // Typedef alignment lost in p[]-style dereferencing
56 void test4(float4align64 *p) {
57 p[0] = (float4align64){ 3.2f, 2.3f, 0.1f, 0.0f };
59 // CHECK: @test4(
60 // CHECK: store <4 x float> {{.*}}, ptr {{.*}}, align 64
62 // PR24944 - Typedef alignment not honored on no-op cast.
63 typedef float __attribute__((vector_size(16), aligned(16))) float4align16;
64 typedef float __attribute__((vector_size(16), aligned(2))) float4align2;
65 void test6(float4align64 *p) {
66 float4align64 vec = *(float4align2*) p;
68 // CHECK-LABEL: @test6
69 // CHECK: load <4 x float>, ptr {{.*}}, align 2
71 typedef int __attribute__((ext_vector_type(200 * 16))) BigVecTy;
72 void test7(void) {
73 BigVecTy V;
75 // CHECK-LABEL: @test7
76 // NONCOFF: alloca <3200 x i32>, align 16384
77 // COFF: alloca <3200 x i32>, align 8192