| Misha Brukman | 6998517 | 2004-07-01 15:25:04 +0000 | [diff] [blame] | 1 | =pod | 
|  | 2 |  | 
|  | 3 | =head1 NAME | 
|  | 4 |  | 
|  | 5 | opt - LLVM optimizer | 
|  | 6 |  | 
|  | 7 | =head1 SYNOPSIS | 
|  | 8 |  | 
| Misha Brukman | c08937a | 2004-07-02 16:06:19 +0000 | [diff] [blame] | 9 | B<opt> [I<options>] [I<filename>] | 
| Misha Brukman | 6998517 | 2004-07-01 15:25:04 +0000 | [diff] [blame] | 10 |  | 
|  | 11 | =head1 DESCRIPTION | 
|  | 12 |  | 
| Reid Spencer | 84f82f7 | 2006-08-28 00:34:19 +0000 | [diff] [blame] | 13 | The B<opt> command is the modular LLVM optimizer and analyzer.  It takes LLVM | 
| Daniel Dunbar | 6db36f3 | 2009-09-15 20:31:28 +0000 | [diff] [blame] | 14 | source files as input, runs the specified optimizations or analyses on it, and then | 
|  | 15 | outputs the optimized file or the analysis results.  The function of | 
| Reid Spencer | 84f82f7 | 2006-08-28 00:34:19 +0000 | [diff] [blame] | 16 | B<opt> depends on whether the B<-analyze> option is given. | 
| Misha Brukman | 6998517 | 2004-07-01 15:25:04 +0000 | [diff] [blame] | 17 |  | 
| Daniel Dunbar | 6db36f3 | 2009-09-15 20:31:28 +0000 | [diff] [blame] | 18 | When B<-analyze> is specified, B<opt> performs various analyses of the input | 
|  | 19 | source.  It will usually print the results on standard output, but in a few | 
|  | 20 | cases, it will print output to standard error or generate a file with the | 
|  | 21 | analysis output, which is usually done when the output is meant for another | 
|  | 22 | program. | 
| Misha Brukman | 6998517 | 2004-07-01 15:25:04 +0000 | [diff] [blame] | 23 |  | 
| Reid Spencer | 84f82f7 | 2006-08-28 00:34:19 +0000 | [diff] [blame] | 24 | While B<-analyze> is I<not> given, B<opt> attempts to produce an optimized | 
| Daniel Dunbar | 6db36f3 | 2009-09-15 20:31:28 +0000 | [diff] [blame] | 25 | output file.  The optimizations available via B<opt> depend upon what | 
| Reid Spencer | 84f82f7 | 2006-08-28 00:34:19 +0000 | [diff] [blame] | 26 | libraries were linked into it as well as any additional libraries that have | 
|  | 27 | been loaded with the B<-load> option.  Use the B<-help> option to determine | 
|  | 28 | what optimizations you can use. | 
|  | 29 |  | 
|  | 30 | If I<filename> is omitted from the command line or is I<->, B<opt> reads its | 
| Daniel Dunbar | 6db36f3 | 2009-09-15 20:31:28 +0000 | [diff] [blame] | 31 | input from standard input. Inputs can be in either the LLVM assembly language | 
|  | 32 | format (.ll) or the LLVM bitcode format (.bc). | 
| Misha Brukman | 6998517 | 2004-07-01 15:25:04 +0000 | [diff] [blame] | 33 |  | 
|  | 34 | If an output filename is not specified with the B<-o> option, B<opt> | 
|  | 35 | writes its output to the standard output. | 
|  | 36 |  | 
|  | 37 | =head1 OPTIONS | 
|  | 38 |  | 
|  | 39 | =over | 
|  | 40 |  | 
| Misha Brukman | 6998517 | 2004-07-01 15:25:04 +0000 | [diff] [blame] | 41 | =item B<-help> | 
|  | 42 |  | 
| Reid Spencer | a1981ff | 2007-02-03 00:21:56 +0000 | [diff] [blame] | 43 | Print a summary of command line options. | 
| Misha Brukman | 6998517 | 2004-07-01 15:25:04 +0000 | [diff] [blame] | 44 |  | 
|  | 45 | =item B<-o> I<filename> | 
|  | 46 |  | 
|  | 47 | Specify the output filename. | 
|  | 48 |  | 
| Daniel Dunbar | 53a99f9 | 2009-09-07 04:03:44 +0000 | [diff] [blame] | 49 | =item B<-S> | 
|  | 50 |  | 
|  | 51 | Write output in LLVM intermediate language (instead of bitcode). | 
|  | 52 |  | 
| Reid Spencer | a1981ff | 2007-02-03 00:21:56 +0000 | [diff] [blame] | 53 | =item B<-{passname}> | 
|  | 54 |  | 
|  | 55 | B<opt> provides the ability to run any of LLVM's optimization or analysis passes | 
|  | 56 | in any order. The B<-help> option lists all the passes available. The order in | 
|  | 57 | which the options occur on the command line are the order in which they are | 
|  | 58 | executed (within pass constraints). | 
|  | 59 |  | 
|  | 60 | =item B<-std-compile-opts> | 
|  | 61 |  | 
|  | 62 | This is short hand for a standard list of I<compile time optimization> passes. | 
|  | 63 | This is typically used to optimize the output from the llvm-gcc front end. It | 
|  | 64 | might be useful for other front end compilers as well. To discover the full set | 
|  | 65 | of options available, use the following command: | 
|  | 66 |  | 
| Reid Spencer | 463708a | 2007-02-03 00:32:23 +0000 | [diff] [blame] | 67 | llvm-as < /dev/null | opt -std-compile-opts -disable-output -debug-pass=Arguments | 
| Reid Spencer | a1981ff | 2007-02-03 00:21:56 +0000 | [diff] [blame] | 68 |  | 
| Reid Spencer | a1981ff | 2007-02-03 00:21:56 +0000 | [diff] [blame] | 69 | =item B<-disable-inlining> | 
|  | 70 |  | 
|  | 71 | This option is only meaningful when B<-std-compile-opts> is given. It simply | 
|  | 72 | removes the inlining pass from the standard list. | 
|  | 73 |  | 
|  | 74 | =item B<-disable-opt> | 
|  | 75 |  | 
|  | 76 | This option is only meaningful when B<-std-compile-opts> is given. It disables | 
|  | 77 | most, but not all, of the B<-std-compile-opts>. The ones that remain are | 
|  | 78 | B<-verify>, B<-lower-setjmp>, and B<-funcresolve>. | 
|  | 79 |  | 
|  | 80 | =item B<-strip-debug> | 
|  | 81 |  | 
|  | 82 | This option causes opt to strip debug information from the module before | 
|  | 83 | applying other optimizations. It is essentially the same as B<-strip> but it | 
|  | 84 | ensures that stripping of debug information is done first. | 
|  | 85 |  | 
|  | 86 | =item B<-verify-each> | 
|  | 87 |  | 
|  | 88 | This option causes opt to add a verify pass after every pass otherwise specified | 
|  | 89 | on the command line (including B<-verify>).  This is useful for cases where it | 
|  | 90 | is suspected that a pass is creating an invalid module but it is not clear which | 
|  | 91 | pass is doing it. The combination of B<-std-compile-opts> and B<-verify-each> | 
|  | 92 | can quickly track down this kind of problem. | 
|  | 93 |  | 
| Misha Brukman | 6998517 | 2004-07-01 15:25:04 +0000 | [diff] [blame] | 94 | =item B<-profile-info-file> I<filename> | 
|  | 95 |  | 
|  | 96 | Specify the name of the file loaded by the -profile-loader option. | 
|  | 97 |  | 
|  | 98 | =item B<-stats> | 
|  | 99 |  | 
|  | 100 | Print statistics. | 
|  | 101 |  | 
|  | 102 | =item B<-time-passes> | 
|  | 103 |  | 
|  | 104 | Record the amount of time needed for each pass and print it to standard | 
|  | 105 | error. | 
|  | 106 |  | 
|  | 107 | =item B<-debug> | 
|  | 108 |  | 
|  | 109 | If this is a debug build, this option will enable debug printouts | 
|  | 110 | from passes which use the I<DEBUG()> macro.  See the B<LLVM Programmer's | 
|  | 111 | Manual>, section I<#DEBUG> for more information. | 
|  | 112 |  | 
|  | 113 | =item B<-load>=I<plugin> | 
|  | 114 |  | 
| Reid Spencer | 84f82f7 | 2006-08-28 00:34:19 +0000 | [diff] [blame] | 115 | Load the dynamic object I<plugin>.  This object should register new optimization | 
|  | 116 | or analysis passes. Once loaded, the object will add new command line options to | 
|  | 117 | enable various optimizations or analyses.  To see the new complete list of | 
|  | 118 | optimizations, use the B<-help> and B<-load> options together. For example: | 
| Misha Brukman | 6998517 | 2004-07-01 15:25:04 +0000 | [diff] [blame] | 119 |  | 
| Reid Spencer | 463708a | 2007-02-03 00:32:23 +0000 | [diff] [blame] | 120 | opt -load=plugin.so -help | 
| Misha Brukman | 6998517 | 2004-07-01 15:25:04 +0000 | [diff] [blame] | 121 |  | 
|  | 122 | =item B<-p> | 
|  | 123 |  | 
|  | 124 | Print module after each transformation. | 
|  | 125 |  | 
|  | 126 | =back | 
|  | 127 |  | 
|  | 128 | =head1 EXIT STATUS | 
|  | 129 |  | 
|  | 130 | If B<opt> succeeds, it will exit with 0.  Otherwise, if an error | 
|  | 131 | occurs, it will exit with a non-zero value. | 
|  | 132 |  | 
| Misha Brukman | 6998517 | 2004-07-01 15:25:04 +0000 | [diff] [blame] | 133 | =head1 AUTHORS | 
|  | 134 |  | 
| Reid Spencer | cd143fc | 2006-03-14 05:42:07 +0000 | [diff] [blame] | 135 | Maintained by the LLVM Team (L<http://llvm.org>). | 
| Misha Brukman | 6998517 | 2004-07-01 15:25:04 +0000 | [diff] [blame] | 136 |  | 
|  | 137 | =cut |