[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGenCXX / attr-mustprogress.cpp
blob843f5460426ccf78796d1dcc995b6db48560ebc8
1 // RUN: %clang_cc1 -std=c++98 -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=CXX98 %s
2 // RUN: %clang_cc1 -std=c++11 -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=CXX11 %s
3 // RUN: %clang_cc1 -std=c++14 -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=CXX11 %s
4 // RUN: %clang_cc1 -std=c++17 -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=CXX11 %s
5 // RUN: %clang_cc1 -std=c++20 -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=CXX11 %s
7 // Check -ffinite-loops option in combination with various standard versions.
8 // RUN: %clang_cc1 -std=c++98 -ffinite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=FINITE %s
9 // RUN: %clang_cc1 -std=c++11 -ffinite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=CXX11 %s
10 // RUN: %clang_cc1 -std=c++14 -ffinite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=CXX11 %s
11 // RUN: %clang_cc1 -std=c++17 -ffinite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=CXX11 %s
12 // RUN: %clang_cc1 -std=c++20 -ffinite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=CXX11 %s
14 // Check -fno-finite-loops option in combination with various standard versions.
15 // RUN: %clang_cc1 -std=c++98 -fno-finite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=CXX98 %s
16 // RUN: %clang_cc1 -std=c++11 -fno-finite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=CXX98 %s
17 // RUN: %clang_cc1 -std=c++14 -fno-finite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=CXX98 %s
18 // RUN: %clang_cc1 -std=c++17 -fno-finite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=CXX98 %s
19 // RUN: %clang_cc1 -std=c++20 -fno-finite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=CXX98 %s
21 int a = 0;
22 int b = 0;
24 // CHECK: datalayout
26 // CXX98-NOT: mustprogress
27 // CXX11: mustprogress
28 // FINITE-NOT: mustprogress
29 // CHECK-LABEL: @_Z2f0v(
30 // CHECK-NEXT: entry:
31 // CHECK-NEXT: br label %for.cond
32 // CHECK: for.cond:
33 // CXX98-NOT: br {{.*}} llvm.loop
34 // CXX11-NEXT: br label %for.cond, !llvm.loop [[LOOP1:!.*]]
35 // FINITE-NEXT: br label %for.cond, !llvm.loop [[LOOP1:!.*]]
36 void f0() {
37 for (; ;) ;
40 // CXX98-NOT: mustprogress
41 // CXX11: mustprogress
42 // FINITE-NOT: mustprogress
43 // CHECK-LABEL: @_Z2f1v(
44 // CHECK-NEXT: entry:
45 // CHECK-NEXT: br label %for.cond
46 // CHECK: for.cond:
47 // CHECK-NEXT: br i1 true, label %for.body, label %for.end
48 // CHECK: for.body:
49 // CXX98-NOT: br {{.*}}, !llvm.loop
50 // CXX11-NEXT: br label %for.cond, !llvm.loop [[LOOP2:!.*]]
51 // FINITE-NEXT: br label %for.cond, !llvm.loop [[LOOP2:!.*]]
52 // CHECK: for.end:
53 // CHECK-NEXT: ret void
55 void f1() {
56 for (; 1;)
60 // CXX98-NOT: mustprogress
61 // CXX11: mustprogress
62 // FINITE-NOT: mustprogress
63 // CHECK-LABEL: @_Z2f2v(
64 // CHECK-NEXT: entry:
65 // CHECK-NEXT: br label %for.cond
66 // CHECK: for.cond:
67 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr @a, align 4
68 // CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr @b, align 4
69 // CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[TMP0]], [[TMP1]]
70 // CHECK-NEXT: br i1 [[CMP]], label %for.body, label %for.end
71 // CHECK: for.body:
72 // CXX98-NOT: br {{.*}}, !llvm.loop
73 // CXX11: br label %for.cond, !llvm.loop [[LOOP3:!.*]]
74 // FINITE-NEXT: br label %for.cond, !llvm.loop [[LOOP3:!.*]]
75 // CHECK: for.end:
76 // CHECK-NEXT: ret void
78 void f2() {
79 for (; a == b;)
83 // CXX98-NOT: mustprogress
84 // CXX11: mustprogress
85 // FINITE-NOT: mustprogress
86 // CHECK-LABEL: @_Z1Fv(
87 // CHECK-NEXT: entry:
88 // CHECK-NEXT: br label %for.cond
89 // CHECK: for.cond:
90 // CHECK-NEXT: br i1 true, label %for.body, label %for.end
91 // CHECK: for.body:
92 // CXX98-NOT: br {{.*}}, !llvm.loop
93 // CXX11-NEXT: br label %for.cond, !llvm.loop [[LOOP4:!.*]]
94 // FINITE-NEXT: br label %for.cond, !llvm.loop [[LOOP4:!.*]]
95 // CHECK: for.end:
96 // CHECK-NEXT: br label %for.cond1
97 // CHECK: for.cond1:
98 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr @a, align 4
99 // CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr @b, align 4
100 // CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[TMP0]], [[TMP1]]
101 // CHECK-NEXT: br i1 [[CMP]], label %for.body2, label %for.end3
102 // CHECK: for.body2:
103 // CXX98-NOT: br {{.*}}, !llvm.loop
104 // CXX11-NEXT: br label %for.cond1, !llvm.loop [[LOOP5:!.*]]
105 // FINITE-NEXT: br label %for.cond1, !llvm.loop [[LOOP5:!.*]]
106 // CHECK: for.end3:
107 // CHECK-NEXT: ret void
109 void F() {
110 for (; 1;)
112 for (; a == b;)
116 // CXX98-NOT: mustprogress
117 // CXX11: mustprogress
118 // FINITE-NOT: mustprogress
119 // CHECK-LABEL: @_Z2F2v(
120 // CHECK-NEXT: entry:
121 // CHECK-NEXT: br label %for.cond
122 // CHECK: for.cond:
123 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr @a, align 4
124 // CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr @b, align 4
125 // CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[TMP0]], [[TMP1]]
126 // CHECK-NEXT: br i1 [[CMP]], label %for.body, label %for.end
127 // CHECK: for.body:
128 // CXX98-NOT: br {{.*}} !llvm.loop
129 // CXX11-NEXT: br label %for.cond, !llvm.loop [[LOOP6:!.*]]
130 // FINITE-NEXT: br label %for.cond, !llvm.loop [[LOOP6:!.*]]
131 // CHECK: for.end:
132 // CHECK-NEXT: br label %for.cond1
133 // CHECK: for.cond1:
134 // CHECK-NEXT: br i1 true, label %for.body2, label %for.end3
135 // CHECK: for.body2:
136 // CXX98-NOT: br {{.*}}, !llvm.loop
137 // CXX11-NEXT: br label %for.cond1, !llvm.loop [[LOOP7:!.*]]
138 // FINITE-NEXT: br label %for.cond1, !llvm.loop [[LOOP7:!.*]]
139 // CHECK: for.end3:
140 // CHECK-NEXT: ret void
142 void F2() {
143 for (; a == b;)
145 for (; 1;)
149 // CXX98-NOT: mustprogress
150 // CXX11: mustprogress
151 // FINITE-NOT: mustprogress
152 // CHECK-LABEL: @_Z2w1v(
153 // CHECK-NEXT: entry:
154 // CHECK-NEXT: br label %while.body
155 // CHECK: while.body:
156 // CXX98-NOT: br {{.*}}, !llvm.loop
157 // CXX11-NEXT: br label %while.body, !llvm.loop [[LOOP8:!.*]]
158 // FINITE-NEXT: br label %while.body, !llvm.loop [[LOOP8:!.*]]
160 void w1() {
161 while (1)
165 // CXX98-NOT: mustprogress
166 // CXX11: mustprogress
167 // FINITE-NOT: mustprogress
168 // CHECK-LABEL: @_Z2w2v(
169 // CHECK-NEXT: entry:
170 // CHECK-NEXT: br label %while.cond
171 // CHECK: while.cond:
172 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr @a, align 4
173 // CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr @b, align 4
174 // CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[TMP0]], [[TMP1]]
175 // CHECK-NEXT: br i1 [[CMP]], label %while.body, label %while.end
176 // CHECK: while.body:
177 // CXX98-NOT: br {{.*}}, !llvm.loop
178 // CXX11-NEXT: br label %while.cond, !llvm.loop [[LOOP9:!.*]]
179 // FINITE-NEXT: br label %while.cond, !llvm.loop [[LOOP9:!.*]]
180 // CHECK: while.end:
181 // CHECK-NEXT: ret void
183 void w2() {
184 while (a == b)
188 // CXX98-NOT: mustprogress
189 // CXX11: mustprogress
190 // FINITE-NOT: mustprogress
191 // CHECK-LABEL: @_Z1Wv(
192 // CHECK-NEXT: entry:
193 // CHECK-NEXT: br label %while.cond
194 // CHECK: while.cond:
195 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr @a, align 4
196 // CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr @b, align 4
197 // CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[TMP0]], [[TMP1]]
198 // CHECK-NEXT: br i1 [[CMP]], label %while.body, label %while.end
199 // CHECK: while.body:
200 // CXX98-NOT: br {{.*}}, !llvm.loop
201 // CXX11-NEXT: br label %while.cond, !llvm.loop [[LOOP10:!.*]]
202 // FINITE-NEXT: br label %while.cond, !llvm.loop [[LOOP10:!.*]]
203 // CHECK: while.end:
204 // CHECK-NEXT: br label %while.body2
205 // CHECK: while.body2:
206 // CXX98-NOT: br {{.*}}, !llvm.loop
207 // CXX11-NEXT: br label %while.body2, !llvm.loop [[LOOP11:!.*]]
208 // FINITE-NEXT: br label %while.body2, !llvm.loop [[LOOP11:!.*]]
210 void W() {
211 while (a == b)
213 while (1)
217 // CXX98-NOT: mustprogress
218 // CXX11: mustprogress
219 // FINITE-NOT: mustprogress
220 // CHECK-LABEL: @_Z2W2v(
221 // CHECK-NEXT: entry:
222 // CHECK-NEXT: br label %while.body
223 // CHECK: while.body:
224 // CXX98-NOT: br {{.*}}, !llvm.loop
225 // CXX11-NEXT: br label %while.body, !llvm.loop [[LOOP12:!.*]]
226 // FINITE-NEXT: br label %while.body, !llvm.loop [[LOOP12:!.*]]
228 void W2() {
229 while (1)
231 while (a == b)
235 // CXX98-NOT: mustprogress
236 // CXX11: mustprogress
237 // FINITE-NOT: mustprogress
238 // CHECK-LABEL: @_Z2d1v(
239 // CHECK-NEXT: entry:
240 // CHECK-NEXT: br label %do.body
241 // CHECK: do.body:
242 // CHECK-NEXT: br label %do.cond
243 // CHECK: do.cond:
244 // CXX98-NOT: br {{.*}}, !llvm.loop
245 // CXX11-NEXT: br i1 true, label %do.body, label %do.end, !llvm.loop [[LOOP13:!.*]]
246 // FINITE-NEXT: br i1 true, label %do.body, label %do.end, !llvm.loop [[LOOP13:!.*]]
247 // CHECK: do.end:
248 // CHECK-NEXT: ret void
250 void d1() {
253 while (1);
256 // CXX98-NOT: mustprogress
257 // CXX11: mustprogress
258 // FINITE-NOT: mustprogress
259 // CHECK-LABEL: @_Z2d2v(
260 // CHECK-NEXT: entry:
261 // CHECK-NEXT: br label %do.body
262 // CHECK: do.body:
263 // CHECK-NEXT: br label %do.cond
264 // CHECK: do.cond:
265 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr @a, align 4
266 // CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr @b, align 4
267 // CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[TMP0]], [[TMP1]]
268 // CXX98-NOT: br {{.*}}, !llvm.loop
269 // CXX11-NEXT: br i1 [[CMP]], label %do.body, label %do.end, !llvm.loop [[LOOP14:!.*]]
270 // FINITE-NEXT: br i1 [[CMP]], label %do.body, label %do.end, !llvm.loop [[LOOP14:!.*]]
271 // CHECK: do.end:
272 // CHECK-NEXT: ret void
274 void d2() {
277 while (a == b);
280 // CXX98-NOT: mustprogress
281 // CXX11: mustprogress
282 // FINITE-NOT: mustprogress
283 // CHECK-LABEL: @_Z1Dv(
284 // CHECK-NEXT: entry:
285 // CHECK-NEXT: br label %do.body
286 // CHECK: do.body:
287 // CHECK-NEXT: br label %do.cond
288 // CHECK: do.cond:
289 // CXX98-NOT: br {{.*}}, !llvm.loop
290 // CXX11-NEXT: br i1 true, label %do.body, label %do.end, !llvm.loop [[LOOP15:!.*]]
291 // FINITE-NEXT: br i1 true, label %do.body, label %do.end, !llvm.loop [[LOOP15:!.*]]
292 // CHECK: do.end:
293 // CHECK-NEXT: br label %do.body1
294 // CHECK: do.body1:
295 // CHECK-NEXT: br label %do.cond2
296 // CHECK: do.cond2:
297 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr @a, align 4
298 // CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr @b, align 4
299 // CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[TMP0]], [[TMP1]]
300 // CXX98-NOT: br {{.*}}, !llvm.loop
301 // CXX11-NEXT: br i1 [[CMP]], label %do.body1, label %do.end3, !llvm.loop [[LOOP16:!.*]]
302 // FINITE-NEXT: br i1 [[CMP]], label %do.body1, label %do.end3, !llvm.loop [[LOOP16:!.*]]
303 // CHECK: do.end3:
304 // CHECK-NEXT: ret void
306 void D() {
309 while (1);
312 while (a == b);
315 // CXX98-NOT : mustprogress
316 // CXX11: mustprogress
317 // FINITE-NOT: mustprogress
318 // CHECK-LABEL: @_Z2D2v(
319 // CHECK-NEXT: entry:
320 // CHECK-NEXT: br label %do.body
321 // CHECK: do.body:
322 // CHECK-NEXT: br label %do.cond
323 // CHECK: do.cond:
324 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr @a, align 4
325 // CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr @b, align 4
326 // CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[TMP0]], [[TMP1]]
327 // CXX98-NOT: br {{.*}}, !llvm.loop
328 // CXX11-NEXT: br i1 [[CMP]], label %do.body, label %do.end, !llvm.loop [[LOOP17:!.*]]
329 // FINITE-NEXT: br i1 [[CMP]], label %do.body, label %do.end, !llvm.loop [[LOOP17:!.*]]
330 // CHECK: do.end:
331 // CHECK-NEXT: br label %do.body1
332 // CHECK: do.body1:
333 // CHECK-NEXT: br label %do.cond2
334 // CHECK: do.cond2:
335 // CXX98-NOT: br {{.*}}, !llvm.loop
336 // CXX11-NEXT: br i1 true, label %do.body1, label %do.end3, !llvm.loop [[LOOP18:!.*]]
337 // FINITE-NEXT: br i1 true, label %do.body1, label %do.end3, !llvm.loop [[LOOP18:!.*]]
338 // CHECK: do.end3:
339 // CHECK-NEXT: ret void
341 void D2() {
344 while (a == b);
347 while (1);
350 // CXX11: [[LOOP1]] = distinct !{[[LOOP1]], [[MP:!.*]]}
351 // CXX11: [[MP]] = !{!"llvm.loop.mustprogress"}
352 // CXX11: [[LOOP2]] = distinct !{[[LOOP2]], [[MP]]}
353 // CXX11: [[LOOP3]] = distinct !{[[LOOP3]], [[MP]]}
354 // CXX11: [[LOOP4]] = distinct !{[[LOOP4]], [[MP]]}
355 // CXX11: [[LOOP5]] = distinct !{[[LOOP5]], [[MP]]}
356 // CXX11: [[LOOP6]] = distinct !{[[LOOP6]], [[MP]]}
357 // CXX11: [[LOOP7]] = distinct !{[[LOOP7]], [[MP]]}
358 // CXX11: [[LOOP8]] = distinct !{[[LOOP8]], [[MP]]}
359 // CXX11: [[LOOP9]] = distinct !{[[LOOP9]], [[MP]]}
360 // CXX11: [[LOOP10]] = distinct !{[[LOOP10]], [[MP]]}
361 // CXX11: [[LOOP11]] = distinct !{[[LOOP11]], [[MP]]}
362 // CXX11: [[LOOP12]] = distinct !{[[LOOP12]], [[MP]]}
363 // CXX11: [[LOOP13]] = distinct !{[[LOOP13]], [[MP]]}
364 // CXX11: [[LOOP14]] = distinct !{[[LOOP14]], [[MP]]}
365 // CXX11: [[LOOP15]] = distinct !{[[LOOP15]], [[MP]]}
366 // CXX11: [[LOOP16]] = distinct !{[[LOOP16]], [[MP]]}
367 // CXX11: [[LOOP17]] = distinct !{[[LOOP17]], [[MP]]}
368 // CXX11: [[LOOP18]] = distinct !{[[LOOP18]], [[MP]]}