Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGen / SystemZ / zos-alignment.c
blob65c6843e0d9acdad9932f19401b5f06569c3eb03
1 // RUN: %clang_cc1 -emit-llvm-only -triple s390x-none-zos -fdump-record-layouts %s | FileCheck %s --check-prefix=CHECK
2 // RUN: %clang_cc1 -emit-llvm -triple s390x-none-zos %s -o - | FileCheck %s --check-prefix=DECL
4 static int __attribute__((aligned(32))) v0;
5 int __attribute__((aligned(32))) v1;
6 typedef int __attribute__((aligned(32))) int32;
7 static int32 v2;
8 int32 v3;
9 int f0(void) { return v0 + v1 + v2 + v3; }
10 // DECL: @v0 {{.*}} align 16
11 // DECL-NEXT: @v1 {{.*}} align 32
12 // DECL-NEXT: @v2 {{.*}} align 16
13 // DECL-NEXT: @v3 {{.*}} align 32
15 const struct cs0 {
16 unsigned long : 0;
17 long long a;
18 } CS0 = {};
19 // CHECK: 0 | struct cs0
20 // CHECK-NEXT: 0:- | unsigned long
21 // CHECK-NEXT: 0 | long long a
22 // CHECK-NEXT: | [sizeof=8, align=8]
24 volatile struct vs0 {
25 long : 0;
26 short a;
27 } VS0;
28 // CHECK: 0 | struct vs0
29 // CHECK-NEXT: 0:- | long
30 // CHECK-NEXT: 0 | short a
31 // CHECK-NEXT: | [sizeof=2, align=2]
33 struct s0 {
34 short a : 3;
35 long b : 5;
36 int c : 1;
37 long d : 10;
38 char e : 5;
39 } S0;
40 // CHECK: 0 | struct s0
41 // CHECK-NEXT: 0:0-2 | short a
42 // CHECK-NEXT: 0:3-7 | long b
43 // CHECK-NEXT: 1:0-0 | int c
44 // CHECK-NEXT: 1:1-10 | long d
45 // CHECK-NEXT: 2:3-7 | char e
46 // CHECK-NEXT: | [sizeof=3, align=1]
48 struct s1 {
49 char a : 7;
50 long b : 27;
51 int c : 2;
52 } S1;
53 // CHECK: 0 | struct s1
54 // CHECK-NEXT: 0:0-6 | char a
55 // CHECK-NEXT: 0:7-33 | long b
56 // CHECK-NEXT: 4:2-3 | int c
57 // CHECK-NEXT: | [sizeof=5, align=1]
59 struct s2 {
60 char a : 7;
61 char : 0;
62 short : 0;
63 short : 0;
64 } S2;
65 // CHECK: 0 | struct s2
66 // CHECK-NEXT: 0:0-6 | char a
67 // CHECK-NEXT: 4:- | char
68 // CHECK-NEXT: 4:- | short
69 // CHECK-NEXT: 4:- | short
70 // CHECK-NEXT: | [sizeof=4, align=4]
72 struct s3 {
73 int a;
74 int b : 16;
75 char : 0;
76 char c : 1;
77 } S3;
78 // CHECK: 0 | struct s3
79 // CHECK-NEXT: 0 | int a
80 // CHECK-NEXT: 4:0-15 | int b
81 // CHECK-NEXT: 8:- | char
82 // CHECK-NEXT: 8:0-0 | char c
83 // CHECK-NEXT: | [sizeof=12, align=4]
85 struct s4 {
86 unsigned int __attribute__((aligned(32))) a;
87 } S4;
88 // CHECK: 0 | struct s4
89 // CHECK-NEXT: 0 | unsigned int a
90 // CHECK-NEXT: | [sizeof=32, align=32]
92 struct s5 {
93 char a;
94 int b : 19 __attribute__((aligned(4)));
95 int c : 22 __attribute__((aligned(8)));
96 int : 0;
97 int d : 10;
98 } S5;
99 // CHECK: 0 | struct s5
100 // CHECK-NEXT: 0 | char a
101 // CHECK-NEXT: 4:0-18 | int b
102 // CHECK-NEXT: 8:0-21 | int c
103 // CHECK-NEXT: 12:- | int
104 // CHECK-NEXT: 12:0-9 | int d
105 // CHECK-NEXT: | [sizeof=16, align=8]
107 struct s6 {
108 char *a;
109 char *b[];
110 } S6;
111 // CHECK: 0 | struct s6
112 // CHECK-NEXT: 0 | char * a
113 // CHECK-NEXT: 8 | char *[] b
114 // CHECK-NEXT: | [sizeof=8, align=8]
116 struct s7 {
117 long : 0;
118 short a;
119 } S7;
120 // CHECK: 0 | struct s7
121 // CHECK-NEXT: 0:- | long
122 // CHECK-NEXT: 0 | short a
123 // CHECK-NEXT: | [sizeof=2, align=2]
125 #pragma pack(2)
126 struct s8 {
127 unsigned long : 0;
128 long long a;
129 } S8;
130 #pragma pack()
131 // CHECK: 0 | struct s8
132 // CHECK-NEXT: 0:- | unsigned long
133 // CHECK-NEXT: 0 | long long a
134 // CHECK-NEXT: | [sizeof=8, align=2]
136 struct s9 {
137 unsigned int : 0;
138 unsigned short : 0;
139 } S9;
140 // CHECK: 0 | struct s9
141 // CHECK-NEXT: 0:- | unsigned int
142 // CHECK-NEXT: 0:- | unsigned short
143 // CHECK-NEXT: | [sizeof=0, align=1]
145 struct s10 {
146 unsigned int __attribute__((aligned)) a;
147 } S10;
148 // CHECK: 0 | struct s10
149 // CHECK-NEXT: 0 | unsigned int a
150 // CHECK-NEXT: | [sizeof=8, align=8]
152 struct s11 {
153 char a;
154 long : 0;
155 char b;
156 } S11;
157 // CHECK: 0 | struct s11
158 // CHECK-NEXT: 0 | char a
159 // CHECK-NEXT: 8:- | long
160 // CHECK-NEXT: 8 | char b
161 // CHECK-NEXT: | [sizeof=16, align=8]
163 struct s12 {
164 __int128_t a;
165 } S12;
166 // CHECK: 0 | struct s12
167 // CHECK-NEXT: 0 | __int128_t a
168 // CHECK-NEXT: | [sizeof=16, align=8]
170 union u0 {
171 unsigned short d1 __attribute__((packed));
172 int d2 : 10;
173 long d3;
174 } U0 __attribute__((aligned(8)));
175 // CHECK: 0 | union u0
176 // CHECK-NEXT: 0 | unsigned short d1
177 // CHECK-NEXT: 0:0-9 | int d2
178 // CHECK-NEXT: 0 | long d3
179 // CHECK-NEXT: | [sizeof=8, align=8]
181 union u1 {
182 unsigned int : 0;
183 short a;
184 } U1;
185 // CHECK: 0 | union u1
186 // CHECK-NEXT: 0:- | unsigned int
187 // CHECK-NEXT: 0 | short a
188 // CHECK-NEXT: | [sizeof=4, align=4]
190 union u2 {
191 long : 0;
192 short a;
193 } U2;
194 // CHECK: 0 | union u2
195 // CHECK-NEXT: 0:- | long
196 // CHECK-NEXT: 0 | short a
197 // CHECK-NEXT: | [sizeof=8, align=8]
199 union u3 {
200 unsigned char : 0;
201 unsigned short : 0;
202 } U3;
203 // CHECK: 0 | union u3
204 // CHECK-NEXT: 0:- | unsigned char
205 // CHECK-NEXT: 0:- | unsigned short
206 // CHECK-NEXT: | [sizeof=0, align=4]