xref: /llvm-project/clang/test/CodeGen/2008-08-07-AlignPadding1.c (revision 627746581b8fde4143533937130f420bbbdf9ddf)
1 /* RUN: %clang_cc1 %s -emit-llvm -triple x86_64-apple-darwin -o - | FileCheck %s
2 /* RUN: %clang_cc1 %s -emit-llvm -triple x86_64-apple-darwin -o - -fexperimental-new-constant-interpreter | FileCheck %s
3 
4 The FE must generate padding here both at the end of each PyG_Head and
5 between array elements.  Reduced from Python. */
6 
7 typedef union _gc_head {
8   struct {
9     union _gc_head *gc_next;
10     union _gc_head *gc_prev;
11     long gc_refs;
12   } gc;
13   int dummy __attribute__((aligned(16)));
14 } PyGC_Head;
15 
16 struct gc_generation {
17   PyGC_Head head;
18   int threshold;
19   int count;
20 };
21 
22 #define GEN_HEAD(n) (&generations[n].head)
23 
24 // The idea is that there are 6 zeroinitializers in this structure initializer to cover
25 // the padding between elements.
26 // CHECK: @generations ={{.*}} global [3 x %struct.gc_generation] [%struct.gc_generation { %union._gc_head { %struct.anon { ptr @generations, ptr @generations, i64 0 }, [8 x i8] zeroinitializer }, i32 700, i32 0, [8 x i8] zeroinitializer }, %struct.gc_generation { %union._gc_head { %struct.anon { ptr getelementptr (i8, ptr @generations, i64 48), ptr getelementptr (i8, ptr @generations, i64 48), i64 0 }, [8 x i8] zeroinitializer }, i32 10, i32 0, [8 x i8] zeroinitializer }, %struct.gc_generation { %union._gc_head { %struct.anon { ptr getelementptr (i8, ptr @generations, i64 96), ptr getelementptr (i8, ptr @generations, i64 96), i64 0 }, [8 x i8] zeroinitializer }, i32 10, i32 0, [8 x i8] zeroinitializer }]
27 /* linked lists of container objects */
28 struct gc_generation generations[3] = {
29         /* PyGC_Head,                           threshold,      count */
30         {{{GEN_HEAD(0), GEN_HEAD(0), 0}},       700,            0},
31         {{{GEN_HEAD(1), GEN_HEAD(1), 0}},       10,             0},
32         {{{GEN_HEAD(2), GEN_HEAD(2), 0}},       10,             0},
33 };
34