Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / debug-info-structured-binding-bitfield.cpp
blob0234e41009f62250998430790e7df16e9733ef48
1 // RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone -triple aarch64-arm-none-eabi %s -o - | FileCheck %s
3 struct S0 {
4 unsigned int x : 16;
5 unsigned int y : 16;
6 };
8 // CHECK-LABEL: define dso_local void @_Z3fS0v
9 // CHECK: alloca %struct.S0, align 4
10 // CHECK-NEXT: [[TMP0:%.*]] = alloca %struct.S0, align 4
11 // CHECK: call void @llvm.dbg.declare(metadata ptr [[TMP0]], metadata [[S0_A:![0-9]+]], metadata !DIExpression())
12 // CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr [[TMP0]], metadata [[S0_B:![0-9]+]], metadata !DIExpression(DW_OP_plus_uconst, 2))
14 void fS0() {
15 S0 s0;
16 auto [a, b] = s0;
19 struct S1 {
20 volatile unsigned int x : 16;
21 volatile unsigned int y : 16;
24 // CHECK-LABEL: define dso_local void @_Z3fS1v
25 // CHECK: alloca %struct.S1, align 4
26 // CHECK-NEXT: [[TMP0:%.*]] = alloca %struct.S1, align 4
27 // CHECK: call void @llvm.dbg.declare(metadata ptr [[TMP0]], metadata [[S1_A:![0-9]+]], metadata !DIExpression())
28 // CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr [[TMP0]], metadata [[S1_B:![0-9]+]], metadata !DIExpression(DW_OP_plus_uconst, 2))
30 void fS1() {
31 S1 s1;
32 auto [a, b] = s1;
35 struct S2 {
36 unsigned int x : 8;
37 unsigned int y : 8;
40 // CHECK-LABEL: define dso_local void @_Z3fS2v
41 // CHECK: alloca %struct.S2, align 4
42 // CHECK-NEXT: [[TMP0:%.*]] = alloca %struct.S2, align 4
43 // CHECK: call void @llvm.dbg.declare(metadata ptr [[TMP0]], metadata [[S2_A:![0-9]+]], metadata !DIExpression())
44 // CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr [[TMP0]], metadata [[S2_B:![0-9]+]], metadata !DIExpression(DW_OP_plus_uconst, 1))
46 void fS2() {
47 S2 s2;
48 auto [a, b] = s2;
51 struct S3 {
52 volatile unsigned int x : 8;
53 volatile unsigned int y : 8;
56 // CHECK-LABEL: define dso_local void @_Z3fS3v
57 // CHECK: alloca %struct.S3, align 4
58 // CHECK-NEXT: [[TMP0:%.*]] = alloca %struct.S3, align 4
59 // CHECK: call void @llvm.dbg.declare(metadata ptr [[TMP0]], metadata [[S3_A:![0-9]+]], metadata !DIExpression())
60 // CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr [[TMP0]], metadata [[S3_B:![0-9]+]], metadata !DIExpression(DW_OP_plus_uconst, 1))
62 void fS3() {
63 S3 s3;
64 auto [a, b] = s3;
67 struct S4 {
68 unsigned int x : 8;
69 unsigned int y : 16;
72 // CHECK-LABEL: define dso_local void @_Z3fS4v
73 // CHECK: alloca %struct.S4, align 4
74 // CHECK-NEXT: [[TMP0:%.*]] = alloca %struct.S4, align 4
75 // CHECK: call void @llvm.dbg.declare(metadata ptr [[TMP0]], metadata [[S4_A:![0-9]+]], metadata !DIExpression())
76 // CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr [[TMP0]], metadata [[S4_B:![0-9]+]], metadata !DIExpression(DW_OP_plus_uconst, 1))
78 void fS4() {
79 S4 s4;
80 auto [a, b] = s4;
83 struct S5 {
84 volatile unsigned int x : 8;
85 volatile unsigned int y : 16;
88 // CHECK-LABEL: define dso_local void @_Z3fS5v
89 // CHECK: alloca %struct.S5, align 4
90 // CHECK-NEXT: [[TMP0:%.*]] = alloca %struct.S5, align 4
91 // CHECK: call void @llvm.dbg.declare(metadata ptr [[TMP0]], metadata [[S5_A:![0-9]+]], metadata !DIExpression())
92 // CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr [[TMP0]], metadata [[S5_B:![0-9]+]], metadata !DIExpression(DW_OP_plus_uconst, 1))
94 void fS5() {
95 S5 s5;
96 auto [a, b] = s5;
99 struct S6 {
100 unsigned int x : 16;
101 unsigned int y : 8;
104 // CHECK-LABEL: define dso_local void @_Z3fS6v
105 // CHECK: alloca %struct.S6, align 4
106 // CHECK-NEXT: [[TMP0:%.*]] = alloca %struct.S6, align 4
107 // CHECK: call void @llvm.dbg.declare(metadata ptr [[TMP0]], metadata [[S6_A:![0-9]+]], metadata !DIExpression())
108 // CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr [[TMP0]], metadata [[S6_B:![0-9]+]], metadata !DIExpression(DW_OP_plus_uconst, 2))
110 void fS6() {
111 S6 s6;
112 auto [a, b] = s6;
115 struct S7 {
116 volatile unsigned int x : 16;
117 volatile unsigned int y : 8;
120 // CHECK-LABEL: define dso_local void @_Z3fS7v
121 // CHECK: alloca %struct.S7, align 4
122 // CHECK-NEXT: [[TMP0:%.*]] = alloca %struct.S7, align 4
123 // CHECK: call void @llvm.dbg.declare(metadata ptr [[TMP0]], metadata [[S7_A:![0-9]+]], metadata !DIExpression())
124 // CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr [[TMP0]], metadata [[S7_B:![0-9]+]], metadata !DIExpression(DW_OP_plus_uconst, 2))
126 void fS7() {
127 S7 s7;
128 auto [a, b] = s7;
131 struct S8 {
132 unsigned int x : 16;
133 volatile unsigned int y : 16;
136 // CHECK-LABEL: define dso_local void @_Z3fS8v
137 // CHECK: alloca %struct.S8, align 4
138 // CHECK-NEXT: [[TMP0:%.*]] = alloca %struct.S8, align 4
139 // CHECK: call void @llvm.dbg.declare(metadata ptr [[TMP0]], metadata [[S8_A:![0-9]+]], metadata !DIExpression())
140 // CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr [[TMP0]], metadata [[S8_B:![0-9]+]], metadata !DIExpression(DW_OP_plus_uconst, 2))
142 void fS8() {
143 S8 s8;
144 auto [a, b] = s8;
147 struct S9 {
148 unsigned int x : 16;
149 unsigned int y : 32;
152 // CHECK-LABEL: define dso_local void @_Z3fS9v
153 // CHECK: alloca %struct.S9, align 4
154 // CHECK-NEXT: [[TMP0:%.*]] = alloca %struct.S9, align 4
155 // CHECK: call void @llvm.dbg.declare(metadata ptr [[TMP0]], metadata [[S9_A:![0-9]+]], metadata !DIExpression())
156 // CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr [[TMP0]], metadata [[S9_B:![0-9]+]], metadata !DIExpression(DW_OP_plus_uconst, 4))
158 void fS9() {
159 S9 s9;
160 auto [a, b] = s9;
163 struct S10 {
164 const unsigned int x : 8;
165 const volatile unsigned int y : 8;
167 // CHECK-LABEL: define dso_local void @_Z4fS10v
168 // CHECK: alloca %struct.S10, align 4
169 // CHECK-NEXT: [[TMP0:%.*]] = alloca %struct.S10, align 4
170 // CHECK: call void @llvm.dbg.declare(metadata ptr [[TMP0]], metadata [[S10_A:![0-9]+]], metadata !DIExpression())
171 // CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr [[TMP0]], metadata [[S10_B:![0-9]+]], metadata !DIExpression(DW_OP_plus_uconst, 1))
173 S10() : x(0), y(0) {}
176 void fS10() {
177 S10 s10;
178 auto [a, b] = s10;
181 // It's currently not possible to produce complete debug information for the following cases.
182 // Confirm that no wrong debug info is output.
183 // Once this is implemented, these tests should be amended.
184 struct S11 {
185 unsigned int x : 15;
186 unsigned int y : 16;
189 // CHECK-LABEL: define dso_local void @_Z4fS11v
190 // CHECK: alloca %struct.S11, align 4
191 // CHECK-NEXT: [[TMP0:%.*]] = alloca %struct.S11, align 4
192 // CHECK-NOT: call void @llvm.dbg.declare(metadata ptr [[TMP0]]
194 void fS11() {
195 S11 s11;
196 auto [a, b] = s11;
199 struct S12 {
200 unsigned int x : 16;
201 unsigned int y : 17;
204 // CHECK-LABEL: define dso_local void @_Z4fS12v
205 // CHECK: alloca %struct.S12, align 4
206 // CHECK-NEXT: [[TMP0:%.*]] = alloca %struct.S12, align 4
207 // CHECK: call void @llvm.dbg.declare(metadata ptr [[TMP0]], metadata [[S12_A:![0-9]+]], metadata !DIExpression())
208 // CHECK-NOT: call void @llvm.dbg.declare(metadata ptr [[TMP0]]
210 void fS12() {
211 S12 s12;
212 auto [a, b] = s12;
215 struct __attribute__((packed)) S13 {
216 unsigned int x : 15;
217 unsigned int y : 16;
220 // CHECK-LABEL: define dso_local void @_Z4fS13v
221 // CHECK: alloca %struct.S13, align 1
222 // CHECK-NEXT: [[TMP0:%.*]] = alloca %struct.S13, align 1
223 // CHECK-NOT: call void @llvm.dbg.declare(metadata ptr [[TMP0]]
225 void fS13() {
226 S13 s13;
227 auto [a, b] = s13;
230 // CHECK: [[UINT_TY:![0-9]+]] = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
231 // CHECK: [[S0_A]] = !DILocalVariable(name: "a", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[USHORT_TY:![0-9]+]])
232 // CHECK: [[USHORT_TY]] = !DIBasicType(name: "unsigned short", size: 16, encoding: DW_ATE_unsigned)
233 // CHECK: [[S0_B]] = !DILocalVariable(name: "b", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[USHORT_TY]])
235 // CHECK: [[VOLATILE_UINT_TY:![0-9]+]] = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: [[UINT_TY]])
236 // CHECK: [[S1_A]] = !DILocalVariable(name: "a", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[VOLATILE_USHORT_TY:![0-9]+]])
237 // CHECK: [[VOLATILE_USHORT_TY]] = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: [[USHORT_TY]])
238 // CHECK: [[S1_B]] = !DILocalVariable(name: "b", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[VOLATILE_USHORT_TY]])
240 // CHECK: [[S2_A]] = !DILocalVariable(name: "a", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[UCHAR_TY:![0-9]+]])
241 // CHECK: [[UCHAR_TY]] = !DIBasicType(name: "unsigned char", size: 8, encoding: DW_ATE_unsigned_char)
242 // CHECK: [[S2_B]] = !DILocalVariable(name: "b", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[UCHAR_TY]])
244 // CHECK: [[S3_A]] = !DILocalVariable(name: "a", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[VOLATILE_UCHAR_TY:![0-9]+]])
245 // CHECK: [[VOLATILE_UCHAR_TY]] = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: [[UCHAR_TY]])
246 // CHECK: [[S3_B]] = !DILocalVariable(name: "b", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[VOLATILE_UCHAR_TY]])
248 // CHECK: [[S4_A]] = !DILocalVariable(name: "a", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[UCHAR_TY]])
249 // CHECK: [[S4_B]] = !DILocalVariable(name: "b", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[USHORT_TY]])
251 // CHECK: [[S5_A]] = !DILocalVariable(name: "a", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[VOLATILE_UCHAR_TY]])
252 // CHECK: [[S5_B]] = !DILocalVariable(name: "b", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[VOLATILE_USHORT_TY]])
254 // CHECK: [[S6_A]] = !DILocalVariable(name: "a", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[USHORT_TY]])
255 // CHECK: [[S6_B]] = !DILocalVariable(name: "b", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[UCHAR_TY]])
257 // CHECK: [[S7_A]] = !DILocalVariable(name: "a", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[VOLATILE_USHORT_TY]])
258 // CHECK: [[S7_B]] = !DILocalVariable(name: "b", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[VOLATILE_UCHAR_TY]])
260 // CHECK: [[S8_A]] = !DILocalVariable(name: "a", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[USHORT_TY]])
261 // CHECK: [[S8_B]] = !DILocalVariable(name: "b", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[VOLATILE_USHORT_TY]])
263 // CHECK: [[S9_A]] = !DILocalVariable(name: "a", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[USHORT_TY]])
264 // CHECK: [[S9_B]] = !DILocalVariable(name: "b", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[UINT_TY]])
266 // CHECK: [[CONST_UINT_TY:![0-9]+]] = !DIDerivedType(tag: DW_TAG_const_type, baseType: [[UINT_TY]])
267 // CHECK: [[S10_A]] = !DILocalVariable(name: "a", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[CONST_UCHAR_TY:![0-9]+]])
268 // CHECK: [[CONST_UCHAR_TY]] = !DIDerivedType(tag: DW_TAG_const_type, baseType: [[UCHAR_TY]])
269 // CHECK: [[S10_B]] = !DILocalVariable(name: "b", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[CONST_VOLATILE_UCHAR_TY:![0-9]+]])
270 // CHECK: [[CONST_VOLATILE_UCHAR_TY]] = !DIDerivedType(tag: DW_TAG_const_type, baseType: [[VOLATILE_UCHAR_TY]])
272 // S11
273 // CHECK-NOT: !DILocalVariable(name: "a"
274 // CHECK-NOT: !DILocalVariable(name: "b"
276 // S12
277 // CHECK: [[S12_A]] = !DILocalVariable(name: "a", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: [[USHORT_TY]])
278 // CHECK-NOT: !DILocalVariable(name: "b"
280 // S13
281 // CHECK-NOT: !DILocalVariable(name: "a"
282 // CHECK-NOT: !DILocalVariable(name: "b"