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