2014-07-30 20:30:11 +00:00
|
|
|
llvm-profdata - Profile data tool
|
|
|
|
=================================
|
2014-02-17 23:22:49 +00:00
|
|
|
|
[docs][tools] Add missing "program" tags to rst files
Sphinx allows for definitions of command-line options using
`.. option <name>` and references to those options via `:option:<name>`.
However, it looks like there is no scoping of these options by default,
meaning that links can end up pointing to incorrect documents. See for
example the llvm-mca document, which contains references to -o that,
prior to this patch, pointed to a different document. What's worse is
that these links appear to be non-deterministic in which one is picked
(on my machine, some references end up pointing to opt, whereas on the
live docs, they point to llvm-dwarfdump, for example).
The fix is to add the .. program <name> tag. This essentially namespaces
the options (definitions and references) to the named program, ensuring
that the links are kept correct.
Reviwed by: andreadb
Differential Revision: https://reviews.llvm.org/D63873
llvm-svn: 364538
2019-06-27 13:24:46 +00:00
|
|
|
.. program:: llvm-profdata
|
|
|
|
|
2014-02-17 23:22:49 +00:00
|
|
|
SYNOPSIS
|
|
|
|
--------
|
|
|
|
|
2014-07-30 20:30:11 +00:00
|
|
|
:program:`llvm-profdata` *command* [*args...*]
|
2014-02-17 23:22:49 +00:00
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
-----------
|
|
|
|
|
2014-07-30 20:30:11 +00:00
|
|
|
The :program:`llvm-profdata` tool is a small utility for working with profile
|
|
|
|
data files.
|
2014-02-17 23:22:49 +00:00
|
|
|
|
2014-07-30 20:30:11 +00:00
|
|
|
COMMANDS
|
|
|
|
--------
|
|
|
|
|
2015-03-12 01:38:50 +00:00
|
|
|
* :ref:`merge <profdata-merge>`
|
|
|
|
* :ref:`show <profdata-show>`
|
2019-04-30 21:19:12 +00:00
|
|
|
* :ref:`overlap <profdata-overlap>`
|
2014-07-30 20:30:11 +00:00
|
|
|
|
|
|
|
.. program:: llvm-profdata merge
|
|
|
|
|
2015-03-12 01:38:50 +00:00
|
|
|
.. _profdata-merge:
|
2014-07-30 20:30:11 +00:00
|
|
|
|
|
|
|
MERGE
|
|
|
|
-----
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
^^^^^^^^
|
|
|
|
|
2015-12-15 17:37:09 +00:00
|
|
|
:program:`llvm-profdata merge` [*options*] [*filename...*]
|
2014-07-30 20:30:11 +00:00
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
^^^^^^^^^^^
|
|
|
|
|
|
|
|
:program:`llvm-profdata merge` takes several profile data files
|
|
|
|
generated by PGO instrumentation and merges them together into a single
|
|
|
|
indexed profile data file.
|
2014-02-17 23:22:49 +00:00
|
|
|
|
2015-12-15 17:37:09 +00:00
|
|
|
By default profile data is merged without modification. This means that the
|
|
|
|
relative importance of each input file is proportional to the number of samples
|
|
|
|
or counts it contains. In general, the input from a longer training run will be
|
|
|
|
interpreted as relatively more important than a shorter run. Depending on the
|
|
|
|
nature of the training runs it may be useful to adjust the weight given to each
|
|
|
|
input file by using the ``-weighted-input`` option.
|
|
|
|
|
2016-06-07 22:47:31 +00:00
|
|
|
Profiles passed in via ``-weighted-input``, ``-input-files``, or via positional
|
|
|
|
arguments are processed once for each time they are seen.
|
|
|
|
|
2015-12-15 17:37:09 +00:00
|
|
|
|
2014-02-17 23:22:49 +00:00
|
|
|
OPTIONS
|
2014-07-30 20:30:11 +00:00
|
|
|
^^^^^^^
|
|
|
|
|
|
|
|
.. option:: -help
|
|
|
|
|
|
|
|
Print a summary of command line options.
|
|
|
|
|
|
|
|
.. option:: -output=output, -o=output
|
|
|
|
|
|
|
|
Specify the output file name. *Output* cannot be ``-`` as the resulting
|
|
|
|
indexed profile data can't be written to standard output.
|
|
|
|
|
2015-12-15 17:37:09 +00:00
|
|
|
.. option:: -weighted-input=weight,filename
|
|
|
|
|
2016-05-28 01:03:36 +00:00
|
|
|
Specify an input file name along with a weight. The profile counts of the
|
|
|
|
supplied ``filename`` will be scaled (multiplied) by the supplied
|
2020-04-13 08:39:58 +02:00
|
|
|
``weight``, where ``weight`` is a decimal integer >= 1.
|
2016-05-28 01:03:36 +00:00
|
|
|
Input files specified without using this option are assigned a default
|
|
|
|
weight of 1. Examples are shown below.
|
2015-12-15 17:37:09 +00:00
|
|
|
|
2016-06-07 22:47:31 +00:00
|
|
|
.. option:: -input-files=path, -f=path
|
|
|
|
|
|
|
|
Specify a file which contains a list of files to merge. The entries in this
|
|
|
|
file are newline-separated. Lines starting with '#' are skipped. Entries may
|
|
|
|
be of the form <filename> or <weight>,<filename>.
|
|
|
|
|
2018-09-13 20:22:02 +00:00
|
|
|
.. option:: -remapping-file=path, -r=path
|
|
|
|
|
|
|
|
Specify a file which contains a remapping from symbol names in the input
|
|
|
|
profile to the symbol names that should be used in the output profile. The
|
|
|
|
file should consist of lines of the form ``<input-symbol> <output-symbol>``.
|
|
|
|
Blank lines and lines starting with ``#`` are skipped.
|
|
|
|
|
|
|
|
The :doc:`llvm-cxxmap <llvm-cxxmap>` tool can be used to generate the symbol
|
|
|
|
remapping file.
|
|
|
|
|
2015-05-28 21:57:17 +00:00
|
|
|
.. option:: -instr (default)
|
|
|
|
|
2015-11-24 20:48:25 +00:00
|
|
|
Specify that the input profile is an instrumentation-based profile.
|
2015-05-28 21:57:17 +00:00
|
|
|
|
|
|
|
.. option:: -sample
|
|
|
|
|
2015-11-24 20:48:25 +00:00
|
|
|
Specify that the input profile is a sample-based profile.
|
2021-11-15 09:17:08 +08:00
|
|
|
|
2015-11-24 20:48:25 +00:00
|
|
|
The format of the generated file can be generated in one of three ways:
|
2015-05-28 21:57:17 +00:00
|
|
|
|
|
|
|
.. option:: -binary (default)
|
|
|
|
|
2015-11-24 20:48:25 +00:00
|
|
|
Emit the profile using a binary encoding. For instrumentation-based profile
|
2021-11-15 09:17:08 +08:00
|
|
|
the output format is the indexed binary format.
|
2015-05-28 21:57:17 +00:00
|
|
|
|
2020-05-13 15:11:49 -07:00
|
|
|
.. option:: -extbinary
|
|
|
|
|
|
|
|
Emit the profile using an extensible binary encoding. This option can only
|
|
|
|
be used with sample-based profile. The extensible binary encoding can be
|
|
|
|
more compact with compression enabled and can be loaded faster than the
|
|
|
|
default binary encoding.
|
|
|
|
|
2015-05-28 21:57:17 +00:00
|
|
|
.. option:: -text
|
|
|
|
|
2015-11-24 20:48:25 +00:00
|
|
|
Emit the profile in text mode. This option can also be used with both
|
|
|
|
sample-based and instrumentation-based profile. When this option is used
|
|
|
|
the profile will be dumped in the text format that is parsable by the profile
|
|
|
|
reader.
|
2015-05-28 21:57:17 +00:00
|
|
|
|
|
|
|
.. option:: -gcc
|
|
|
|
|
|
|
|
Emit the profile using GCC's gcov format (Not yet supported).
|
|
|
|
|
2016-06-09 21:09:54 +00:00
|
|
|
.. option:: -sparse[=true|false]
|
2016-01-29 22:54:45 +00:00
|
|
|
|
|
|
|
Do not emit function records with 0 execution count. Can only be used in
|
|
|
|
conjunction with -instr. Defaults to false, since it can inhibit compiler
|
|
|
|
optimization during PGO.
|
|
|
|
|
2016-07-19 01:17:20 +00:00
|
|
|
.. option:: -num-threads=N, -j=N
|
|
|
|
|
|
|
|
Use N threads to perform profile merging. When N=0, llvm-profdata auto-detects
|
|
|
|
an appropriate number of threads to use. This is the default.
|
|
|
|
|
2019-09-03 22:23:16 +00:00
|
|
|
.. option:: -failure-mode=[any|all]
|
|
|
|
|
|
|
|
Set the failure mode. There are two options: 'any' causes the merge command to
|
|
|
|
fail if any profiles are invalid, and 'all' causes the merge command to fail
|
|
|
|
only if all profiles are invalid. If 'all' is set, information from any
|
|
|
|
invalid profiles is excluded from the final merged product. The default
|
|
|
|
failure mode is 'any'.
|
|
|
|
|
2020-05-13 15:11:49 -07:00
|
|
|
.. option:: -prof-sym-list=path
|
|
|
|
|
|
|
|
Specify a file which contains a list of symbols to generate profile symbol
|
|
|
|
list in the profile. This option can only be used with sample-based profile
|
|
|
|
in extbinary format. The entries in this file are newline-separated.
|
|
|
|
|
|
|
|
.. option:: -compress-all-sections=[true|false]
|
|
|
|
|
|
|
|
Compress all sections when writing the profile. This option can only be used
|
|
|
|
with sample-based profile in extbinary format.
|
|
|
|
|
|
|
|
.. option:: -use-md5=[true|false]
|
|
|
|
|
|
|
|
Use MD5 to represent string in name table when writing the profile.
|
|
|
|
This option can only be used with sample-based profile in extbinary format.
|
|
|
|
|
|
|
|
.. option:: -gen-partial-profile=[true|false]
|
|
|
|
|
|
|
|
Mark the profile to be a partial profile which only provides partial profile
|
|
|
|
coverage for the optimized target. This option can only be used with
|
|
|
|
sample-based profile in extbinary format.
|
|
|
|
|
Supplement instr profile with sample profile.
PGO profile is usually more precise than sample profile. However, PGO profile
needs to be collected from loadtest and loadtest may not be representative
enough to the production workload. Sample profile collected from production
can be used as a supplement -- for functions cold in loadtest but warm/hot
in production, we can scale up the related function in PGO profile if the
function is warm or hot in sample profile.
The implementation contains changes in compiler side and llvm-profdata side.
Given an instr profile and a sample profile, for a function cold in PGO
profile but warm/hot in sample profile, llvm-profdata will either mark
all the counters in the profile to be -1 or scale up the max count in the
function to be above hot threshold, depending on the zero counter ratio in
the profile. The assumption is if there are too many counters being zero
in the function profile, the profile is more likely to cause harm than good,
then llvm-profdata will mark all the counters to be -1 indicating the
function is hot but the profile is unaccountable. In compiler side, if a
function profile with all -1 counters is seen, the function entry count will
be set to be above hot threshold but its internal profile will be dropped.
In the long run, it may be useful to let compiler support using PGO profile
and sample profile at the same time, but that requires more careful design
and more substantial changes to make two profiles work seamlessly. The patch
here serves as a simple intermediate solution.
Differential Revision: https://reviews.llvm.org/D81981
2020-07-08 15:19:44 -07:00
|
|
|
.. option:: -supplement-instr-with-sample=path_to_sample_profile
|
|
|
|
|
|
|
|
Supplement an instrumentation profile with sample profile. The sample profile
|
|
|
|
is the input of the flag. Output will be in instrumentation format (only works
|
|
|
|
with -instr).
|
|
|
|
|
|
|
|
.. option:: -zero-counter-threshold=threshold_float_number
|
|
|
|
|
|
|
|
For the function which is cold in instr profile but hot in sample profile, if
|
|
|
|
the ratio of the number of zero counters divided by the the total number of
|
|
|
|
counters is above the threshold, the profile of the function will be regarded
|
|
|
|
as being harmful for performance and will be dropped.
|
|
|
|
|
|
|
|
.. option:: -instr-prof-cold-threshold=threshold_int_number
|
|
|
|
|
|
|
|
User specified cold threshold for instr profile which will override the cold
|
|
|
|
threshold got from profile summary.
|
|
|
|
|
|
|
|
.. option:: -suppl-min-size-threshold=threshold_int_number
|
|
|
|
|
|
|
|
If the size of a function is smaller than the threshold, assume it can be
|
|
|
|
inlined by PGO early inliner and it will not be adjusted based on sample
|
|
|
|
profile.
|
|
|
|
|
2015-12-15 17:37:09 +00:00
|
|
|
EXAMPLES
|
|
|
|
^^^^^^^^
|
|
|
|
Basic Usage
|
|
|
|
+++++++++++
|
|
|
|
Merge three profiles:
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
llvm-profdata merge foo.profdata bar.profdata baz.profdata -output merged.profdata
|
|
|
|
|
|
|
|
Weighted Input
|
|
|
|
++++++++++++++
|
|
|
|
The input file `foo.profdata` is especially important, multiply its counts by 10:
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
llvm-profdata merge -weighted-input=10,foo.profdata bar.profdata baz.profdata -output merged.profdata
|
|
|
|
|
|
|
|
Exactly equivalent to the previous invocation (explicit form; useful for programmatic invocation):
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
llvm-profdata merge -weighted-input=10,foo.profdata -weighted-input=1,bar.profdata -weighted-input=1,baz.profdata -output merged.profdata
|
|
|
|
|
2014-07-30 20:30:11 +00:00
|
|
|
.. program:: llvm-profdata show
|
|
|
|
|
2015-03-12 01:38:50 +00:00
|
|
|
.. _profdata-show:
|
2014-07-30 20:30:11 +00:00
|
|
|
|
|
|
|
SHOW
|
|
|
|
----
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
^^^^^^^^
|
|
|
|
|
|
|
|
:program:`llvm-profdata show` [*options*] [*filename*]
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
^^^^^^^^^^^
|
|
|
|
|
|
|
|
:program:`llvm-profdata show` takes a profile data file and displays the
|
|
|
|
information about the profile counters for this file and
|
|
|
|
for any of the specified function(s).
|
|
|
|
|
|
|
|
If *filename* is omitted or is ``-``, then **llvm-profdata show** reads its
|
|
|
|
input from standard input.
|
|
|
|
|
|
|
|
OPTIONS
|
|
|
|
^^^^^^^
|
|
|
|
|
|
|
|
.. option:: -all-functions
|
|
|
|
|
|
|
|
Print details for every function.
|
|
|
|
|
|
|
|
.. option:: -counts
|
|
|
|
|
|
|
|
Print the counter values for the displayed functions.
|
|
|
|
|
|
|
|
.. option:: -function=string
|
|
|
|
|
|
|
|
Print details for a function if the function's name contains the given string.
|
|
|
|
|
|
|
|
.. option:: -help
|
|
|
|
|
|
|
|
Print a summary of command line options.
|
2014-02-17 23:22:49 +00:00
|
|
|
|
2014-07-30 20:30:11 +00:00
|
|
|
.. option:: -output=output, -o=output
|
2014-02-17 23:22:49 +00:00
|
|
|
|
2014-07-30 20:30:11 +00:00
|
|
|
Specify the output file name. If *output* is ``-`` or it isn't specified,
|
|
|
|
then the output is sent to standard output.
|
2014-02-17 23:22:49 +00:00
|
|
|
|
2015-05-28 21:57:17 +00:00
|
|
|
.. option:: -instr (default)
|
|
|
|
|
|
|
|
Specify that the input profile is an instrumentation-based profile.
|
|
|
|
|
2015-11-23 20:47:38 +00:00
|
|
|
.. option:: -text
|
|
|
|
|
|
|
|
Instruct the profile dumper to show profile counts in the text format of the
|
|
|
|
instrumentation-based profile data representation. By default, the profile
|
|
|
|
information is dumped in a more human readable form (also in text) with
|
|
|
|
annotations.
|
|
|
|
|
2017-07-11 20:30:43 +00:00
|
|
|
.. option:: -topn=n
|
2019-01-08 22:41:48 +00:00
|
|
|
|
2017-07-11 20:30:43 +00:00
|
|
|
Instruct the profile dumper to show the top ``n`` functions with the
|
|
|
|
hottest basic blocks in the summary section. By default, the topn functions
|
|
|
|
are not dumped.
|
|
|
|
|
2015-05-28 21:57:17 +00:00
|
|
|
.. option:: -sample
|
|
|
|
|
|
|
|
Specify that the input profile is a sample-based profile.
|
|
|
|
|
2017-03-16 21:15:48 +00:00
|
|
|
.. option:: -memop-sizes
|
|
|
|
|
|
|
|
Show the profiled sizes of the memory intrinsic calls for shown functions.
|
|
|
|
|
2019-01-08 22:41:48 +00:00
|
|
|
.. option:: -value-cutoff=n
|
|
|
|
|
|
|
|
Show only those functions whose max count values are greater or equal to ``n``.
|
|
|
|
By default, the value-cutoff is set to 0.
|
|
|
|
|
|
|
|
.. option:: -list-below-cutoff
|
|
|
|
|
|
|
|
Only output names of functions whose max count value are below the cutoff
|
|
|
|
value.
|
|
|
|
|
2019-02-28 19:55:07 +00:00
|
|
|
.. option:: -showcs
|
2019-04-18 07:11:05 +00:00
|
|
|
|
2019-02-28 19:55:07 +00:00
|
|
|
Only show context sensitive profile counts. The default is to filter all
|
|
|
|
context sensitive profile counts.
|
|
|
|
|
2020-05-13 15:11:49 -07:00
|
|
|
.. option:: -show-prof-sym-list=[true|false]
|
|
|
|
|
|
|
|
Show profile symbol list if it exists in the profile. This option is only
|
|
|
|
meaningful for sample-based profile in extbinary format.
|
|
|
|
|
|
|
|
.. option:: -show-sec-info-only=[true|false]
|
|
|
|
|
|
|
|
Show basic information about each section in the profile. This option is
|
|
|
|
only meaningful for sample-based profile in extbinary format.
|
|
|
|
|
2019-04-30 21:19:12 +00:00
|
|
|
.. program:: llvm-profdata overlap
|
|
|
|
|
|
|
|
.. _profdata-overlap:
|
|
|
|
|
|
|
|
OVERLAP
|
|
|
|
-------
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
^^^^^^^^
|
|
|
|
|
|
|
|
:program:`llvm-profdata overlap` [*options*] [*base profile file*] [*test profile file*]
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
^^^^^^^^^^^
|
|
|
|
|
|
|
|
:program:`llvm-profdata overlap` takes two profile data files and displays the
|
|
|
|
*overlap* of counter distribution between the whole files and between any of the
|
|
|
|
specified functions.
|
|
|
|
|
|
|
|
In this command, *overlap* is defined as follows:
|
|
|
|
Suppose *base profile file* has the following counts:
|
|
|
|
{c1_1, c1_2, ..., c1_n, c1_u_1, c2_u_2, ..., c2_u_s},
|
|
|
|
and *test profile file* has
|
|
|
|
{c2_1, c2_2, ..., c2_n, c2_v_1, c2_v_2, ..., c2_v_t}.
|
|
|
|
Here c{1|2}_i (i = 1 .. n) are matched counters and c1_u_i (i = 1 .. s) and
|
|
|
|
c2_v_i (i = 1 .. v) are unmatched counters (or counters only existing in)
|
|
|
|
*base profile file* and *test profile file*, respectively.
|
|
|
|
Let sum_1 = c1_1 + c1_2 + ... + c1_n + c1_u_1 + c2_u_2 + ... + c2_u_s, and
|
|
|
|
sum_2 = c2_1 + c2_2 + ... + c2_n + c2_v_1 + c2_v_2 + ... + c2_v_t.
|
|
|
|
*overlap* = min(c1_1/sum_1, c2_1/sum_2) + min(c1_2/sum_1, c2_2/sum_2) + ...
|
2019-04-30 22:35:35 +00:00
|
|
|
+ min(c1_n/sum_1, c2_n/sum_2).
|
2019-04-30 21:19:12 +00:00
|
|
|
|
|
|
|
The result overlap distribution is a percentage number, ranging from 0.0% to
|
|
|
|
100.0%, where 0.0% means there is no overlap and 100.0% means a perfect
|
|
|
|
overlap.
|
|
|
|
|
|
|
|
Here is an example, if *base profile file* has counts of {400, 600}, and
|
|
|
|
*test profile file* has matched counts of {60000, 40000}. The *overlap* is 80%.
|
|
|
|
|
|
|
|
OPTIONS
|
|
|
|
^^^^^^^
|
|
|
|
|
|
|
|
.. option:: -function=string
|
|
|
|
|
|
|
|
Print details for a function if the function's name contains the given string.
|
|
|
|
|
|
|
|
.. option:: -help
|
|
|
|
|
|
|
|
Print a summary of command line options.
|
|
|
|
|
|
|
|
.. option:: -o=output or -o output
|
|
|
|
|
|
|
|
Specify the output file name. If *output* is ``-`` or it isn't specified,
|
|
|
|
then the output is sent to standard output.
|
|
|
|
|
|
|
|
.. option:: -value-cutoff=n
|
|
|
|
|
|
|
|
Show only those functions whose max count values are greater or equal to ``n``.
|
|
|
|
By default, the value-cutoff is set to max of unsigned long long.
|
|
|
|
|
|
|
|
.. option:: -cs
|
|
|
|
|
|
|
|
Only show overlap for the context sensitive profile counts. The default is to show
|
|
|
|
non-context sensitive profile counts.
|
|
|
|
|
2014-02-17 23:22:49 +00:00
|
|
|
EXIT STATUS
|
|
|
|
-----------
|
|
|
|
|
2014-07-30 20:30:11 +00:00
|
|
|
:program:`llvm-profdata` returns 1 if the command is omitted or is invalid,
|
|
|
|
if it cannot read input files, or if there is a mismatch between their data.
|