blob: 211d8c5bbd84533db9838b38fdca4afa8e4960d0 [file] [log] [blame]
Diego Novillod5336ae2014-11-01 00:56:55 +00001Basic tests for sample profiles.
2
31- Show all functions
4RUN: llvm-profdata show --sample %p/Inputs/sample-profile.proftext | FileCheck %s --check-prefix=SHOW1
Vedant Kumar7f5b3d62017-04-26 15:39:53 +00005SHOW1-DAG: Function: main: 184019, 0, 7 sampled lines
6SHOW1-DAG: 9: 2064, calls: _Z3fooi:631 _Z3bari:1471
7SHOW1-DAG: Function: _Z3fooi: 7711, 610, 1 sampled lines
8SHOW1-DAG: Function: _Z3bari: 20301, 1437, 1 sampled lines
9SHOW1-DAG: 1: 1437
Diego Novillod5336ae2014-11-01 00:56:55 +000010
112- Show only bar
12RUN: llvm-profdata show --sample --function=_Z3bari %p/Inputs/sample-profile.proftext | FileCheck %s --check-prefix=SHOW2
13SHOW2: Function: _Z3bari: 20301, 1437, 1 sampled lines
Diego Novillo8e415a82015-11-13 20:24:28 +000014SHOW2: 1: 1437
Diego Novillod5336ae2014-11-01 00:56:55 +000015SHOW2-NOT: Function: main: 184019, 0, 7 sampled lines
16SHOW2-NOT: Function: _Z3fooi: 7711, 610, 1 sampled lines
17
183- Convert the profile to binary encoding and check that they are both
19 identical.
20RUN: llvm-profdata merge --sample %p/Inputs/sample-profile.proftext --binary -o - | llvm-profdata show --sample - -o %t-binary
21RUN: llvm-profdata show --sample %p/Inputs/sample-profile.proftext -o %t-text
22RUN: diff %t-binary %t-text
23
244- Merge the binary and text encodings of the profile and check that the
25 counters have doubled.
26RUN: llvm-profdata merge --sample %p/Inputs/sample-profile.proftext -o %t-binprof
27RUN: llvm-profdata merge --sample --text %p/Inputs/sample-profile.proftext %t-binprof -o - | FileCheck %s --check-prefix=MERGE1
Vedant Kumar7f5b3d62017-04-26 15:39:53 +000028MERGE1-DAG: main:368038:0
29MERGE1-DAG: 9: 4128 _Z3fooi:1262 _Z3bari:2942
30MERGE1-DAG: _Z3fooi:15422:1220
Nathan Slingerland4f823662015-11-13 03:47:58 +000031
325- Detect invalid text encoding (e.g. instrumentation profile text format).
33RUN: not llvm-profdata show --sample %p/Inputs/foo3bar3-1.proftext 2>&1 | FileCheck %s --check-prefix=BADTEXT
34BADTEXT: error: {{.+}}: Unrecognized sample profile encoding format