xref: /aosp_15_r20/external/llvm/test/tools/llvm-profdata/sample-profile-basic.test (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard WorkerBasic tests for sample profiles.
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker1- Show all functions
4*9880d681SAndroid Build Coastguard WorkerRUN: llvm-profdata show --sample %p/Inputs/sample-profile.proftext | FileCheck %s --check-prefix=SHOW1
5*9880d681SAndroid Build Coastguard WorkerSHOW1: Function: main: 184019, 0, 7 sampled lines
6*9880d681SAndroid Build Coastguard WorkerSHOW1: 9: 2064, calls: _Z3fooi:631 _Z3bari:1471
7*9880d681SAndroid Build Coastguard WorkerSHOW1: Function: _Z3fooi: 7711, 610, 1 sampled lines
8*9880d681SAndroid Build Coastguard WorkerSHOW1: Function: _Z3bari: 20301, 1437, 1 sampled lines
9*9880d681SAndroid Build Coastguard WorkerSHOW1: 1: 1437
10*9880d681SAndroid Build Coastguard Worker
11*9880d681SAndroid Build Coastguard Worker2- Show only bar
12*9880d681SAndroid Build Coastguard WorkerRUN: llvm-profdata show --sample --function=_Z3bari %p/Inputs/sample-profile.proftext | FileCheck %s --check-prefix=SHOW2
13*9880d681SAndroid Build Coastguard WorkerSHOW2: Function: _Z3bari: 20301, 1437, 1 sampled lines
14*9880d681SAndroid Build Coastguard WorkerSHOW2: 1: 1437
15*9880d681SAndroid Build Coastguard WorkerSHOW2-NOT: Function: main: 184019, 0, 7 sampled lines
16*9880d681SAndroid Build Coastguard WorkerSHOW2-NOT: Function: _Z3fooi: 7711, 610, 1 sampled lines
17*9880d681SAndroid Build Coastguard Worker
18*9880d681SAndroid Build Coastguard Worker3- Convert the profile to binary encoding and check that they are both
19*9880d681SAndroid Build Coastguard Worker   identical.
20*9880d681SAndroid Build Coastguard WorkerRUN: llvm-profdata merge --sample %p/Inputs/sample-profile.proftext --binary -o - | llvm-profdata show --sample - -o %t-binary
21*9880d681SAndroid Build Coastguard WorkerRUN: llvm-profdata show --sample %p/Inputs/sample-profile.proftext -o %t-text
22*9880d681SAndroid Build Coastguard WorkerRUN: diff %t-binary %t-text
23*9880d681SAndroid Build Coastguard Worker
24*9880d681SAndroid Build Coastguard Worker4- Merge the binary and text encodings of the profile and check that the
25*9880d681SAndroid Build Coastguard Worker   counters have doubled.
26*9880d681SAndroid Build Coastguard WorkerRUN: llvm-profdata merge --sample %p/Inputs/sample-profile.proftext -o %t-binprof
27*9880d681SAndroid Build Coastguard WorkerRUN: llvm-profdata merge --sample --text %p/Inputs/sample-profile.proftext %t-binprof -o - | FileCheck %s --check-prefix=MERGE1
28*9880d681SAndroid Build Coastguard WorkerMERGE1: main:368038:0
29*9880d681SAndroid Build Coastguard WorkerMERGE1: 9: 4128 _Z3fooi:1262 _Z3bari:2942
30*9880d681SAndroid Build Coastguard WorkerMERGE1: _Z3fooi:15422:1220
31*9880d681SAndroid Build Coastguard Worker
32*9880d681SAndroid Build Coastguard Worker5- Detect invalid text encoding (e.g. instrumentation profile text format).
33*9880d681SAndroid Build Coastguard WorkerRUN: not llvm-profdata show --sample %p/Inputs/foo3bar3-1.proftext 2>&1 | FileCheck %s --check-prefix=BADTEXT
34*9880d681SAndroid Build Coastguard WorkerBADTEXT: error: {{.+}}: Unrecognized sample profile encoding format
35