llvm-profdata.rst 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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. EXAMPLES
  83. ^^^^^^^^
  84. Basic Usage
  85. +++++++++++
  86. Merge three profiles:
  87. ::
  88. llvm-profdata merge foo.profdata bar.profdata baz.profdata -output merged.profdata
  89. Weighted Input
  90. ++++++++++++++
  91. The input file `foo.profdata` is especially important, multiply its counts by 10:
  92. ::
  93. llvm-profdata merge -weighted-input=10,foo.profdata bar.profdata baz.profdata -output merged.profdata
  94. Exactly equivalent to the previous invocation (explicit form; useful for programmatic invocation):
  95. ::
  96. llvm-profdata merge -weighted-input=10,foo.profdata -weighted-input=1,bar.profdata -weighted-input=1,baz.profdata -output merged.profdata
  97. .. program:: llvm-profdata show
  98. .. _profdata-show:
  99. SHOW
  100. ----
  101. SYNOPSIS
  102. ^^^^^^^^
  103. :program:`llvm-profdata show` [*options*] [*filename*]
  104. DESCRIPTION
  105. ^^^^^^^^^^^
  106. :program:`llvm-profdata show` takes a profile data file and displays the
  107. information about the profile counters for this file and
  108. for any of the specified function(s).
  109. If *filename* is omitted or is ``-``, then **llvm-profdata show** reads its
  110. input from standard input.
  111. OPTIONS
  112. ^^^^^^^
  113. .. option:: -all-functions
  114. Print details for every function.
  115. .. option:: -counts
  116. Print the counter values for the displayed functions.
  117. .. option:: -function=string
  118. Print details for a function if the function's name contains the given string.
  119. .. option:: -help
  120. Print a summary of command line options.
  121. .. option:: -output=output, -o=output
  122. Specify the output file name. If *output* is ``-`` or it isn't specified,
  123. then the output is sent to standard output.
  124. .. option:: -instr (default)
  125. Specify that the input profile is an instrumentation-based profile.
  126. .. option:: -text
  127. Instruct the profile dumper to show profile counts in the text format of the
  128. instrumentation-based profile data representation. By default, the profile
  129. information is dumped in a more human readable form (also in text) with
  130. annotations.
  131. .. option:: -topn=n
  132. Instruct the profile dumper to show the top ``n`` functions with the
  133. hottest basic blocks in the summary section. By default, the topn functions
  134. are not dumped.
  135. .. option:: -sample
  136. Specify that the input profile is a sample-based profile.
  137. .. option:: -memop-sizes
  138. Show the profiled sizes of the memory intrinsic calls for shown functions.
  139. .. option:: -value-cutoff=n
  140. Show only those functions whose max count values are greater or equal to ``n``.
  141. By default, the value-cutoff is set to 0.
  142. .. option:: -list-below-cutoff
  143. Only output names of functions whose max count value are below the cutoff
  144. value.
  145. .. option:: -showcs
  146. Only show context sensitive profile counts. The default is to filter all
  147. context sensitive profile counts.
  148. .. program:: llvm-profdata overlap
  149. .. _profdata-overlap:
  150. OVERLAP
  151. -------
  152. SYNOPSIS
  153. ^^^^^^^^
  154. :program:`llvm-profdata overlap` [*options*] [*base profile file*] [*test profile file*]
  155. DESCRIPTION
  156. ^^^^^^^^^^^
  157. :program:`llvm-profdata overlap` takes two profile data files and displays the
  158. *overlap* of counter distribution between the whole files and between any of the
  159. specified functions.
  160. In this command, *overlap* is defined as follows:
  161. Suppose *base profile file* has the following counts:
  162. {c1_1, c1_2, ..., c1_n, c1_u_1, c2_u_2, ..., c2_u_s},
  163. and *test profile file* has
  164. {c2_1, c2_2, ..., c2_n, c2_v_1, c2_v_2, ..., c2_v_t}.
  165. Here c{1|2}_i (i = 1 .. n) are matched counters and c1_u_i (i = 1 .. s) and
  166. c2_v_i (i = 1 .. v) are unmatched counters (or counters only existing in)
  167. *base profile file* and *test profile file*, respectively.
  168. Let sum_1 = c1_1 + c1_2 + ... + c1_n + c1_u_1 + c2_u_2 + ... + c2_u_s, and
  169. sum_2 = c2_1 + c2_2 + ... + c2_n + c2_v_1 + c2_v_2 + ... + c2_v_t.
  170. *overlap* = min(c1_1/sum_1, c2_1/sum_2) + min(c1_2/sum_1, c2_2/sum_2) + ...
  171. + min(c1_n/sum_1, c2_n/sum_2).
  172. The result overlap distribution is a percentage number, ranging from 0.0% to
  173. 100.0%, where 0.0% means there is no overlap and 100.0% means a perfect
  174. overlap.
  175. Here is an example, if *base profile file* has counts of {400, 600}, and
  176. *test profile file* has matched counts of {60000, 40000}. The *overlap* is 80%.
  177. OPTIONS
  178. ^^^^^^^
  179. .. option:: -function=string
  180. Print details for a function if the function's name contains the given string.
  181. .. option:: -help
  182. Print a summary of command line options.
  183. .. option:: -o=output or -o output
  184. Specify the output file name. If *output* is ``-`` or it isn't specified,
  185. then the output is sent to standard output.
  186. .. option:: -value-cutoff=n
  187. Show only those functions whose max count values are greater or equal to ``n``.
  188. By default, the value-cutoff is set to max of unsigned long long.
  189. .. option:: -cs
  190. Only show overlap for the context sensitive profile counts. The default is to show
  191. non-context sensitive profile counts.
  192. EXIT STATUS
  193. -----------
  194. :program:`llvm-profdata` returns 1 if the command is omitted or is invalid,
  195. if it cannot read input files, or if there is a mismatch between their data.