Extend and simplify the sample profile input file.
authorDiego Novillo <dnovillo@google.com>
Fri, 10 Jan 2014 23:23:51 +0000 (23:23 +0000)
committerDiego Novillo <dnovillo@google.com>
Fri, 10 Jan 2014 23:23:51 +0000 (23:23 +0000)
commit4b2b2da9c76acff7f38854ad4187ce2a3d46da9d
treeec87b8eb0bfbb3844615d88334a9fe13dd436dcd
parent0de8cecb840e1b332a0a6f39855ddecda94202e8
Extend and simplify the sample profile input file.

1- Use the line_iterator class to read profile files.

2- Allow comments in profile file. Lines starting with '#'
   are completely ignored while reading the profile.

3- Add parsing support for discriminators and indirect call samples.

   Our external profiler can emit more profile information that we are
   currently not handling. This patch does not add new functionality to
   support this information, but it allows profile files to provide it.

   I will add actual support later on (for at least one of these
   features, I need support for DWARF discriminators in Clang).

   A sample line may contain the following additional information:

   Discriminator. This is used if the sampled program was compiled with
   DWARF discriminator support
   (http://wiki.dwarfstd.org/index.php?title=Path_Discriminators). This
   is currently only emitted by GCC and we just ignore it.

   Potential call targets and samples. If present, this line contains a
   call instruction. This models both direct and indirect calls. Each
   called target is listed together with the number of samples. For
   example,

                    130: 7  foo:3  bar:2  baz:7

   The above means that at relative line offset 130 there is a call
   instruction that calls one of foo(), bar() and baz(). With baz()
   being the relatively more frequent call target.

   Differential Revision: http://llvm-reviews.chandlerc.com/D2355

4- Simplify format of profile input file.

   This implements earlier suggestions to simplify the format of the
   sample profile file. The symbol table is not necessary and function
   profiles do not need to know the number of samples in advance.

   Differential Revision: http://llvm-reviews.chandlerc.com/D2419

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198973 91177308-0d34-0410-b5e6-96231b3b80d8
12 files changed:
lib/Transforms/Scalar/SampleProfile.cpp
test/Transforms/SampleProfile/Inputs/bad_fn_header.prof
test/Transforms/SampleProfile/Inputs/bad_sample_line.prof
test/Transforms/SampleProfile/Inputs/branch.prof
test/Transforms/SampleProfile/Inputs/calls.prof [new file with mode: 0644]
test/Transforms/SampleProfile/Inputs/missing_num_syms.prof [deleted file]
test/Transforms/SampleProfile/Inputs/missing_samples.prof [deleted file]
test/Transforms/SampleProfile/Inputs/missing_symtab.prof [deleted file]
test/Transforms/SampleProfile/Inputs/propagate.prof
test/Transforms/SampleProfile/Inputs/syntax.prof
test/Transforms/SampleProfile/calls.ll [new file with mode: 0644]
test/Transforms/SampleProfile/syntax.ll