blob: 981fd983582cc065c7e5d3a1f1e6ce04cbf500df [file] [log] [blame]
Stephen Hines651f13c2014-04-23 16:59:28 -07001// Test instrumentation of general constructs in C.
2
3// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-general.c %s -o - -emit-llvm -fprofile-instr-generate | FileCheck -check-prefix=PGOGEN %s
Stephen Hines651f13c2014-04-23 16:59:28 -07004
Stephen Hines6bcf27b2014-05-29 04:14:42 -07005// RUN: llvm-profdata merge %S/Inputs/c-general.proftext -o %t.profdata
6// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-general.c %s -o - -emit-llvm -fprofile-instr-use=%t.profdata | FileCheck -check-prefix=PGOUSE %s
7
Stephen Hines176edba2014-12-01 14:53:08 -08008// Also check compatibility with older profiles.
9// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-general.c %s -o - -emit-llvm -fprofile-instr-use=%S/Inputs/c-general.profdata.v1 | FileCheck -check-prefix=PGOUSE %s
10
Stephen Hines6bcf27b2014-05-29 04:14:42 -070011// PGOGEN: @[[SLC:__llvm_profile_counters_simple_loops]] = hidden global [4 x i64] zeroinitializer
12// PGOGEN: @[[IFC:__llvm_profile_counters_conditionals]] = hidden global [11 x i64] zeroinitializer
13// PGOGEN: @[[EEC:__llvm_profile_counters_early_exits]] = hidden global [9 x i64] zeroinitializer
14// PGOGEN: @[[JMC:__llvm_profile_counters_jumps]] = hidden global [22 x i64] zeroinitializer
15// PGOGEN: @[[SWC:__llvm_profile_counters_switches]] = hidden global [19 x i64] zeroinitializer
16// PGOGEN: @[[BSC:__llvm_profile_counters_big_switch]] = hidden global [17 x i64] zeroinitializer
17// PGOGEN: @[[BOC:__llvm_profile_counters_boolean_operators]] = hidden global [8 x i64] zeroinitializer
18// PGOGEN: @[[BLC:__llvm_profile_counters_boolop_loops]] = hidden global [9 x i64] zeroinitializer
19// PGOGEN: @[[COC:__llvm_profile_counters_conditional_operator]] = hidden global [3 x i64] zeroinitializer
20// PGOGEN: @[[MAC:__llvm_profile_counters_main]] = hidden global [1 x i64] zeroinitializer
Stephen Hines0e2c34f2015-03-23 12:09:02 -070021// PGOGEN: @[[STC:"__llvm_profile_counters_c-general.c:static_func"]] = internal global [2 x i64] zeroinitializer
Stephen Hines651f13c2014-04-23 16:59:28 -070022
23// PGOGEN-LABEL: @simple_loops()
24// PGOUSE-LABEL: @simple_loops()
25// PGOGEN: store {{.*}} @[[SLC]], i64 0, i64 0
26void simple_loops() {
27 int i;
28 // PGOGEN: store {{.*}} @[[SLC]], i64 0, i64 1
29 // PGOUSE: br {{.*}} !prof ![[SL1:[0-9]+]]
30 for (i = 0; i < 100; ++i) {
31 }
32 // PGOGEN: store {{.*}} @[[SLC]], i64 0, i64 2
33 // PGOUSE: br {{.*}} !prof ![[SL2:[0-9]+]]
34 while (i > 0)
35 i--;
36 // PGOGEN: store {{.*}} @[[SLC]], i64 0, i64 3
37 // PGOUSE: br {{.*}} !prof ![[SL3:[0-9]+]]
38 do {} while (i++ < 75);
39
40 // PGOGEN-NOT: store {{.*}} @[[SLC]],
41 // PGOUSE-NOT: br {{.*}} !prof ![0-9]+
42}
43
44// PGOGEN-LABEL: @conditionals()
45// PGOUSE-LABEL: @conditionals()
46// PGOGEN: store {{.*}} @[[IFC]], i64 0, i64 0
47void conditionals() {
48 // PGOGEN: store {{.*}} @[[IFC]], i64 0, i64 1
49 // PGOUSE: br {{.*}} !prof ![[IF1:[0-9]+]]
50 for (int i = 0; i < 100; ++i) {
51 // PGOGEN: store {{.*}} @[[IFC]], i64 0, i64 2
52 // PGOUSE: br {{.*}} !prof ![[IF2:[0-9]+]]
53 if (i % 2) {
54 // PGOGEN: store {{.*}} @[[IFC]], i64 0, i64 3
55 // PGOUSE: br {{.*}} !prof ![[IF3:[0-9]+]]
56 if (i) {}
57 // PGOGEN: store {{.*}} @[[IFC]], i64 0, i64 4
58 // PGOUSE: br {{.*}} !prof ![[IF4:[0-9]+]]
59 } else if (i % 3) {
60 // PGOGEN: store {{.*}} @[[IFC]], i64 0, i64 5
61 // PGOUSE: br {{.*}} !prof ![[IF5:[0-9]+]]
62 if (i) {}
63 } else {
64 // PGOGEN: store {{.*}} @[[IFC]], i64 0, i64 6
65 // PGOUSE: br {{.*}} !prof ![[IF6:[0-9]+]]
66 if (i) {}
67 }
68
69 // PGOGEN: store {{.*}} @[[IFC]], i64 0, i64 8
70 // PGOGEN: store {{.*}} @[[IFC]], i64 0, i64 7
71 // PGOUSE: br {{.*}} !prof ![[IF7:[0-9]+]]
72 if (1 && i) {}
73 // PGOGEN: store {{.*}} @[[IFC]], i64 0, i64 10
74 // PGOGEN: store {{.*}} @[[IFC]], i64 0, i64 9
75 // PGOUSE: br {{.*}} !prof ![[IF8:[0-9]+]]
76 if (0 || i) {}
77 }
78
79 // PGOGEN-NOT: store {{.*}} @[[IFC]],
80 // PGOUSE-NOT: br {{.*}} !prof ![0-9]+
81}
82
83// PGOGEN-LABEL: @early_exits()
84// PGOUSE-LABEL: @early_exits()
85// PGOGEN: store {{.*}} @[[EEC]], i64 0, i64 0
86void early_exits() {
87 int i = 0;
88
89 // PGOGEN: store {{.*}} @[[EEC]], i64 0, i64 1
90 // PGOUSE: br {{.*}} !prof ![[EE1:[0-9]+]]
91 if (i) {}
92
93 // PGOGEN: store {{.*}} @[[EEC]], i64 0, i64 2
94 // PGOUSE: br {{.*}} !prof ![[EE2:[0-9]+]]
95 while (i < 100) {
96 i++;
97 // PGOGEN: store {{.*}} @[[EEC]], i64 0, i64 3
98 // PGOUSE: br {{.*}} !prof ![[EE3:[0-9]+]]
99 if (i > 50)
100 break;
101 // PGOGEN: store {{.*}} @[[EEC]], i64 0, i64 4
102 // PGOUSE: br {{.*}} !prof ![[EE4:[0-9]+]]
103 if (i % 2)
104 continue;
105 }
106
107 // PGOGEN: store {{.*}} @[[EEC]], i64 0, i64 5
108 // PGOUSE: br {{.*}} !prof ![[EE5:[0-9]+]]
109 if (i) {}
110
111 // PGOGEN: store {{.*}} @[[EEC]], i64 0, i64 6
112 do {
113 // PGOGEN: store {{.*}} @[[EEC]], i64 0, i64 7
114 // PGOUSE: br {{.*}} !prof ![[EE6:[0-9]+]]
115 if (i > 75)
116 return;
117 else
118 i++;
119 // PGOUSE: br {{.*}} !prof ![[EE7:[0-9]+]]
120 } while (i < 100);
121
122 // PGOGEN: store {{.*}} @[[EEC]], i64 0, i64 8
123 // Never reached -> no weights
124 if (i) {}
125
126 // PGOGEN-NOT: store {{.*}} @[[EEC]],
127 // PGOUSE-NOT: br {{.*}} !prof ![0-9]+
128}
129
130// PGOGEN-LABEL: @jumps()
131// PGOUSE-LABEL: @jumps()
132// PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 0
133void jumps() {
134 int i;
135
136 // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 1
137 // PGOUSE: br {{.*}} !prof ![[JM1:[0-9]+]]
138 for (i = 0; i < 2; ++i) {
139 goto outofloop;
140 // Never reached -> no weights
141 if (i) {}
142 }
143// PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 3
144outofloop:
145 // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 4
146 // PGOUSE: br {{.*}} !prof ![[JM2:[0-9]+]]
147 if (i) {}
148
149 goto loop1;
150
151 // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 5
152 // PGOUSE: br {{.*}} !prof ![[JM3:[0-9]+]]
153 while (i) {
154 // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 6
155 loop1:
156 // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 7
157 // PGOUSE: br {{.*}} !prof ![[JM4:[0-9]+]]
158 if (i) {}
159 }
160
161 goto loop2;
162// PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 8
163first:
164// PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 9
165second:
166// PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 10
167third:
168 i++;
169 // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 11
170 // PGOUSE: br {{.*}} !prof ![[JM5:[0-9]+]]
171 if (i < 3)
172 goto loop2;
173
174 // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 12
175 // PGOUSE: br {{.*}} !prof ![[JM6:[0-9]+]]
176 while (i < 3) {
177 // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 13
178 loop2:
179 // PGOUSE: switch {{.*}} [
180 // PGOUSE: ], !prof ![[JM7:[0-9]+]]
181 switch (i) {
182 // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 15
183 case 0:
184 goto first;
185 // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 16
186 case 1:
187 goto second;
188 // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 17
189 case 2:
190 goto third;
191 }
192 // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 14
193 }
194
195 // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 18
196 // PGOUSE: br {{.*}} !prof ![[JM8:[0-9]+]]
197 for (i = 0; i < 10; ++i) {
198 goto withinloop;
199 // never reached -> no weights
200 if (i) {}
201 // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 20
202 withinloop:
203 // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 21
204 // PGOUSE: br {{.*}} !prof ![[JM9:[0-9]+]]
205 if (i) {}
206 }
207
208 // PGOGEN-NOT: store {{.*}} @[[JMC]],
209 // PGOUSE-NOT: br {{.*}} !prof ![0-9]+
210}
211
212// PGOGEN-LABEL: @switches()
213// PGOUSE-LABEL: @switches()
214// PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 0
215void switches() {
216 static int weights[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5};
217
218 // No cases -> no weights
219 switch (weights[0]) {
220 // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 2
221 default:
222 break;
223 }
224 // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 1
225
226 // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 3
227 // PGOUSE: br {{.*}} !prof ![[SW1:[0-9]+]]
228 for (int i = 0, len = sizeof(weights) / sizeof(weights[0]); i < len; ++i) {
229 // PGOUSE: switch {{.*}} [
230 // PGOUSE: ], !prof ![[SW2:[0-9]+]]
231 switch (i[weights]) {
232 // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 5
233 case 1:
234 // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 6
235 // PGOUSE: br {{.*}} !prof ![[SW3:[0-9]+]]
236 if (i) {}
237 // fallthrough
238 // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 7
239 case 2:
240 // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 8
241 // PGOUSE: br {{.*}} !prof ![[SW4:[0-9]+]]
242 if (i) {}
243 break;
244 // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 9
245 case 3:
246 // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 10
247 // PGOUSE: br {{.*}} !prof ![[SW5:[0-9]+]]
248 if (i) {}
249 continue;
250 // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 11
251 case 4:
252 // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 12
253 // PGOUSE: br {{.*}} !prof ![[SW6:[0-9]+]]
254 if (i) {}
255 // PGOUSE: switch {{.*}} [
256 // PGOUSE: ], !prof ![[SW7:[0-9]+]]
257 switch (i) {
258 // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 14
259 case 6 ... 9:
260 // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 15
261 // PGOUSE: br {{.*}} !prof ![[SW8:[0-9]+]]
262 if (i) {}
263 continue;
264 }
265 // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 13
266
267 // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 16
268 default:
269 // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 17
270 // PGOUSE: br {{.*}} !prof ![[SW9:[0-9]+]]
271 if (i == len - 1)
272 return;
273 }
274 // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 4
275 }
276
277 // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 18
278 // Never reached -> no weights
279 if (weights[0]) {}
280
281 // PGOGEN-NOT: store {{.*}} @[[SWC]],
282 // PGOUSE-NOT: br {{.*}} !prof ![0-9]+
283}
284
285// PGOGEN-LABEL: @big_switch()
286// PGOUSE-LABEL: @big_switch()
287// PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 0
288void big_switch() {
289 // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 1
290 // PGOUSE: br {{.*}} !prof ![[BS1:[0-9]+]]
291 for (int i = 0; i < 32; ++i) {
292 // PGOUSE: switch {{.*}} [
293 // PGOUSE: ], !prof ![[BS2:[0-9]+]]
294 switch (1 << i) {
295 // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 3
296 case (1 << 0):
297 // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 4
298 // PGOUSE: br {{.*}} !prof ![[BS3:[0-9]+]]
299 if (i) {}
300 // fallthrough
301 // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 5
302 case (1 << 1):
303 // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 6
304 // PGOUSE: br {{.*}} !prof ![[BS4:[0-9]+]]
305 if (i) {}
306 break;
307 // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 7
308 case (1 << 2) ... (1 << 12):
309 // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 8
310 // PGOUSE: br {{.*}} !prof ![[BS5:[0-9]+]]
311 if (i) {}
312 break;
313 // The branch for the large case range above appears after the case body
314 // PGOUSE: br {{.*}} !prof ![[BS6:[0-9]+]]
315
316 // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 9
317 case (1 << 13):
318 // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 10
319 // PGOUSE: br {{.*}} !prof ![[BS7:[0-9]+]]
320 if (i) {}
321 break;
322 // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 11
323 case (1 << 14) ... (1 << 28):
324 // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 12
325 // PGOUSE: br {{.*}} !prof ![[BS8:[0-9]+]]
326 if (i) {}
327 break;
328 // The branch for the large case range above appears after the case body
329 // PGOUSE: br {{.*}} !prof ![[BS9:[0-9]+]]
330
331 // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 13
332 case (1 << 29) ... ((1 << 29) + 1):
333 // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 14
334 // PGOUSE: br {{.*}} !prof ![[BS10:[0-9]+]]
335 if (i) {}
336 break;
337 // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 15
338 default:
339 // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 16
340 // PGOUSE: br {{.*}} !prof ![[BS11:[0-9]+]]
341 if (i) {}
342 break;
343 }
344 // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 2
345 }
346
347 // PGOGEN-NOT: store {{.*}} @[[BSC]],
348 // PGOUSE-NOT: br {{.*}} !prof ![0-9]+
349 // PGOUSE: ret void
350}
351
352// PGOGEN-LABEL: @boolean_operators()
353// PGOUSE-LABEL: @boolean_operators()
354// PGOGEN: store {{.*}} @[[BOC]], i64 0, i64 0
355void boolean_operators() {
356 int v;
357 // PGOGEN: store {{.*}} @[[BOC]], i64 0, i64 1
358 // PGOUSE: br {{.*}} !prof ![[BO1:[0-9]+]]
359 for (int i = 0; i < 100; ++i) {
360 // PGOGEN: store {{.*}} @[[BOC]], i64 0, i64 2
361 // PGOUSE: br {{.*}} !prof ![[BO2:[0-9]+]]
362 v = i % 3 || i;
363
364 // PGOGEN: store {{.*}} @[[BOC]], i64 0, i64 3
365 // PGOUSE: br {{.*}} !prof ![[BO3:[0-9]+]]
366 v = i % 3 && i;
367
368 // PGOGEN: store {{.*}} @[[BOC]], i64 0, i64 5
369 // PGOGEN: store {{.*}} @[[BOC]], i64 0, i64 4
370 // PGOUSE: br {{.*}} !prof ![[BO4:[0-9]+]]
371 // PGOUSE: br {{.*}} !prof ![[BO5:[0-9]+]]
372 v = i % 3 || i % 2 || i;
373
374 // PGOGEN: store {{.*}} @[[BOC]], i64 0, i64 7
375 // PGOGEN: store {{.*}} @[[BOC]], i64 0, i64 6
376 // PGOUSE: br {{.*}} !prof ![[BO6:[0-9]+]]
377 // PGOUSE: br {{.*}} !prof ![[BO7:[0-9]+]]
378 v = i % 2 && i % 3 && i;
379 }
380
381 // PGOGEN-NOT: store {{.*}} @[[BOC]],
382 // PGOUSE-NOT: br {{.*}} !prof ![0-9]+
383}
384
385// PGOGEN-LABEL: @boolop_loops()
386// PGOUSE-LABEL: @boolop_loops()
387// PGOGEN: store {{.*}} @[[BLC]], i64 0, i64 0
388void boolop_loops() {
389 int i = 100;
390
391 // PGOGEN: store {{.*}} @[[BLC]], i64 0, i64 2
392 // PGOGEN: store {{.*}} @[[BLC]], i64 0, i64 1
393 // PGOUSE: br {{.*}} !prof ![[BL1:[0-9]+]]
394 // PGOUSE: br {{.*}} !prof ![[BL2:[0-9]+]]
395 while (i && i > 50)
396 i--;
397
398 // PGOGEN: store {{.*}} @[[BLC]], i64 0, i64 4
399 // PGOGEN: store {{.*}} @[[BLC]], i64 0, i64 3
400 // PGOUSE: br {{.*}} !prof ![[BL3:[0-9]+]]
401 // PGOUSE: br {{.*}} !prof ![[BL4:[0-9]+]]
402 while ((i % 2) || (i > 0))
403 i--;
404
405 // PGOGEN: store {{.*}} @[[BLC]], i64 0, i64 6
406 // PGOGEN: store {{.*}} @[[BLC]], i64 0, i64 5
407 // PGOUSE: br {{.*}} !prof ![[BL5:[0-9]+]]
408 // PGOUSE: br {{.*}} !prof ![[BL6:[0-9]+]]
409 for (i = 100; i && i > 50; --i);
410
411 // PGOGEN: store {{.*}} @[[BLC]], i64 0, i64 8
412 // PGOGEN: store {{.*}} @[[BLC]], i64 0, i64 7
413 // PGOUSE: br {{.*}} !prof ![[BL7:[0-9]+]]
414 // PGOUSE: br {{.*}} !prof ![[BL8:[0-9]+]]
415 for (; (i % 2) || (i > 0); --i);
416
417 // PGOGEN-NOT: store {{.*}} @[[BLC]],
418 // PGOUSE-NOT: br {{.*}} !prof ![0-9]+
419}
420
Stephen Hines6bcf27b2014-05-29 04:14:42 -0700421// PGOGEN-LABEL: @conditional_operator()
422// PGOUSE-LABEL: @conditional_operator()
423// PGOGEN: store {{.*}} @[[COC]], i64 0, i64 0
424void conditional_operator() {
425 int i = 100;
426
427 // PGOGEN: store {{.*}} @[[COC]], i64 0, i64 1
428 // PGOUSE: br {{.*}} !prof ![[CO1:[0-9]+]]
429 int j = i < 50 ? i : 1;
430
431 // PGOGEN: store {{.*}} @[[COC]], i64 0, i64 2
432 // PGOUSE: br {{.*}} !prof ![[CO2:[0-9]+]]
433 int k = i ?: 0;
434
435 // PGOGEN-NOT: store {{.*}} @[[COC]],
436 // PGOUSE-NOT: br {{.*}} !prof ![0-9]+
437}
438
Stephen Hines651f13c2014-04-23 16:59:28 -0700439void do_fallthrough() {
440 for (int i = 0; i < 10; ++i) {
441 int j = 0;
442 do {
443 // The number of exits out of this do-loop via the break statement
444 // exceeds the counter value for the loop (which does not include the
445 // fallthrough count). Make sure that does not violate any assertions.
446 if (i < 8) break;
447 j++;
448 } while (j < 2);
449 }
450}
451
452// PGOGEN-LABEL: @static_func()
453// PGOUSE-LABEL: @static_func()
454// PGOGEN: store {{.*}} @[[STC]], i64 0, i64 0
455static void static_func() {
456 // PGOGEN: store {{.*}} @[[STC]], i64 0, i64 1
457 // PGOUSE: br {{.*}} !prof ![[ST1:[0-9]+]]
458 for (int i = 0; i < 10; ++i) {
459 }
460}
461
Stephen Hines0e2c34f2015-03-23 12:09:02 -0700462// PGOUSE-DAG: ![[SL1]] = !{!"branch_weights", i32 101, i32 2}
463// PGOUSE-DAG: ![[SL2]] = !{!"branch_weights", i32 101, i32 2}
464// PGOUSE-DAG: ![[SL3]] = !{!"branch_weights", i32 76, i32 2}
Stephen Hines651f13c2014-04-23 16:59:28 -0700465
Stephen Hines0e2c34f2015-03-23 12:09:02 -0700466// PGOUSE-DAG: ![[EE1]] = !{!"branch_weights", i32 1, i32 2}
467// PGOUSE-DAG: ![[EE2]] = !{!"branch_weights", i32 52, i32 1}
468// PGOUSE-DAG: ![[EE3]] = !{!"branch_weights", i32 2, i32 51}
469// PGOUSE-DAG: ![[EE4]] = !{!"branch_weights", i32 26, i32 26}
470// PGOUSE-DAG: ![[EE5]] = !{!"branch_weights", i32 2, i32 1}
471// PGOUSE-DAG: ![[EE6]] = !{!"branch_weights", i32 2, i32 26}
472// PGOUSE-DAG: ![[EE7]] = !{!"branch_weights", i32 26, i32 1}
Stephen Hines651f13c2014-04-23 16:59:28 -0700473
Stephen Hines0e2c34f2015-03-23 12:09:02 -0700474// PGOUSE-DAG: ![[IF1]] = !{!"branch_weights", i32 101, i32 2}
475// PGOUSE-DAG: ![[IF2]] = !{!"branch_weights", i32 51, i32 51}
476// PGOUSE-DAG: ![[IF3]] = !{!"branch_weights", i32 51, i32 1}
477// PGOUSE-DAG: ![[IF4]] = !{!"branch_weights", i32 34, i32 18}
478// PGOUSE-DAG: ![[IF5]] = !{!"branch_weights", i32 34, i32 1}
479// PGOUSE-DAG: ![[IF6]] = !{!"branch_weights", i32 17, i32 2}
480// PGOUSE-DAG: ![[IF7]] = !{!"branch_weights", i32 100, i32 2}
481// PGOUSE-DAG: ![[IF8]] = !{!"branch_weights", i32 100, i32 2}
Stephen Hines651f13c2014-04-23 16:59:28 -0700482
Stephen Hines0e2c34f2015-03-23 12:09:02 -0700483// PGOUSE-DAG: ![[JM1]] = !{!"branch_weights", i32 2, i32 1}
484// PGOUSE-DAG: ![[JM2]] = !{!"branch_weights", i32 1, i32 2}
485// PGOUSE-DAG: ![[JM3]] = !{!"branch_weights", i32 1, i32 2}
486// PGOUSE-DAG: ![[JM4]] = !{!"branch_weights", i32 1, i32 2}
487// PGOUSE-DAG: ![[JM5]] = !{!"branch_weights", i32 3, i32 2}
488// PGOUSE-DAG: ![[JM6]] = !{!"branch_weights", i32 1, i32 2}
489// PGOUSE-DAG: ![[JM7]] = !{!"branch_weights", i32 1, i32 2, i32 2, i32 2}
490// PGOUSE-DAG: ![[JM8]] = !{!"branch_weights", i32 11, i32 2}
491// PGOUSE-DAG: ![[JM9]] = !{!"branch_weights", i32 10, i32 2}
Stephen Hines651f13c2014-04-23 16:59:28 -0700492
Stephen Hines0e2c34f2015-03-23 12:09:02 -0700493// PGOUSE-DAG: ![[SW1]] = !{!"branch_weights", i32 16, i32 1}
494// PGOUSE-DAG: ![[SW2]] = !{!"branch_weights", i32 6, i32 2, i32 3, i32 4, i32 5}
495// PGOUSE-DAG: ![[SW3]] = !{!"branch_weights", i32 1, i32 2}
496// PGOUSE-DAG: ![[SW4]] = !{!"branch_weights", i32 3, i32 2}
497// PGOUSE-DAG: ![[SW5]] = !{!"branch_weights", i32 4, i32 1}
498// PGOUSE-DAG: ![[SW6]] = !{!"branch_weights", i32 5, i32 1}
499// PGOUSE-DAG: ![[SW7]] = !{!"branch_weights", i32 1, i32 2, i32 2, i32 2, i32 2}
500// PGOUSE-DAG: ![[SW8]] = !{!"branch_weights", i32 5, i32 1}
501// PGOUSE-DAG: ![[SW9]] = !{!"branch_weights", i32 2, i32 5}
Stephen Hines651f13c2014-04-23 16:59:28 -0700502
Stephen Hines0e2c34f2015-03-23 12:09:02 -0700503// PGOUSE-DAG: ![[BS1]] = !{!"branch_weights", i32 33, i32 2}
504// PGOUSE-DAG: ![[BS2]] = !{!"branch_weights", i32 29, i32 2, i32 2, i32 2, i32 2, i32 1}
505// PGOUSE-DAG: ![[BS3]] = !{!"branch_weights", i32 1, i32 2}
506// PGOUSE-DAG: ![[BS4]] = !{!"branch_weights", i32 2, i32 2}
507// PGOUSE-DAG: ![[BS5]] = !{!"branch_weights", i32 12, i32 1}
508// PGOUSE-DAG: ![[BS6]] = !{!"branch_weights", i32 12, i32 3}
509// PGOUSE-DAG: ![[BS7]] = !{!"branch_weights", i32 2, i32 1}
510// PGOUSE-DAG: ![[BS8]] = !{!"branch_weights", i32 16, i32 1}
511// PGOUSE-DAG: ![[BS9]] = !{!"branch_weights", i32 16, i32 14}
512// PGOUSE-DAG: ![[BS10]] = !{!"branch_weights", i32 2, i32 1}
513// PGOUSE-DAG: ![[BS11]] = !{!"branch_weights", i32 3, i32 1}
Stephen Hines651f13c2014-04-23 16:59:28 -0700514
Stephen Hines0e2c34f2015-03-23 12:09:02 -0700515// PGOUSE-DAG: ![[BO1]] = !{!"branch_weights", i32 101, i32 2}
516// PGOUSE-DAG: ![[BO2]] = !{!"branch_weights", i32 67, i32 35}
517// PGOUSE-DAG: ![[BO3]] = !{!"branch_weights", i32 67, i32 35}
518// PGOUSE-DAG: ![[BO4]] = !{!"branch_weights", i32 67, i32 35}
519// PGOUSE-DAG: ![[BO5]] = !{!"branch_weights", i32 18, i32 18}
520// PGOUSE-DAG: ![[BO6]] = !{!"branch_weights", i32 51, i32 51}
521// PGOUSE-DAG: ![[BO7]] = !{!"branch_weights", i32 34, i32 18}
522// PGOUSE-DAG: ![[BL1]] = !{!"branch_weights", i32 52, i32 1}
523// PGOUSE-DAG: ![[BL2]] = !{!"branch_weights", i32 51, i32 2}
524// PGOUSE-DAG: ![[BL3]] = !{!"branch_weights", i32 26, i32 27}
525// PGOUSE-DAG: ![[BL4]] = !{!"branch_weights", i32 51, i32 2}
526// PGOUSE-DAG: ![[BL5]] = !{!"branch_weights", i32 52, i32 1}
527// PGOUSE-DAG: ![[BL6]] = !{!"branch_weights", i32 51, i32 2}
528// PGOUSE-DAG: ![[BL7]] = !{!"branch_weights", i32 26, i32 27}
529// PGOUSE-DAG: ![[BL8]] = !{!"branch_weights", i32 51, i32 2}
530// PGOUSE-DAG: ![[CO1]] = !{!"branch_weights", i32 1, i32 2}
531// PGOUSE-DAG: ![[CO2]] = !{!"branch_weights", i32 2, i32 1}
532// PGOUSE-DAG: ![[ST1]] = !{!"branch_weights", i32 11, i32 2}
Stephen Hines651f13c2014-04-23 16:59:28 -0700533
534int main(int argc, const char *argv[]) {
535 simple_loops();
536 conditionals();
537 early_exits();
538 jumps();
539 switches();
540 big_switch();
541 boolean_operators();
542 boolop_loops();
Stephen Hines6bcf27b2014-05-29 04:14:42 -0700543 conditional_operator();
Stephen Hines651f13c2014-04-23 16:59:28 -0700544 do_fallthrough();
545 static_func();
546 return 0;
547}