1 // RUN: %clang_cc1 -std=c89 -triple=x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=C99 %s
2 // RUN: %clang_cc1 -std=c99 -triple=x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=C99 %s
3 // RUN: %clang_cc1 -std=c11 -triple=x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=C11 %s
4 // RUN: %clang_cc1 -std=c18 -triple=x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=C11 %s
5 // RUN: %clang_cc1 -std=c2x -triple=x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=C11 %s
7 // Check -ffinite-loops option in combination with various standard versions.
8 // RUN: %clang_cc1 -std=c89 -ffinite-loops -triple=x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=FINITE %s
9 // RUN: %clang_cc1 -std=c99 -ffinite-loops -triple=x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=FINITE %s
10 // RUN: %clang_cc1 -std=c11 -ffinite-loops -triple=x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=FINITE %s
11 // RUN: %clang_cc1 -std=c18 -ffinite-loops -triple=x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=FINITE %s
12 // RUN: %clang_cc1 -std=c2x -ffinite-loops -triple=x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=FINITE %s
14 // Check -fno-finite-loops option in combination with various standard versions.
15 // RUN: %clang_cc1 -std=c89 -fno-finite-loops -triple=x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=C99 %s
16 // RUN: %clang_cc1 -std=c99 -fno-finite-loops -triple=x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=C99 %s
17 // RUN: %clang_cc1 -std=c11 -fno-finite-loops -triple=x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=C99 %s
18 // RUN: %clang_cc1 -std=c18 -fno-finite-loops -triple=x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=C99 %s
19 // RUN: %clang_cc1 -std=c2x -fno-finite-loops -triple=x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=C99 %s
26 // CHECK-NOT: mustprogress
29 // CHECK-NEXT: br label %for.cond
31 // C99-NOT: br {{.*}}!llvm.loop
32 // C11-NOT: br {{.*}}!llvm.loop
33 // FINITE-NOR: br {{.*}}!llvm.loop
39 // CHECK-NOT: mustprogress
42 // CHECK-NEXT: br label %for.cond
44 // CHECK-NEXT: br i1 true, label %for.body, label %for.end
46 // C99-NOT: br {{.*}}, !llvm.loop
47 // C11-NOT: br {{.*}}, !llvm.loop
48 // FINITE-NOT: br {{.*}}, !llvm.loop
50 // CHECK-NEXT: ret void
57 // CHECK-NOT: mustprogress
60 // CHECK-NEXT: br label %for.cond
62 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr @a, align 4
63 // CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr @b, align 4
64 // CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[TMP0]], [[TMP1]]
65 // CHECK-NEXT: br i1 [[CMP]], label %for.body, label %for.end
67 // C99-NOT: br {{.*}} !llvm.loop
68 // C11: br label %for.cond, !llvm.loop [[LOOP1:!.*]]
69 // FINITE: br label %for.cond, !llvm.loop [[LOOP1:!.*]]
71 // CHECK-NEXT: ret void
78 // CHECK-NOT: mustprogress
81 // CHECK-NEXT: br label %for.cond
83 // CHECK-NEXT: br i1 true, label %for.body, label %for.end
85 // C99-NOT: br {{.*}}, !llvm.loop
86 // C11-NOT: br {{.*}}, !llvm.loop
87 // FINITE-NOT: br {{.*}}, !llvm.loop
89 // CHECK-NEXT: br label %for.cond1
91 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr @a, align 4
92 // CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr @b, align 4
93 // CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[TMP0]], [[TMP1]]
94 // CHECK-NEXT: br i1 [[CMP]], label %for.body2, label %for.end3
96 // C99-NOT: br {{.*}}, !llvm.loop
97 // C11: br label %for.cond1, !llvm.loop [[LOOP2:!.*]]
98 // FINITE: br label %for.cond1, !llvm.loop [[LOOP2:!.*]]
100 // CHECK-NEXT: ret void
109 // CHECK-NOT: mustprogress
111 // CHECK-NEXT: entry:
112 // CHECK-NEXT: br label %while.body
113 // CHECK: while.body:
114 // C99-NOT: br {{.*}}, !llvm.loop
115 // C11-NOT: br {{.*}}, !llvm.loop
116 // FINITE-NOT: br {{.*}}, !llvm.loop
123 // CHECK-NOT: mustprogress
125 // CHECK-NEXT: entry:
126 // CHECK-NEXT: br label %while.cond
127 // CHECK: while.cond:
128 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr @a, align 4
129 // CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr @b, align 4
130 // CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[TMP0]], [[TMP1]]
131 // CHECK-NEXT: br i1 [[CMP]], label %while.body, label %while.end
132 // CHECK: while.body:
133 // C99-NOT: br {{.*}}, !llvm.loop
134 // C11: br label %while.cond, !llvm.loop [[LOOP3:!.*]]
135 // FINITE: br label %while.cond, !llvm.loop [[LOOP3:!.*]]
137 // CHECK-NEXT: ret void
144 // CHECK-NOT: mustprogress
146 // CHECK-NEXT: entry:
147 // CHECK-NEXT: br label [[WHILE_COND:%.*]]
148 // CHECK: while.cond:
149 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr @a, align 4
150 // CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr @b, align 4
151 // CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[TMP0]], [[TMP1]]
152 // CHECK-NEXT: br i1 [[CMP]], label %while.body, label %while.end
153 // CHECK: while.body:
154 // C99-NOT: br {{.*}} !llvm.loop
155 // C11-NEXT: br label %while.cond, !llvm.loop [[LOOP4:!.*]]
156 // FINITE-NEXT: br label %while.cond, !llvm.loop [[LOOP4:!.*]]
158 // CHECK-NEXT: br label %while.body2
159 // CHECK: while.body2:
160 // C99-NOT: br {{.*}} !llvm.loop
161 // C11-NOT: br {{.*}} !llvm.loop
162 // FINITE-NOT: br {{.*}} !llvm.loop
171 // CHECK-NOT: mustprogress
173 // CHECK-NEXT: entry:
174 // CHECK-NEXT: br label %do.body
176 // CHECK-NEXT: br label %do.cond
178 // C99-NOT: br {{.*}}, !llvm.loop
179 // C11-NOT: br {{.*}}, !llvm.loop
180 // FINITE-NOT: br {{.*}}, !llvm.loop
182 // CHECK-NEXT: ret void
189 // CHECK-NOT: mustprogress
191 // CHECK-NEXT: entry:
192 // CHECK-NEXT: br label %do.body
194 // CHECK-NEXT: br label %do.cond
196 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr @a, align 4
197 // CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr @b, align 4
198 // CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[TMP0]], [[TMP1]]
199 // C99-NOT: br {{.*}}, !llvm.loop
200 // C11: br i1 [[CMP]], label %do.body, label %do.end, !llvm.loop [[LOOP5:!.*]]
201 // FINITE: br i1 [[CMP]], label %do.body, label %do.end, !llvm.loop [[LOOP5:!.*]]
203 // CHECK-NEXT: ret void
210 // CHECK-NOT: mustprogress
212 // CHECK-NEXT: entry:
213 // CHECK-NEXT: br label %do.body
215 // CHECK-NEXT: br label %do.cond
217 // CHECK-NOT: br label {{.*}}, !llvm.loop
219 // CHECK-NEXT: br label %do.body1
221 // CHECK-NEXT: br label %do.cond2
223 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr @a, align 4
224 // CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr @b, align 4
225 // CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[TMP0]], [[TMP1]]
226 // C99-NOT: br {{.*}}, !llvm.loop
227 // C11: br i1 [[CMP]], label %do.body1, label %do.end3, !llvm.loop [[LOOP6:!.*]]
228 // FINITE: br i1 [[CMP]], label %do.body1, label %do.end3, !llvm.loop [[LOOP6:!.*]]
230 // CHECK-NEXT: ret void
239 // C11: [[LOOP1]] = distinct !{[[LOOP1]], [[MP:!.*]]}
240 // C11: [[MP]] = !{!"llvm.loop.mustprogress"}
241 // C11: [[LOOP2]] = distinct !{[[LOOP2]], [[MP]]}
242 // C11: [[LOOP3]] = distinct !{[[LOOP3]], [[MP]]}
243 // C11: [[LOOP4]] = distinct !{[[LOOP4]], [[MP]]}
244 // C11: [[LOOP5]] = distinct !{[[LOOP5]], [[MP]]}
245 // C11: [[LOOP6]] = distinct !{[[LOOP6]], [[MP]]}