opt.rst 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. opt - LLVM optimizer
  2. ====================
  3. SYNOPSIS
  4. --------
  5. :program:`opt` [*options*] [*filename*]
  6. DESCRIPTION
  7. -----------
  8. The :program:`opt` command is the modular LLVM optimizer and analyzer. It
  9. takes LLVM source files as input, runs the specified optimizations or analyses
  10. on it, and then outputs the optimized file or the analysis results. The
  11. function of :program:`opt` depends on whether the :option:`-analyze` option is
  12. given.
  13. When :option:`-analyze` is specified, :program:`opt` performs various analyses
  14. of the input source. It will usually print the results on standard output, but
  15. in a few cases, it will print output to standard error or generate a file with
  16. the analysis output, which is usually done when the output is meant for another
  17. program.
  18. While :option:`-analyze` is *not* given, :program:`opt` attempts to produce an
  19. optimized output file. The optimizations available via :program:`opt` depend
  20. upon what libraries were linked into it as well as any additional libraries
  21. that have been loaded with the :option:`-load` option. Use the :option:`-help`
  22. option to determine what optimizations you can use.
  23. If ``filename`` is omitted from the command line or is "``-``", :program:`opt`
  24. reads its input from standard input. Inputs can be in either the LLVM assembly
  25. language format (``.ll``) or the LLVM bitcode format (``.bc``).
  26. If an output filename is not specified with the :option:`-o` option,
  27. :program:`opt` writes its output to the standard output.
  28. OPTIONS
  29. -------
  30. .. option:: -f
  31. Enable binary output on terminals. Normally, :program:`opt` will refuse to
  32. write raw bitcode output if the output stream is a terminal. With this option,
  33. :program:`opt` will write raw bitcode regardless of the output device.
  34. .. option:: -help
  35. Print a summary of command line options.
  36. .. option:: -o <filename>
  37. Specify the output filename.
  38. .. option:: -S
  39. Write output in LLVM intermediate language (instead of bitcode).
  40. .. option:: -{passname}
  41. :program:`opt` provides the ability to run any of LLVM's optimization or
  42. analysis passes in any order. The :option:`-help` option lists all the passes
  43. available. The order in which the options occur on the command line are the
  44. order in which they are executed (within pass constraints).
  45. .. option:: -disable-inlining
  46. This option simply removes the inlining pass from the standard list.
  47. .. option:: -disable-opt
  48. This option is only meaningful when :option:`-std-link-opts` is given. It
  49. disables most passes.
  50. .. option:: -strip-debug
  51. This option causes opt to strip debug information from the module before
  52. applying other optimizations. It is essentially the same as :option:`-strip`
  53. but it ensures that stripping of debug information is done first.
  54. .. option:: -verify-each
  55. This option causes opt to add a verify pass after every pass otherwise
  56. specified on the command line (including :option:`-verify`). This is useful
  57. for cases where it is suspected that a pass is creating an invalid module but
  58. it is not clear which pass is doing it.
  59. .. option:: -stats
  60. Print statistics.
  61. .. option:: -time-passes
  62. Record the amount of time needed for each pass and print it to standard
  63. error.
  64. .. option:: -debug
  65. If this is a debug build, this option will enable debug printouts from passes
  66. which use the ``DEBUG()`` macro. See the `LLVM Programmer's Manual
  67. <../ProgrammersManual.html>`_, section ``#DEBUG`` for more information.
  68. .. option:: -load=<plugin>
  69. Load the dynamic object ``plugin``. This object should register new
  70. optimization or analysis passes. Once loaded, the object will add new command
  71. line options to enable various optimizations or analyses. To see the new
  72. complete list of optimizations, use the :option:`-help` and :option:`-load`
  73. options together. For example:
  74. .. code-block:: sh
  75. opt -load=plugin.so -help
  76. .. option:: -p
  77. Print module after each transformation.
  78. EXIT STATUS
  79. -----------
  80. If :program:`opt` succeeds, it will exit with 0. Otherwise, if an error
  81. occurs, it will exit with a non-zero value.