xref: /llvm-project/llvm/test/tools/llvm-profgen/update-samples.test (revision acfd0a345619c9293ac8fa5f690fa78b27a10814)
1; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/noprobe.perfscript --binary=%S/Inputs/noprobe.perfbin --output=%t1
2; RUN: FileCheck %s --input-file %t1 --check-prefix=CALLSITE
3; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/noprobe.perfscript --binary=%S/Inputs/noprobe.perfbin --output=%t2 --update-total-samples=1
4; RUN: FileCheck %s --input-file %t2 --check-prefix=TOTAL
5
6
7;CALLSITE: foo:1241:0
8;CALLSITE:  0: 0
9;CALLSITE:  1: 0
10;CALLSITE:  2: 19
11;CALLSITE:  3: 21 bar:21
12;CALLSITE:  4: 0
13;CALLSITE:  5: 0
14
15;TOTAL: foo:40:0
16;TOTAL:  0: 0
17;TOTAL:  1: 0
18;TOTAL:  2: 19
19;TOTAL:  3: 21 bar:21
20;TOTAL:  4: 0
21;TOTAL:  5: 0
22
23
24; original code:
25; clang -O3 -g -fdebug-info-for-profiling test.c -fno-inline -o a.out
26#include <stdio.h>
27
28int bar(int x, int y) {
29  if (x % 3) {
30    return x - y;
31  }
32  return x + y;
33}
34
35void foo() {
36  int s, i = 0;
37  while (i++ < 4000 * 4000)
38    if (i % 91) s = bar(i, s); else s += 30;
39  printf("sum is %d\n", s);
40}
41
42int main() {
43  foo();
44  return 0;
45}
46