Handle inline stacks in gcov-encoded sample profiles.
authorDiego Novillo <dnovillo@google.com>
Thu, 8 Oct 2015 00:39:11 +0000 (00:39 +0000)
committerDiego Novillo <dnovillo@google.com>
Thu, 8 Oct 2015 00:39:11 +0000 (00:39 +0000)
commit6fd08c8868ad63057e4455150a7be9e4019b2371
tree689c0058190dea4b79c44d80bc7814ff7549fbdf
parentb224a734975c4fb2923ebded8e63c21a8a7f2bc1
Handle inline stacks in gcov-encoded sample profiles.

This patch adds support for reading sample profiles with inline stacks.
Inline stacks in a profile are generated when the sampled binary has
samples in inlined functions.

For instance, if main() calls foo() and foo() calls bar(), and bar() is
inlined into foo() and foo() inlined into main(), the profile may look
something like:

main total:364084 head:0
  [ ... ]
  2.3: _Z3fool total:243786
    1: 60149
    1.2: 38568
    1.4: 46511
    1.7: _Z3bari total:98558
      1.1: 52672
      1.2: 45886

At line 2, discriminator 3, main() calls foo(). In turn, foo() calls
bar() at line 1, discriminator 7.

In the textual format, this stacking of inline calls is represented
with indentation.

With this change, LLVM can now read sample profile files generated by
the create_gcov tool from https://github.com/google/autofdo.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249644 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/ProfileData/SampleProf.h
include/llvm/ProfileData/SampleProfReader.h
include/llvm/ProfileData/SampleProfWriter.h
lib/ProfileData/SampleProfReader.cpp
lib/ProfileData/SampleProfWriter.cpp
test/tools/llvm-profdata/Inputs/gcc-sample-profile.gcov [new file with mode: 0644]
test/tools/llvm-profdata/gcc-gcov-sample-profile.test [new file with mode: 0644]