Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 1 | opt - LLVM optimizer |
| 2 | ==================== |
| 3 | |
| 4 | |
| 5 | SYNOPSIS |
| 6 | -------- |
| 7 | |
| 8 | |
| 9 | **opt** [*options*] [*filename*] |
| 10 | |
| 11 | |
| 12 | DESCRIPTION |
| 13 | ----------- |
| 14 | |
| 15 | |
| 16 | The **opt** command is the modular LLVM optimizer and analyzer. It takes LLVM |
| 17 | source files as input, runs the specified optimizations or analyses on it, and then |
| 18 | outputs the optimized file or the analysis results. The function of |
| 19 | **opt** depends on whether the **-analyze** option is given. |
| 20 | |
| 21 | When **-analyze** is specified, **opt** performs various analyses of the input |
| 22 | source. It will usually print the results on standard output, but in a few |
| 23 | cases, it will print output to standard error or generate a file with the |
| 24 | analysis output, which is usually done when the output is meant for another |
| 25 | program. |
| 26 | |
| 27 | While **-analyze** is *not* given, **opt** attempts to produce an optimized |
| 28 | output file. The optimizations available via **opt** depend upon what |
| 29 | libraries were linked into it as well as any additional libraries that have |
| 30 | been loaded with the **-load** option. Use the **-help** option to determine |
| 31 | what optimizations you can use. |
| 32 | |
| 33 | If *filename* is omitted from the command line or is *-*, **opt** reads its |
| 34 | input from standard input. Inputs can be in either the LLVM assembly language |
| 35 | format (.ll) or the LLVM bitcode format (.bc). |
| 36 | |
| 37 | If an output filename is not specified with the **-o** option, **opt** |
| 38 | writes its output to the standard output. |
| 39 | |
| 40 | |
| 41 | OPTIONS |
| 42 | ------- |
| 43 | |
| 44 | |
| 45 | |
| 46 | **-f** |
| 47 | |
| 48 | Enable binary output on terminals. Normally, **opt** will refuse to |
| 49 | write raw bitcode output if the output stream is a terminal. With this option, |
| 50 | **opt** will write raw bitcode regardless of the output device. |
| 51 | |
| 52 | |
| 53 | |
| 54 | **-help** |
| 55 | |
| 56 | Print a summary of command line options. |
| 57 | |
| 58 | |
| 59 | |
| 60 | **-o** *filename* |
| 61 | |
| 62 | Specify the output filename. |
| 63 | |
| 64 | |
| 65 | |
| 66 | **-S** |
| 67 | |
| 68 | Write output in LLVM intermediate language (instead of bitcode). |
| 69 | |
| 70 | |
| 71 | |
| 72 | **-{passname}** |
| 73 | |
| 74 | **opt** provides the ability to run any of LLVM's optimization or analysis passes |
| 75 | in any order. The **-help** option lists all the passes available. The order in |
| 76 | which the options occur on the command line are the order in which they are |
| 77 | executed (within pass constraints). |
| 78 | |
| 79 | |
| 80 | |
| 81 | **-std-compile-opts** |
| 82 | |
| 83 | This is short hand for a standard list of *compile time optimization* passes. |
| 84 | This is typically used to optimize the output from the llvm-gcc front end. It |
| 85 | might be useful for other front end compilers as well. To discover the full set |
| 86 | of options available, use the following command: |
| 87 | |
| 88 | |
Dmitri Gribenko | 0d887a0 | 2012-06-12 15:45:07 +0000 | [diff] [blame] | 89 | .. code-block:: sh |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 90 | |
| 91 | llvm-as < /dev/null | opt -std-compile-opts -disable-output -debug-pass=Arguments |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | **-disable-inlining** |
| 97 | |
| 98 | This option is only meaningful when **-std-compile-opts** is given. It simply |
| 99 | removes the inlining pass from the standard list. |
| 100 | |
| 101 | |
| 102 | |
| 103 | **-disable-opt** |
| 104 | |
| 105 | This option is only meaningful when **-std-compile-opts** is given. It disables |
| 106 | most, but not all, of the **-std-compile-opts**. The ones that remain are |
| 107 | **-verify**, **-lower-setjmp**, and **-funcresolve**. |
| 108 | |
| 109 | |
| 110 | |
| 111 | **-strip-debug** |
| 112 | |
| 113 | This option causes opt to strip debug information from the module before |
| 114 | applying other optimizations. It is essentially the same as **-strip** but it |
| 115 | ensures that stripping of debug information is done first. |
| 116 | |
| 117 | |
| 118 | |
| 119 | **-verify-each** |
| 120 | |
| 121 | This option causes opt to add a verify pass after every pass otherwise specified |
| 122 | on the command line (including **-verify**). This is useful for cases where it |
| 123 | is suspected that a pass is creating an invalid module but it is not clear which |
| 124 | pass is doing it. The combination of **-std-compile-opts** and **-verify-each** |
| 125 | can quickly track down this kind of problem. |
| 126 | |
| 127 | |
| 128 | |
| 129 | **-profile-info-file** *filename* |
| 130 | |
| 131 | Specify the name of the file loaded by the -profile-loader option. |
| 132 | |
| 133 | |
| 134 | |
| 135 | **-stats** |
| 136 | |
| 137 | Print statistics. |
| 138 | |
| 139 | |
| 140 | |
| 141 | **-time-passes** |
| 142 | |
| 143 | Record the amount of time needed for each pass and print it to standard |
| 144 | error. |
| 145 | |
| 146 | |
| 147 | |
| 148 | **-debug** |
| 149 | |
| 150 | If this is a debug build, this option will enable debug printouts |
| 151 | from passes which use the *DEBUG()* macro. See the **LLVM Programmer's |
| 152 | Manual**, section *#DEBUG* for more information. |
| 153 | |
| 154 | |
| 155 | |
| 156 | **-load**\ =\ *plugin* |
| 157 | |
| 158 | Load the dynamic object *plugin*. This object should register new optimization |
| 159 | or analysis passes. Once loaded, the object will add new command line options to |
| 160 | enable various optimizations or analyses. To see the new complete list of |
| 161 | optimizations, use the **-help** and **-load** options together. For example: |
| 162 | |
| 163 | |
Dmitri Gribenko | 0d887a0 | 2012-06-12 15:45:07 +0000 | [diff] [blame] | 164 | .. code-block:: sh |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 165 | |
| 166 | opt -load=plugin.so -help |
| 167 | |
| 168 | |
| 169 | |
| 170 | |
| 171 | **-p** |
| 172 | |
| 173 | Print module after each transformation. |
| 174 | |
| 175 | |
| 176 | |
| 177 | |
| 178 | EXIT STATUS |
| 179 | ----------- |
| 180 | |
| 181 | |
| 182 | If **opt** succeeds, it will exit with 0. Otherwise, if an error |
| 183 | occurs, it will exit with a non-zero value. |