111 lines · plain
1opt - LLVM optimizer2====================3 4.. program:: opt5 6SYNOPSIS7--------8 9:program:`opt` [*options*] [*filename*]10 11DESCRIPTION12-----------13 14The :program:`opt` command is the modular LLVM optimizer and analyzer. It takes15LLVM source files as input, runs the specified optimizations or analyses on it,16and then outputs the optimized file. The optimizations available via17:program:`opt` depend upon what libraries were linked into it as well as any18additional libraries that have been loaded with the :option:`-load` option. Use19the :option:`-help` option to determine what optimizations you can use.20 21If ``filename`` is omitted from the command line or is "``-``", :program:`opt`22reads its input from standard input. Inputs can be in either the LLVM assembly23language format (``.ll``) or the LLVM bitcode format (``.bc``).24 25If an output filename is not specified with the :option:`-o` option,26:program:`opt` writes its output to the standard output.27 28OPTIONS29-------30 31.. option:: -f32 33 Enable binary output on terminals. Normally, :program:`opt` will refuse to34 write raw bitcode output if the output stream is a terminal. With this option,35 :program:`opt` will write raw bitcode regardless of the output device.36 37.. option:: -help38 39 Print a summary of command line options.40 41.. option:: -o <filename>42 43 Specify the output filename.44 45.. option:: -S46 47 Write output in LLVM intermediate language (instead of bitcode).48 49.. option:: -passes=<string>50 51 A textual (comma-separated) description of the pass pipeline,52 e.g., ``-passes="sroa,instcombine"``. See53 `invoking opt <../NewPassManager.html#invoking-opt>`_ for more details on the54 pass pipeline syntax.55 56.. option:: -strip-debug57 58 This option causes opt to strip debug information from the module before59 applying other optimizations. It is essentially the same as `-strip`60 but it ensures that stripping of debug information is done first.61 62.. option:: -verify-each63 64 This option causes opt to add a verify pass after every pass otherwise65 specified on the command line (including `-verify`). This is useful66 for cases where it is suspected that a pass is creating an invalid module but67 it is not clear which pass is doing it.68 69.. option:: -stats70 71 Print statistics.72 73.. option:: --save-stats, --save-stats=cwd, --save-stats=obj74 75 Save LLVM statistics to a file in the current directory76 (:option:`--save-stats`/"--save-stats=cwd") or the directory77 of the output file ("--save-stats=obj") in JSON format.78 79.. option:: -time-passes80 81 Record the amount of time needed for each pass and print it to standard82 error.83 84.. option:: -debug85 86 If this is a debug build, this option will enable debug printouts from passes87 which use the ``LLVM_DEBUG()`` macro. See the `LLVM Programmer's Manual88 <../ProgrammersManual.html>`_, section ``#DEBUG`` for more information.89 90.. option:: -load=<plugin>91 92 Load the dynamic object ``plugin``. This object should register new93 optimization or analysis passes. Once loaded, the object will add new command94 line options to enable various optimizations or analyses. To see the new95 complete list of optimizations, use the :option:`-help` and :option:`-load`96 options together. For example:97 98 .. code-block:: sh99 100 opt -load=plugin.so -help101 102.. option:: -print-passes103 104 Print all available passes and exit.105 106EXIT STATUS107-----------108 109If :program:`opt` succeeds, it will exit with 0. Otherwise, if an error110occurs, it will exit with a non-zero value.111