SamplePGO - Sort samples by source location when emitting as text.
[oota-llvm.git] / test / tools / llvm-profdata / gcc-gcov-sample-profile.test
1 The input gcov file has been generated on a little endian machine. Expect
2 failures on big endian systems.
3
4 XFAIL: powerpc64-, s390x, mips-, mips64-, sparc
5
6 Tests for sample profiles encoded in GCC's gcov format.
7
8 1- Show all functions. This profile has a single main() function with several
9    inlined callees.
10 RUN: llvm-profdata show --sample %p/Inputs/gcc-sample-profile.gcov | FileCheck %s --check-prefix=SHOW1
11 SHOW1: Function: main: 364084, 0, 6 sampled lines
12 SHOW1: 2.3: inlined callee: _Z3fool: 243786, 0, 3 sampled lines
13 SHOW1:   1.3: inlined callee: _Z3bari: 0, 0, 2 sampled lines
14 SHOW1:   1.7: inlined callee: _Z3bari: 98558, 0, 2 sampled lines
15 SHOW1:   1.8: inlined callee: _Z3bari: 0, 0, 2 sampled lines
16
17 2- Convert the profile to text encoding and check that they are both
18    identical.
19 RUN: llvm-profdata merge --sample %p/Inputs/gcc-sample-profile.gcov --text -o - | llvm-profdata show --sample - -o %t-text
20 RUN: llvm-profdata show --sample %p/Inputs/gcc-sample-profile.gcov -o %t-gcov
21 RUN: diff %t-text %t-gcov
22
23 4- Merge the gcov and text encodings of the profile and check that the
24    counters have doubled.
25 RUN: llvm-profdata merge --sample --text %p/Inputs/gcc-sample-profile.gcov -o %t-gcov
26 RUN: llvm-profdata merge --sample --text %p/Inputs/gcc-sample-profile.gcov %t-gcov -o - | FileCheck %s --check-prefix=MERGE1
27 MERGE1: main:728168:0
28 MERGE1: 2.3: 120298
29 MERGE1: 2.3: _Z3fool:487572