xref: /llvm-project/llvm/test/tools/llvm-profdata/sample-profile-basic.test (revision 5adace352d5ef63fe344dc95a375bd33040ea987)
1d5336ae2SDiego NovilloBasic tests for sample profiles.
2d5336ae2SDiego Novillo
3d5336ae2SDiego Novillo1- Show all functions
4d5336ae2SDiego NovilloRUN: llvm-profdata show --sample %p/Inputs/sample-profile.proftext | FileCheck %s --check-prefix=SHOW1
57f5b3d6fSVedant KumarSHOW1-DAG: Function: main: 184019, 0, 7 sampled lines
6*5adace35SWenlei HeSHOW1-DAG: 9: 2064, calls: _Z3bari:1471 _Z3fooi:631
77f5b3d6fSVedant KumarSHOW1-DAG: Function: _Z3fooi: 7711, 610, 1 sampled lines
87f5b3d6fSVedant KumarSHOW1-DAG: Function: _Z3bari: 20301, 1437, 1 sampled lines
97f5b3d6fSVedant KumarSHOW1-DAG: 1: 1437
10d5336ae2SDiego Novillo
11d5336ae2SDiego Novillo2- Show only bar
12d5336ae2SDiego NovilloRUN: llvm-profdata show --sample --function=_Z3bari %p/Inputs/sample-profile.proftext | FileCheck %s --check-prefix=SHOW2
13d5336ae2SDiego NovilloSHOW2: Function: _Z3bari: 20301, 1437, 1 sampled lines
148e415a82SDiego NovilloSHOW2: 1: 1437
15d5336ae2SDiego NovilloSHOW2-NOT: Function: main: 184019, 0, 7 sampled lines
16d5336ae2SDiego NovilloSHOW2-NOT: Function: _Z3fooi: 7711, 610, 1 sampled lines
17d5336ae2SDiego Novillo
18d5336ae2SDiego Novillo3- Convert the profile to binary encoding and check that they are both
19d5336ae2SDiego Novillo   identical.
20d5336ae2SDiego NovilloRUN: llvm-profdata merge --sample %p/Inputs/sample-profile.proftext --binary -o - | llvm-profdata show --sample - -o %t-binary
21d5336ae2SDiego NovilloRUN: llvm-profdata show --sample %p/Inputs/sample-profile.proftext -o %t-text
22d5336ae2SDiego NovilloRUN: diff %t-binary %t-text
23d5336ae2SDiego Novillo
24d5336ae2SDiego Novillo4- Merge the binary and text encodings of the profile and check that the
25d5336ae2SDiego Novillo   counters have doubled.
26d5336ae2SDiego NovilloRUN: llvm-profdata merge --sample %p/Inputs/sample-profile.proftext -o %t-binprof
27d5336ae2SDiego NovilloRUN: llvm-profdata merge --sample --text %p/Inputs/sample-profile.proftext %t-binprof -o - | FileCheck %s --check-prefix=MERGE1
288d1c983fSDehao ChenMERGE1: main:368038:0
29*5adace35SWenlei HeMERGE1: 9: 4128 _Z3bari:2942 _Z3fooi:1262
308d1c983fSDehao ChenMERGE1: _Z3bari:40602:2874
318d1c983fSDehao ChenMERGE1: _Z3fooi:15422:1220
324f823667SNathan Slingerland
334f823667SNathan Slingerland5- Detect invalid text encoding (e.g. instrumentation profile text format).
344f823667SNathan SlingerlandRUN: not llvm-profdata show --sample %p/Inputs/foo3bar3-1.proftext 2>&1 | FileCheck %s --check-prefix=BADTEXT
354f823667SNathan SlingerlandBADTEXT: error: {{.+}}: Unrecognized sample profile encoding format
36