blob: 75b7eddd4cf13ef2311a5a6a4355773947753910 [file] [log] [blame]
Misha Brukman69985172004-07-01 15:25:04 +00001=pod
2
3=head1 NAME
4
5opt - LLVM optimizer
6
7=head1 SYNOPSIS
8
Misha Brukmanc08937a2004-07-02 16:06:19 +00009B<opt> [I<options>] [I<filename>]
Misha Brukman69985172004-07-01 15:25:04 +000010
11=head1 DESCRIPTION
12
Reid Spencer84f82f72006-08-28 00:34:19 +000013The B<opt> command is the modular LLVM optimizer and analyzer. It takes LLVM
Gabor Greif3bd6e0d2007-07-09 11:24:05 +000014bitcode as input, runs the specified optimizations or analyses on it, and then
15outputs the optimized LLVM bitcode or the analysis results. The function of
Reid Spencer84f82f72006-08-28 00:34:19 +000016B<opt> depends on whether the B<-analyze> option is given.
Misha Brukman69985172004-07-01 15:25:04 +000017
Reid Spencer84f82f72006-08-28 00:34:19 +000018When B<-analyze> is specified, B<opt> performs various analyses of LLVM
Gabor Greif3bd6e0d2007-07-09 11:24:05 +000019bitcode. It will usually print the results on standard output, but in a few
Reid Spencer84f82f72006-08-28 00:34:19 +000020cases, it will print output to standard error or generate a file with the
21analysis output, which is usually done when the output is meant for another
22program.
Misha Brukman69985172004-07-01 15:25:04 +000023
Reid Spencer84f82f72006-08-28 00:34:19 +000024While B<-analyze> is I<not> given, B<opt> attempts to produce an optimized
Gabor Greif3bd6e0d2007-07-09 11:24:05 +000025bitcode file. The optimizations available via B<opt> depend upon what
Reid Spencer84f82f72006-08-28 00:34:19 +000026libraries were linked into it as well as any additional libraries that have
27been loaded with the B<-load> option. Use the B<-help> option to determine
28what optimizations you can use.
29
30If I<filename> is omitted from the command line or is I<->, B<opt> reads its
Gabor Greif3bd6e0d2007-07-09 11:24:05 +000031input from standard input. The input must be an LLVM bitcode file.
Misha Brukman69985172004-07-01 15:25:04 +000032
33If an output filename is not specified with the B<-o> option, B<opt>
34writes its output to the standard output.
35
36=head1 OPTIONS
37
38=over
39
40=item B<-f>
41
42Force overwrite. Normally, B<opt> will refuse to overwrite an
43output file that already exists. With this option, B<opt> will
Gabor Greif3bd6e0d2007-07-09 11:24:05 +000044overwrite the output file and replace it with new bitcode.
Misha Brukman69985172004-07-01 15:25:04 +000045
46=item B<-help>
47
Reid Spencera1981ff2007-02-03 00:21:56 +000048Print a summary of command line options.
Misha Brukman69985172004-07-01 15:25:04 +000049
50=item B<-o> I<filename>
51
52Specify the output filename.
53
Reid Spencera1981ff2007-02-03 00:21:56 +000054=item B<-{passname}>
55
56B<opt> provides the ability to run any of LLVM's optimization or analysis passes
57in any order. The B<-help> option lists all the passes available. The order in
58which the options occur on the command line are the order in which they are
59executed (within pass constraints).
60
61=item B<-std-compile-opts>
62
63This is short hand for a standard list of I<compile time optimization> passes.
64This is typically used to optimize the output from the llvm-gcc front end. It
65might be useful for other front end compilers as well. To discover the full set
66of options available, use the following command:
67
Reid Spencer463708a2007-02-03 00:32:23 +000068 llvm-as < /dev/null | opt -std-compile-opts -disable-output -debug-pass=Arguments
Reid Spencera1981ff2007-02-03 00:21:56 +000069
Reid Spencera1981ff2007-02-03 00:21:56 +000070=item B<-disable-inlining>
71
72This option is only meaningful when B<-std-compile-opts> is given. It simply
73removes the inlining pass from the standard list.
74
75=item B<-disable-opt>
76
77This option is only meaningful when B<-std-compile-opts> is given. It disables
78most, but not all, of the B<-std-compile-opts>. The ones that remain are
79B<-verify>, B<-lower-setjmp>, and B<-funcresolve>.
80
81=item B<-strip-debug>
82
83This option causes opt to strip debug information from the module before
84applying other optimizations. It is essentially the same as B<-strip> but it
85ensures that stripping of debug information is done first.
86
87=item B<-verify-each>
88
89This option causes opt to add a verify pass after every pass otherwise specified
90on the command line (including B<-verify>). This is useful for cases where it
91is suspected that a pass is creating an invalid module but it is not clear which
92pass is doing it. The combination of B<-std-compile-opts> and B<-verify-each>
93can quickly track down this kind of problem.
94
Misha Brukman69985172004-07-01 15:25:04 +000095=item B<-profile-info-file> I<filename>
96
97Specify the name of the file loaded by the -profile-loader option.
98
99=item B<-stats>
100
101Print statistics.
102
103=item B<-time-passes>
104
105Record the amount of time needed for each pass and print it to standard
106error.
107
108=item B<-debug>
109
110If this is a debug build, this option will enable debug printouts
111from passes which use the I<DEBUG()> macro. See the B<LLVM Programmer's
112Manual>, section I<#DEBUG> for more information.
113
114=item B<-load>=I<plugin>
115
Reid Spencer84f82f72006-08-28 00:34:19 +0000116Load the dynamic object I<plugin>. This object should register new optimization
117or analysis passes. Once loaded, the object will add new command line options to
118enable various optimizations or analyses. To see the new complete list of
119optimizations, use the B<-help> and B<-load> options together. For example:
Misha Brukman69985172004-07-01 15:25:04 +0000120
Reid Spencer463708a2007-02-03 00:32:23 +0000121 opt -load=plugin.so -help
Misha Brukman69985172004-07-01 15:25:04 +0000122
123=item B<-p>
124
125Print module after each transformation.
126
127=back
128
129=head1 EXIT STATUS
130
131If B<opt> succeeds, it will exit with 0. Otherwise, if an error
132occurs, it will exit with a non-zero value.
133
Misha Brukman69985172004-07-01 15:25:04 +0000134=head1 AUTHORS
135
Reid Spencercd143fc2006-03-14 05:42:07 +0000136Maintained by the LLVM Team (L<http://llvm.org>).
Misha Brukman69985172004-07-01 15:25:04 +0000137
138=cut