• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llvm-profgen --perfscript=%S/Inputs/noinline-cs-noprobe.perfscript --binary=%S/Inputs/noinline-cs-noprobe.perfbin --output=%t --show-unwinder-output | FileCheck %s --check-prefix=CHECK-UNWINDER
2; RUN: FileCheck %s --input-file %t
3
4; CHECK:[main:1 @ foo:3 @ bar]:12:3
5; CHECK: 0: 3
6; CHECK: 1: 3
7; CHECK: 2: 2
8; CHECK: 4: 1
9; CHECK: 5: 3
10; CHECK:[main:1 @ foo]:9:0
11; CHECK: 2: 3
12; CHECK: 3: 3 bar:3
13
14; CHECK-UNWINDER: Binary(noinline-cs-noprobe.perfbin)'s Range Counter:
15; CHECK-UNWINDER: main:1 @ foo
16; CHECK-UNWINDER:   (5ff, 62f): 3
17; CHECK-UNWINDER:   (634, 637): 3
18; CHECK-UNWINDER:   (645, 645): 3
19; CHECK-UNWINDER: main:1 @ foo:3 @ bar
20; CHECK-UNWINDER:   (5b0, 5c8): 1
21; CHECK-UNWINDER:   (5b0, 5d7): 2
22; CHECK-UNWINDER:   (5dc, 5e9): 1
23; CHECK-UNWINDER:   (5e5, 5e9): 2
24
25; CHECK-UNWINDER: Binary(noinline-cs-noprobe.perfbin)'s Branch Counter:
26; CHECK-UNWINDER: main:1 @ foo
27; CHECK-UNWINDER:   (62f, 5b0): 3
28; CHECK-UNWINDER:   (637, 645): 3
29; CHECK-UNWINDER:   (645, 5ff): 3
30; CHECK-UNWINDER: main:1 @ foo:3 @ bar
31; CHECK-UNWINDER:   (5c8, 5dc): 2
32; CHECK-UNWINDER:   (5d7, 5e5): 2
33; CHECK-UNWINDER:   (5e9, 634): 3
34
35
36
37
38
39; original code:
40; clang -O0 -g test.c -o a.out
41#include <stdio.h>
42
43int bar(int x, int y) {
44  if (x % 3) {
45    return x - y;
46  }
47  return x + y;
48}
49
50void foo() {
51  int s, i = 0;
52  while (i++ < 4000 * 4000)
53    if (i % 91) s = bar(i, s); else s += 30;
54  printf("sum is %d\n", s);
55}
56
57int main() {
58  foo();
59  return 0;
60}
61