opt.rst 3.9 KB

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