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