Alex Lorenz | bf4508b | 2014-07-30 20:30:11 +0000 | [diff] [blame] | 1 | llvm-profdata - Profile data tool |
| 2 | ================================= |
Duncan P. N. Exon Smith | 846a627 | 2014-02-17 23:22:49 +0000 | [diff] [blame] | 3 | |
| 4 | SYNOPSIS |
| 5 | -------- |
| 6 | |
Alex Lorenz | bf4508b | 2014-07-30 20:30:11 +0000 | [diff] [blame] | 7 | :program:`llvm-profdata` *command* [*args...*] |
Duncan P. N. Exon Smith | 846a627 | 2014-02-17 23:22:49 +0000 | [diff] [blame] | 8 | |
| 9 | DESCRIPTION |
| 10 | ----------- |
| 11 | |
Alex Lorenz | bf4508b | 2014-07-30 20:30:11 +0000 | [diff] [blame] | 12 | The :program:`llvm-profdata` tool is a small utility for working with profile |
| 13 | data files. |
Duncan P. N. Exon Smith | 846a627 | 2014-02-17 23:22:49 +0000 | [diff] [blame] | 14 | |
Alex Lorenz | bf4508b | 2014-07-30 20:30:11 +0000 | [diff] [blame] | 15 | COMMANDS |
| 16 | -------- |
| 17 | |
Justin Bogner | 22b9f6a | 2015-03-12 01:38:50 +0000 | [diff] [blame] | 18 | * :ref:`merge <profdata-merge>` |
| 19 | * :ref:`show <profdata-show>` |
Rong Xu | 998b97f | 2019-04-30 21:19:12 +0000 | [diff] [blame] | 20 | * :ref:`overlap <profdata-overlap>` |
Alex Lorenz | bf4508b | 2014-07-30 20:30:11 +0000 | [diff] [blame] | 21 | |
| 22 | .. program:: llvm-profdata merge |
| 23 | |
Justin Bogner | 22b9f6a | 2015-03-12 01:38:50 +0000 | [diff] [blame] | 24 | .. _profdata-merge: |
Alex Lorenz | bf4508b | 2014-07-30 20:30:11 +0000 | [diff] [blame] | 25 | |
| 26 | MERGE |
| 27 | ----- |
| 28 | |
| 29 | SYNOPSIS |
| 30 | ^^^^^^^^ |
| 31 | |
Nathan Slingerland | 7f5b47d | 2015-12-15 17:37:09 +0000 | [diff] [blame] | 32 | :program:`llvm-profdata merge` [*options*] [*filename...*] |
Alex Lorenz | bf4508b | 2014-07-30 20:30:11 +0000 | [diff] [blame] | 33 | |
| 34 | DESCRIPTION |
| 35 | ^^^^^^^^^^^ |
| 36 | |
| 37 | :program:`llvm-profdata merge` takes several profile data files |
| 38 | generated by PGO instrumentation and merges them together into a single |
| 39 | indexed profile data file. |
Duncan P. N. Exon Smith | 846a627 | 2014-02-17 23:22:49 +0000 | [diff] [blame] | 40 | |
Nathan Slingerland | 7f5b47d | 2015-12-15 17:37:09 +0000 | [diff] [blame] | 41 | By default profile data is merged without modification. This means that the |
| 42 | relative importance of each input file is proportional to the number of samples |
| 43 | or counts it contains. In general, the input from a longer training run will be |
| 44 | interpreted as relatively more important than a shorter run. Depending on the |
| 45 | nature of the training runs it may be useful to adjust the weight given to each |
| 46 | input file by using the ``-weighted-input`` option. |
| 47 | |
Vedant Kumar | cef4360 | 2016-06-07 22:47:31 +0000 | [diff] [blame] | 48 | Profiles passed in via ``-weighted-input``, ``-input-files``, or via positional |
| 49 | arguments are processed once for each time they are seen. |
| 50 | |
Nathan Slingerland | 7f5b47d | 2015-12-15 17:37:09 +0000 | [diff] [blame] | 51 | |
Duncan P. N. Exon Smith | 846a627 | 2014-02-17 23:22:49 +0000 | [diff] [blame] | 52 | OPTIONS |
Alex Lorenz | bf4508b | 2014-07-30 20:30:11 +0000 | [diff] [blame] | 53 | ^^^^^^^ |
Duncan P. N. Exon Smith | 846a627 | 2014-02-17 23:22:49 +0000 | [diff] [blame] | 54 | |
Alex Lorenz | bf4508b | 2014-07-30 20:30:11 +0000 | [diff] [blame] | 55 | .. option:: -help |
Duncan P. N. Exon Smith | 846a627 | 2014-02-17 23:22:49 +0000 | [diff] [blame] | 56 | |
Alex Lorenz | bf4508b | 2014-07-30 20:30:11 +0000 | [diff] [blame] | 57 | Print a summary of command line options. |
| 58 | |
| 59 | .. option:: -output=output, -o=output |
| 60 | |
| 61 | Specify the output file name. *Output* cannot be ``-`` as the resulting |
| 62 | indexed profile data can't be written to standard output. |
| 63 | |
Nathan Slingerland | 7f5b47d | 2015-12-15 17:37:09 +0000 | [diff] [blame] | 64 | .. option:: -weighted-input=weight,filename |
| 65 | |
Sean Silva | 84d1922 | 2016-05-28 01:03:36 +0000 | [diff] [blame] | 66 | Specify an input file name along with a weight. The profile counts of the |
| 67 | supplied ``filename`` will be scaled (multiplied) by the supplied |
| 68 | ``weight``, where where ``weight`` is a decimal integer >= 1. |
| 69 | Input files specified without using this option are assigned a default |
| 70 | weight of 1. Examples are shown below. |
Nathan Slingerland | 7f5b47d | 2015-12-15 17:37:09 +0000 | [diff] [blame] | 71 | |
Vedant Kumar | cef4360 | 2016-06-07 22:47:31 +0000 | [diff] [blame] | 72 | .. option:: -input-files=path, -f=path |
| 73 | |
| 74 | Specify a file which contains a list of files to merge. The entries in this |
| 75 | file are newline-separated. Lines starting with '#' are skipped. Entries may |
| 76 | be of the form <filename> or <weight>,<filename>. |
| 77 | |
Richard Smith | 3164fcf | 2018-09-13 20:22:02 +0000 | [diff] [blame] | 78 | .. option:: -remapping-file=path, -r=path |
| 79 | |
| 80 | Specify a file which contains a remapping from symbol names in the input |
| 81 | profile to the symbol names that should be used in the output profile. The |
| 82 | file should consist of lines of the form ``<input-symbol> <output-symbol>``. |
| 83 | Blank lines and lines starting with ``#`` are skipped. |
| 84 | |
| 85 | The :doc:`llvm-cxxmap <llvm-cxxmap>` tool can be used to generate the symbol |
| 86 | remapping file. |
| 87 | |
Diego Novillo | 6555adb | 2015-05-28 21:57:17 +0000 | [diff] [blame] | 88 | .. option:: -instr (default) |
| 89 | |
Xinliang David Li | 2fc2515 | 2015-11-24 20:48:25 +0000 | [diff] [blame] | 90 | Specify that the input profile is an instrumentation-based profile. |
Diego Novillo | 6555adb | 2015-05-28 21:57:17 +0000 | [diff] [blame] | 91 | |
| 92 | .. option:: -sample |
| 93 | |
Xinliang David Li | 2fc2515 | 2015-11-24 20:48:25 +0000 | [diff] [blame] | 94 | Specify that the input profile is a sample-based profile. |
| 95 | |
| 96 | The format of the generated file can be generated in one of three ways: |
Diego Novillo | 6555adb | 2015-05-28 21:57:17 +0000 | [diff] [blame] | 97 | |
| 98 | .. option:: -binary (default) |
| 99 | |
Xinliang David Li | 2fc2515 | 2015-11-24 20:48:25 +0000 | [diff] [blame] | 100 | Emit the profile using a binary encoding. For instrumentation-based profile |
| 101 | the output format is the indexed binary format. |
Diego Novillo | 6555adb | 2015-05-28 21:57:17 +0000 | [diff] [blame] | 102 | |
| 103 | .. option:: -text |
| 104 | |
Xinliang David Li | 2fc2515 | 2015-11-24 20:48:25 +0000 | [diff] [blame] | 105 | Emit the profile in text mode. This option can also be used with both |
| 106 | sample-based and instrumentation-based profile. When this option is used |
| 107 | the profile will be dumped in the text format that is parsable by the profile |
| 108 | reader. |
Diego Novillo | 6555adb | 2015-05-28 21:57:17 +0000 | [diff] [blame] | 109 | |
| 110 | .. option:: -gcc |
| 111 | |
| 112 | Emit the profile using GCC's gcov format (Not yet supported). |
| 113 | |
Vedant Kumar | ee2ce4a5 | 2016-06-09 21:09:54 +0000 | [diff] [blame] | 114 | .. option:: -sparse[=true|false] |
Vedant Kumar | 00dab22 | 2016-01-29 22:54:45 +0000 | [diff] [blame] | 115 | |
| 116 | Do not emit function records with 0 execution count. Can only be used in |
| 117 | conjunction with -instr. Defaults to false, since it can inhibit compiler |
| 118 | optimization during PGO. |
| 119 | |
Vedant Kumar | e3a0bf5 | 2016-07-19 01:17:20 +0000 | [diff] [blame] | 120 | .. option:: -num-threads=N, -j=N |
| 121 | |
| 122 | Use N threads to perform profile merging. When N=0, llvm-profdata auto-detects |
| 123 | an appropriate number of threads to use. This is the default. |
| 124 | |
Nathan Slingerland | 7f5b47d | 2015-12-15 17:37:09 +0000 | [diff] [blame] | 125 | EXAMPLES |
| 126 | ^^^^^^^^ |
| 127 | Basic Usage |
| 128 | +++++++++++ |
| 129 | Merge three profiles: |
| 130 | |
| 131 | :: |
| 132 | |
| 133 | llvm-profdata merge foo.profdata bar.profdata baz.profdata -output merged.profdata |
| 134 | |
| 135 | Weighted Input |
| 136 | ++++++++++++++ |
| 137 | The input file `foo.profdata` is especially important, multiply its counts by 10: |
| 138 | |
| 139 | :: |
| 140 | |
| 141 | llvm-profdata merge -weighted-input=10,foo.profdata bar.profdata baz.profdata -output merged.profdata |
| 142 | |
| 143 | Exactly equivalent to the previous invocation (explicit form; useful for programmatic invocation): |
| 144 | |
| 145 | :: |
| 146 | |
| 147 | llvm-profdata merge -weighted-input=10,foo.profdata -weighted-input=1,bar.profdata -weighted-input=1,baz.profdata -output merged.profdata |
| 148 | |
Alex Lorenz | bf4508b | 2014-07-30 20:30:11 +0000 | [diff] [blame] | 149 | .. program:: llvm-profdata show |
| 150 | |
Justin Bogner | 22b9f6a | 2015-03-12 01:38:50 +0000 | [diff] [blame] | 151 | .. _profdata-show: |
Alex Lorenz | bf4508b | 2014-07-30 20:30:11 +0000 | [diff] [blame] | 152 | |
| 153 | SHOW |
| 154 | ---- |
| 155 | |
| 156 | SYNOPSIS |
| 157 | ^^^^^^^^ |
| 158 | |
| 159 | :program:`llvm-profdata show` [*options*] [*filename*] |
| 160 | |
| 161 | DESCRIPTION |
| 162 | ^^^^^^^^^^^ |
| 163 | |
| 164 | :program:`llvm-profdata show` takes a profile data file and displays the |
| 165 | information about the profile counters for this file and |
| 166 | for any of the specified function(s). |
| 167 | |
| 168 | If *filename* is omitted or is ``-``, then **llvm-profdata show** reads its |
| 169 | input from standard input. |
| 170 | |
| 171 | OPTIONS |
| 172 | ^^^^^^^ |
| 173 | |
| 174 | .. option:: -all-functions |
| 175 | |
| 176 | Print details for every function. |
| 177 | |
| 178 | .. option:: -counts |
| 179 | |
| 180 | Print the counter values for the displayed functions. |
| 181 | |
| 182 | .. option:: -function=string |
| 183 | |
| 184 | Print details for a function if the function's name contains the given string. |
| 185 | |
| 186 | .. option:: -help |
| 187 | |
| 188 | Print a summary of command line options. |
| 189 | |
| 190 | .. option:: -output=output, -o=output |
| 191 | |
| 192 | Specify the output file name. If *output* is ``-`` or it isn't specified, |
| 193 | then the output is sent to standard output. |
Duncan P. N. Exon Smith | 846a627 | 2014-02-17 23:22:49 +0000 | [diff] [blame] | 194 | |
Diego Novillo | 6555adb | 2015-05-28 21:57:17 +0000 | [diff] [blame] | 195 | .. option:: -instr (default) |
| 196 | |
| 197 | Specify that the input profile is an instrumentation-based profile. |
| 198 | |
Xinliang David Li | 6f7c19a | 2015-11-23 20:47:38 +0000 | [diff] [blame] | 199 | .. option:: -text |
| 200 | |
| 201 | Instruct the profile dumper to show profile counts in the text format of the |
| 202 | instrumentation-based profile data representation. By default, the profile |
| 203 | information is dumped in a more human readable form (also in text) with |
| 204 | annotations. |
| 205 | |
Xinliang David Li | 801b531 | 2017-07-11 20:30:43 +0000 | [diff] [blame] | 206 | .. option:: -topn=n |
Rong Xu | 52aa224 | 2019-01-08 22:41:48 +0000 | [diff] [blame] | 207 | |
Xinliang David Li | 801b531 | 2017-07-11 20:30:43 +0000 | [diff] [blame] | 208 | Instruct the profile dumper to show the top ``n`` functions with the |
| 209 | hottest basic blocks in the summary section. By default, the topn functions |
| 210 | are not dumped. |
| 211 | |
Diego Novillo | 6555adb | 2015-05-28 21:57:17 +0000 | [diff] [blame] | 212 | .. option:: -sample |
| 213 | |
| 214 | Specify that the input profile is a sample-based profile. |
| 215 | |
Rong Xu | 60faea1 | 2017-03-16 21:15:48 +0000 | [diff] [blame] | 216 | .. option:: -memop-sizes |
| 217 | |
| 218 | Show the profiled sizes of the memory intrinsic calls for shown functions. |
| 219 | |
Rong Xu | 52aa224 | 2019-01-08 22:41:48 +0000 | [diff] [blame] | 220 | .. option:: -value-cutoff=n |
| 221 | |
| 222 | Show only those functions whose max count values are greater or equal to ``n``. |
| 223 | By default, the value-cutoff is set to 0. |
| 224 | |
| 225 | .. option:: -list-below-cutoff |
| 226 | |
| 227 | Only output names of functions whose max count value are below the cutoff |
| 228 | value. |
| 229 | |
Rong Xu | a6ff69f | 2019-02-28 19:55:07 +0000 | [diff] [blame] | 230 | .. option:: -showcs |
Rong Xu | 4f471ee | 2019-04-18 07:11:05 +0000 | [diff] [blame] | 231 | |
Rong Xu | a6ff69f | 2019-02-28 19:55:07 +0000 | [diff] [blame] | 232 | Only show context sensitive profile counts. The default is to filter all |
| 233 | context sensitive profile counts. |
| 234 | |
Rong Xu | 998b97f | 2019-04-30 21:19:12 +0000 | [diff] [blame] | 235 | .. program:: llvm-profdata overlap |
| 236 | |
| 237 | .. _profdata-overlap: |
| 238 | |
| 239 | OVERLAP |
| 240 | ------- |
| 241 | |
| 242 | SYNOPSIS |
| 243 | ^^^^^^^^ |
| 244 | |
| 245 | :program:`llvm-profdata overlap` [*options*] [*base profile file*] [*test profile file*] |
| 246 | |
| 247 | DESCRIPTION |
| 248 | ^^^^^^^^^^^ |
| 249 | |
| 250 | :program:`llvm-profdata overlap` takes two profile data files and displays the |
| 251 | *overlap* of counter distribution between the whole files and between any of the |
| 252 | specified functions. |
| 253 | |
| 254 | In this command, *overlap* is defined as follows: |
| 255 | Suppose *base profile file* has the following counts: |
| 256 | {c1_1, c1_2, ..., c1_n, c1_u_1, c2_u_2, ..., c2_u_s}, |
| 257 | and *test profile file* has |
| 258 | {c2_1, c2_2, ..., c2_n, c2_v_1, c2_v_2, ..., c2_v_t}. |
| 259 | Here c{1|2}_i (i = 1 .. n) are matched counters and c1_u_i (i = 1 .. s) and |
| 260 | c2_v_i (i = 1 .. v) are unmatched counters (or counters only existing in) |
| 261 | *base profile file* and *test profile file*, respectively. |
| 262 | Let sum_1 = c1_1 + c1_2 + ... + c1_n + c1_u_1 + c2_u_2 + ... + c2_u_s, and |
| 263 | sum_2 = c2_1 + c2_2 + ... + c2_n + c2_v_1 + c2_v_2 + ... + c2_v_t. |
| 264 | *overlap* = min(c1_1/sum_1, c2_1/sum_2) + min(c1_2/sum_1, c2_2/sum_2) + ... |
Rong Xu | b1f9577 | 2019-04-30 22:35:35 +0000 | [diff] [blame] | 265 | + min(c1_n/sum_1, c2_n/sum_2). |
Rong Xu | 998b97f | 2019-04-30 21:19:12 +0000 | [diff] [blame] | 266 | |
| 267 | The result overlap distribution is a percentage number, ranging from 0.0% to |
| 268 | 100.0%, where 0.0% means there is no overlap and 100.0% means a perfect |
| 269 | overlap. |
| 270 | |
| 271 | Here is an example, if *base profile file* has counts of {400, 600}, and |
| 272 | *test profile file* has matched counts of {60000, 40000}. The *overlap* is 80%. |
| 273 | |
| 274 | |
| 275 | OPTIONS |
| 276 | ^^^^^^^ |
| 277 | |
| 278 | .. option:: -function=string |
| 279 | |
| 280 | Print details for a function if the function's name contains the given string. |
| 281 | |
| 282 | .. option:: -help |
| 283 | |
| 284 | Print a summary of command line options. |
| 285 | |
| 286 | .. option:: -o=output or -o output |
| 287 | |
| 288 | Specify the output file name. If *output* is ``-`` or it isn't specified, |
| 289 | then the output is sent to standard output. |
| 290 | |
| 291 | .. option:: -value-cutoff=n |
| 292 | |
| 293 | Show only those functions whose max count values are greater or equal to ``n``. |
| 294 | By default, the value-cutoff is set to max of unsigned long long. |
| 295 | |
| 296 | .. option:: -cs |
| 297 | |
| 298 | Only show overlap for the context sensitive profile counts. The default is to show |
| 299 | non-context sensitive profile counts. |
| 300 | |
Duncan P. N. Exon Smith | 846a627 | 2014-02-17 23:22:49 +0000 | [diff] [blame] | 301 | EXIT STATUS |
| 302 | ----------- |
| 303 | |
Alex Lorenz | bf4508b | 2014-07-30 20:30:11 +0000 | [diff] [blame] | 304 | :program:`llvm-profdata` returns 1 if the command is omitted or is invalid, |
| 305 | if it cannot read input files, or if there is a mismatch between their data. |