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