1; RUN: llvm-profgen --perfscript=%s  --binary=%S/Inputs/inline-cs-pseudoprobe.perfbin --output=%t --show-pseudo-probe --show-disassembly-only | FileCheck %s
2
3PERF_RECORD_MMAP2 2854748/2854748: [0x400000(0x1000) @ 0 00:1d 123291722 526021]: r-xp /home/inline-cs-pseudoprobe.perfbin
4
5; CHECK: Pseudo Probe Desc:
6; CHECK: GUID: 6699318081062747564 Name: foo
7; CHECK: Hash: 138950591924
8; CHECK: GUID: 15822663052811949562 Name: main
9; CHECK: Hash: 4294967295
10; CHECK: GUID: 16434608426314478903 Name: bar
11; CHECK: Hash: 72617220756
12
13
14
15; CHECK:      <bar>:
16
17; CHECK:       [Probe]: FUNC: bar Index: 1  Type: Block
18; CHECK-NEXT:      754: imull $2863311531, %edi, %eax
19
20; CHECK:       [Probe]: FUNC: bar Index: 2  Type: Block  Dangling
21; CHECK-NEXT:  [Probe]: FUNC: bar Index: 3  Type: Block  Dangling
22; CHECK-NEXT:      768: cmovbl  %esi, %ecx
23
24; CHECK:       [Probe]: FUNC: bar Index: 4  Type: Block
25; CHECK-NEXT:      76e: popq  %rbp
26
27
28; CHECK:      <foo>:
29; CHECK:       [Probe]: FUNC: foo Index: 1  Type: Block
30; CHECK-NEXT:  [Probe]: FUNC: foo Index: 2  Type: Block
31; CHECK-NEXT:      770: movl  $1, %ecx
32
33; CHECK:       [Probe]: FUNC: foo Index: 5  Type: Block
34; CHECK-NEXT:      780: addl  $30, %esi
35; CHECK:       [Probe]: FUNC: foo Index: 6  Type: Block
36; CHECK-NEXT:  [Probe]: FUNC: foo Index: 2  Type: Block
37; CHECK-NEXT:      783: addl  $1, %ecx
38
39; CHECK:       [Probe]: FUNC: foo Index: 3  Type: Block
40; CHECK-NEXT:      7a9: cmpl  %eax, %ecx
41
42; CHECK:       [Probe]: FUNC: foo Index: 4  Type: Block
43; CHECK-NEXT:  [Probe]: FUNC: bar Index: 1  Type: Block  Inlined: @ foo:8
44; CHECK-NEXT:      7bf: addl  %ecx, %edx
45
46; CHECK:       [Probe]: FUNC: bar Index: 2  Type: Block  Dangling  Inlined: @ foo:8
47; CHECK-NEXT:  [Probe]: FUNC: bar Index: 3  Type: Block  Dangling  Inlined: @ foo:8
48; CHECK-NEXT:      7c8: cmovel  %esi, %eax
49
50; CHECK:       [Probe]: FUNC: bar Index: 4  Type: Block  Inlined: @ foo:8
51; CHECK-NEXT:      7cd: movl  %eax, %esi
52; CHECK:       [Probe]: FUNC: foo Index: 6  Type: Block
53; CHECK-NEXT:  [Probe]: FUNC: foo Index: 2  Type: Block
54
55; CHECK:       [Probe]: FUNC: foo Index: 7  Type: Block
56; CHECK-NEXT:      7de: movl  $2098432, %edi
57
58; CHECK:       [Probe]: FUNC: foo Index: 9  Type: DirectCall
59; CHECK-NEXT:      7e5: callq 0x930
60
61
62; CHECK:      <main>:
63; CHECK:       [Probe]: FUNC: main Index: 1  Type: Block
64; CHECK-NEXT:  [Probe]: FUNC: foo Index: 1  Type: Block  Inlined: @ main:2
65; CHECK-NEXT:  [Probe]: FUNC: foo Index: 2  Type: Block  Inlined: @ main:2
66; CHECK-NEXT:      7f0: movl  $1, %ecx
67
68; CHECK:       [Probe]: FUNC: foo Index: 5  Type: Block  Inlined: @ main:2
69; CHECK-NEXT:      800: addl  $30, %esi
70; CHECK:       [Probe]: FUNC: foo Index: 6  Type: Block  Inlined: @ main:2
71; CHECK-NEXT:  [Probe]: FUNC: foo Index: 2  Type: Block  Inlined: @ main:2
72; CHECK-NEXT:      803: addl  $1, %ecx
73
74; CHECK:       [Probe]: FUNC: foo Index: 3  Type: Block  Inlined: @ main:2
75; CHECK-NEXT:      829: cmpl  %eax, %ecx
76
77; CHECK:       [Probe]: FUNC: foo Index: 4  Type: Block  Inlined: @ main:2
78; CHECK-NEXT:  [Probe]: FUNC: bar Index: 1  Type: Block  Inlined: @ main:2 @ foo:8
79; CHECK-NEXT:      83f: addl  %ecx, %edx
80
81; CHECK:       [Probe]: FUNC: bar Index: 2  Type: Block  Dangling  Inlined: @ main:2 @ foo:8
82; CHECK-NEXT:  [Probe]: FUNC: bar Index: 3  Type: Block  Dangling  Inlined: @ main:2 @ foo:8
83; CHECK-NEXT:      848: cmovel  %esi, %eax
84
85; CHECK:       [Probe]: FUNC: bar Index: 4  Type: Block  Inlined: @ main:2 @ foo:8
86; CHECK-NEXT:      84d: movl  %eax, %esi
87; CHECK:       [Probe]: FUNC: foo Index: 6  Type: Block  Inlined: @ main:2
88; CHECK-NEXT:  [Probe]: FUNC: foo Index: 2  Type: Block  Inlined: @ main:2
89; CHECK-NEXT:      84f: addl  $1, %ecx
90
91; CHECK:       [Probe]: FUNC: foo Index: 7  Type: Block  Inlined: @ main:2
92; CHECK-NEXT:      85e: movl  $2098432, %edi
93
94; CHECK:       [Probe]: FUNC: foo Index: 9  Type: DirectCall  Inlined: @ main:2
95; CHECK-NEXT:      865: callq 0x930
96
97
98; clang -O3 -fexperimental-new-pass-manager -fuse-ld=lld -fpseudo-probe-for-profiling
99; -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Xclang -mdisable-tail-calls
100; -g test.c  -o a.out
101
102#include <stdio.h>
103
104int bar(int x, int y) {
105  if (x % 3) {
106    return x - y;
107  }
108  return x + y;
109}
110
111void foo() {
112  int s, i = 0;
113  while (i++ < 4000 * 4000)
114    if (i % 91) s = bar(i, s); else s += 30;
115  printf("sum is %d\n", s);
116}
117
118int main() {
119  foo();
120  return 0;
121}
122