llvm-profdata.rst 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. llvm-profdata - Profile data tool
  2. =================================
  3. .. program:: llvm-profdata
  4. SYNOPSIS
  5. --------
  6. :program:`llvm-profdata` *command* [*args...*]
  7. DESCRIPTION
  8. -----------
  9. The :program:`llvm-profdata` tool is a small utility for working with profile
  10. data files.
  11. COMMANDS
  12. --------
  13. * :ref:`merge <profdata-merge>`
  14. * :ref:`show <profdata-show>`
  15. * :ref:`overlap <profdata-overlap>`
  16. .. program:: llvm-profdata merge
  17. .. _profdata-merge:
  18. MERGE
  19. -----
  20. SYNOPSIS
  21. ^^^^^^^^
  22. :program:`llvm-profdata merge` [*options*] [*filename...*]
  23. DESCRIPTION
  24. ^^^^^^^^^^^
  25. :program:`llvm-profdata merge` takes several profile data files
  26. generated by PGO instrumentation and merges them together into a single
  27. indexed profile data file.
  28. By default profile data is merged without modification. This means that the
  29. relative importance of each input file is proportional to the number of samples
  30. or counts it contains. In general, the input from a longer training run will be
  31. interpreted as relatively more important than a shorter run. Depending on the
  32. nature of the training runs it may be useful to adjust the weight given to each
  33. input file by using the ``-weighted-input`` option.
  34. Profiles passed in via ``-weighted-input``, ``-input-files``, or via positional
  35. arguments are processed once for each time they are seen.
  36. OPTIONS
  37. ^^^^^^^
  38. .. option:: -help
  39. Print a summary of command line options.
  40. .. option:: -output=output, -o=output
  41. Specify the output file name. *Output* cannot be ``-`` as the resulting
  42. indexed profile data can't be written to standard output.
  43. .. option:: -weighted-input=weight,filename
  44. Specify an input file name along with a weight. The profile counts of the
  45. supplied ``filename`` will be scaled (multiplied) by the supplied
  46. ``weight``, where where ``weight`` is a decimal integer >= 1.
  47. Input files specified without using this option are assigned a default
  48. weight of 1. Examples are shown below.
  49. .. option:: -input-files=path, -f=path
  50. Specify a file which contains a list of files to merge. The entries in this
  51. file are newline-separated. Lines starting with '#' are skipped. Entries may
  52. be of the form <filename> or <weight>,<filename>.
  53. .. option:: -remapping-file=path, -r=path
  54. Specify a file which contains a remapping from symbol names in the input
  55. profile to the symbol names that should be used in the output profile. The
  56. file should consist of lines of the form ``<input-symbol> <output-symbol>``.
  57. Blank lines and lines starting with ``#`` are skipped.
  58. The :doc:`llvm-cxxmap <llvm-cxxmap>` tool can be used to generate the symbol
  59. remapping file.
  60. .. option:: -instr (default)
  61. Specify that the input profile is an instrumentation-based profile.
  62. .. option:: -sample
  63. Specify that the input profile is a sample-based profile.
  64. The format of the generated file can be generated in one of three ways:
  65. .. option:: -binary (default)
  66. Emit the profile using a binary encoding. For instrumentation-based profile
  67. the output format is the indexed binary format.
  68. .. option:: -text
  69. Emit the profile in text mode. This option can also be used with both
  70. sample-based and instrumentation-based profile. When this option is used
  71. the profile will be dumped in the text format that is parsable by the profile
  72. reader.
  73. .. option:: -gcc
  74. Emit the profile using GCC's gcov format (Not yet supported).
  75. .. option:: -sparse[=true|false]
  76. Do not emit function records with 0 execution count. Can only be used in
  77. conjunction with -instr. Defaults to false, since it can inhibit compiler
  78. optimization during PGO.
  79. .. option:: -num-threads=N, -j=N
  80. Use N threads to perform profile merging. When N=0, llvm-profdata auto-detects
  81. an appropriate number of threads to use. This is the default.
  82. .. option:: -failure-mode=[any|all]
  83. Set the failure mode. There are two options: 'any' causes the merge command to
  84. fail if any profiles are invalid, and 'all' causes the merge command to fail
  85. only if all profiles are invalid. If 'all' is set, information from any
  86. invalid profiles is excluded from the final merged product. The default
  87. failure mode is 'any'.
  88. EXAMPLES
  89. ^^^^^^^^
  90. Basic Usage
  91. +++++++++++
  92. Merge three profiles:
  93. ::
  94. llvm-profdata merge foo.profdata bar.profdata baz.profdata -output merged.profdata
  95. Weighted Input
  96. ++++++++++++++
  97. The input file `foo.profdata` is especially important, multiply its counts by 10:
  98. ::
  99. llvm-profdata merge -weighted-input=10,foo.profdata bar.profdata baz.profdata -output merged.profdata
  100. Exactly equivalent to the previous invocation (explicit form; useful for programmatic invocation):
  101. ::
  102. llvm-profdata merge -weighted-input=10,foo.profdata -weighted-input=1,bar.profdata -weighted-input=1,baz.profdata -output merged.profdata
  103. .. program:: llvm-profdata show
  104. .. _profdata-show:
  105. SHOW
  106. ----
  107. SYNOPSIS
  108. ^^^^^^^^
  109. :program:`llvm-profdata show` [*options*] [*filename*]
  110. DESCRIPTION
  111. ^^^^^^^^^^^
  112. :program:`llvm-profdata show` takes a profile data file and displays the
  113. information about the profile counters for this file and
  114. for any of the specified function(s).
  115. If *filename* is omitted or is ``-``, then **llvm-profdata show** reads its
  116. input from standard input.
  117. OPTIONS
  118. ^^^^^^^
  119. .. option:: -all-functions
  120. Print details for every function.
  121. .. option:: -counts
  122. Print the counter values for the displayed functions.
  123. .. option:: -function=string
  124. Print details for a function if the function's name contains the given string.
  125. .. option:: -help
  126. Print a summary of command line options.
  127. .. option:: -output=output, -o=output
  128. Specify the output file name. If *output* is ``-`` or it isn't specified,
  129. then the output is sent to standard output.
  130. .. option:: -instr (default)
  131. Specify that the input profile is an instrumentation-based profile.
  132. .. option:: -text
  133. Instruct the profile dumper to show profile counts in the text format of the
  134. instrumentation-based profile data representation. By default, the profile
  135. information is dumped in a more human readable form (also in text) with
  136. annotations.
  137. .. option:: -topn=n
  138. Instruct the profile dumper to show the top ``n`` functions with the
  139. hottest basic blocks in the summary section. By default, the topn functions
  140. are not dumped.
  141. .. option:: -sample
  142. Specify that the input profile is a sample-based profile.
  143. .. option:: -memop-sizes
  144. Show the profiled sizes of the memory intrinsic calls for shown functions.
  145. .. option:: -value-cutoff=n
  146. Show only those functions whose max count values are greater or equal to ``n``.
  147. By default, the value-cutoff is set to 0.
  148. .. option:: -list-below-cutoff
  149. Only output names of functions whose max count value are below the cutoff
  150. value.
  151. .. option:: -showcs
  152. Only show context sensitive profile counts. The default is to filter all
  153. context sensitive profile counts.
  154. .. program:: llvm-profdata overlap
  155. .. _profdata-overlap:
  156. OVERLAP
  157. -------
  158. SYNOPSIS
  159. ^^^^^^^^
  160. :program:`llvm-profdata overlap` [*options*] [*base profile file*] [*test profile file*]
  161. DESCRIPTION
  162. ^^^^^^^^^^^
  163. :program:`llvm-profdata overlap` takes two profile data files and displays the
  164. *overlap* of counter distribution between the whole files and between any of the
  165. specified functions.
  166. In this command, *overlap* is defined as follows:
  167. Suppose *base profile file* has the following counts:
  168. {c1_1, c1_2, ..., c1_n, c1_u_1, c2_u_2, ..., c2_u_s},
  169. and *test profile file* has
  170. {c2_1, c2_2, ..., c2_n, c2_v_1, c2_v_2, ..., c2_v_t}.
  171. Here c{1|2}_i (i = 1 .. n) are matched counters and c1_u_i (i = 1 .. s) and
  172. c2_v_i (i = 1 .. v) are unmatched counters (or counters only existing in)
  173. *base profile file* and *test profile file*, respectively.
  174. Let sum_1 = c1_1 + c1_2 + ... + c1_n + c1_u_1 + c2_u_2 + ... + c2_u_s, and
  175. sum_2 = c2_1 + c2_2 + ... + c2_n + c2_v_1 + c2_v_2 + ... + c2_v_t.
  176. *overlap* = min(c1_1/sum_1, c2_1/sum_2) + min(c1_2/sum_1, c2_2/sum_2) + ...
  177. + min(c1_n/sum_1, c2_n/sum_2).
  178. The result overlap distribution is a percentage number, ranging from 0.0% to
  179. 100.0%, where 0.0% means there is no overlap and 100.0% means a perfect
  180. overlap.
  181. Here is an example, if *base profile file* has counts of {400, 600}, and
  182. *test profile file* has matched counts of {60000, 40000}. The *overlap* is 80%.
  183. OPTIONS
  184. ^^^^^^^
  185. .. option:: -function=string
  186. Print details for a function if the function's name contains the given string.
  187. .. option:: -help
  188. Print a summary of command line options.
  189. .. option:: -o=output or -o output
  190. Specify the output file name. If *output* is ``-`` or it isn't specified,
  191. then the output is sent to standard output.
  192. .. option:: -value-cutoff=n
  193. Show only those functions whose max count values are greater or equal to ``n``.
  194. By default, the value-cutoff is set to max of unsigned long long.
  195. .. option:: -cs
  196. Only show overlap for the context sensitive profile counts. The default is to show
  197. non-context sensitive profile counts.
  198. EXIT STATUS
  199. -----------
  200. :program:`llvm-profdata` returns 1 if the command is omitted or is invalid,
  201. if it cannot read input files, or if there is a mismatch between their data.