1 // RUN: %clang_pgogen -o %t -O3 %s
2 // RUN: rm -rf %t.profdir
3 // RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t
4 // RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t
5 // RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t
6 // RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t 1
7 // RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t 1
8 // RUN: llvm-profdata show -counts -function=main -ic-targets -memop-sizes %t.profdir/default_*.profraw | FileCheck %s
9
10 #include <string.h>
11
12 void (*f0)();
13 void (*f1)();
14 void (*f2)();
15
16 char dst[200];
17 char src[200];
18 volatile int n;
19
foo()20 __attribute__((noinline)) void foo() {}
21
bar()22 __attribute__((noinline)) void bar() {
23 f0 = foo;
24 f1 = foo;
25 f2 = foo;
26 n = 4;
27 }
main(int argc,char * argv[])28 int main(int argc, char *argv[]) {
29 int i;
30 bar();
31 if (argc == 1) {
32 f0();
33 for (i = 0; i < 9; i++)
34 f1();
35 for (i = 0; i < 99; i++)
36 f2();
37 } else {
38 memcpy((void *)dst, (void *)src, n);
39 for (i = 0; i < 6; i++)
40 memcpy((void *)(dst + 2), (void *)src, n + 1);
41 for (i = 0; i < 66; i++)
42 memcpy((void *)(dst + 9), (void *)src, n + 2);
43 }
44 }
45
46 // CHECK: Counters:
47 // CHECK: main:
48 // CHECK: Hash: 0x0a9bd81e87ab6e87
49 // CHECK: Counters: 6
50 // CHECK: Indirect Call Site Count: 3
51 // CHECK: Number of Memory Intrinsics Calls: 3
52 // CHECK: Block counts: [27, 297, 12, 132, 3, 2]
53 // CHECK: Indirect Target Results:
54 // CHECK: [ 0, foo, 3 ]
55 // CHECK: [ 1, foo, 27 ]
56 // CHECK: [ 2, foo, 297 ]
57 // CHECK: Memory Intrinsic Size Results:
58 // CHECK: [ 0, 4, 2 ]
59 // CHECK: [ 1, 5, 12 ]
60 // CHECK: [ 2, 6, 132 ]
61 // CHECK: Instrumentation level: IR
62 // CHECK: Functions shown: 1
63 // CHECK: Total functions: 3
64 // CHECK: Maximum function count: 327
65 // CHECK: Maximum internal block count: 297
66 // CHECK: Statistics for indirect call sites profile:
67 // CHECK: Total number of sites: 3
68 // CHECK: Total number of sites with values: 3
69 // CHECK: Total number of profiled values: 3
70 // CHECK: Value sites histogram:
71 // CHECK: NumTargets, SiteCount
72 // CHECK: 1, 3
73 // CHECK: Statistics for memory intrinsic calls sizes profile:
74 // CHECK: Total number of sites: 3
75 // CHECK: Total number of sites with values: 3
76 // CHECK: Total number of profiled values: 3
77 // CHECK: Value sites histogram:
78 // CHECK: NumTargets, SiteCount
79 // CHECK: 1, 3
80