blob: a6c18b18722eb23d5dc1bbcc4aa4f93fbee87ef2 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001=pod
2
3=head1 NAME
4
5opt - LLVM optimizer
6
7=head1 SYNOPSIS
8
9B<opt> [I<options>] [I<filename>]
10
11=head1 DESCRIPTION
12
13The B<opt> command is the modular LLVM optimizer and analyzer. It takes LLVM
14bitcode as input, runs the specified optimizations or analyses on it, and then
15outputs the optimized LLVM bitcode or the analysis results. The function of
16B<opt> depends on whether the B<-analyze> option is given.
17
18When B<-analyze> is specified, B<opt> performs various analyses of LLVM
19bitcode. It will usually print the results on standard output, but in a few
20cases, 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.
23
24While B<-analyze> is I<not> given, B<opt> attempts to produce an optimized
25bitcode file. The optimizations available via B<opt> depend upon what
26libraries 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
31input from standard input. The input must be an LLVM bitcode file.
32
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
Dan Gohman87489cf2009-08-25 15:54:01 +000042Enable binary output on terminals. Normally, B<opt> will refuse to
43write raw bitcode output if the output stream is a terminal. With this option,
44B<opt> will write raw bitcode regardless of the output device.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000045
46=item B<-help>
47
48Print a summary of command line options.
49
50=item B<-o> I<filename>
51
52Specify the output filename.
53
Daniel Dunbar1c40a1e2009-09-07 04:03:44 +000054=item B<-S>
55
56Write output in LLVM intermediate language (instead of bitcode).
57
Dan Gohmanf17a25c2007-07-18 16:29:46 +000058=item B<-{passname}>
59
60B<opt> provides the ability to run any of LLVM's optimization or analysis passes
61in any order. The B<-help> option lists all the passes available. The order in
62which the options occur on the command line are the order in which they are
63executed (within pass constraints).
64
65=item B<-std-compile-opts>
66
67This is short hand for a standard list of I<compile time optimization> passes.
68This is typically used to optimize the output from the llvm-gcc front end. It
69might be useful for other front end compilers as well. To discover the full set
70of options available, use the following command:
71
72 llvm-as < /dev/null | opt -std-compile-opts -disable-output -debug-pass=Arguments
73
74=item B<-disable-inlining>
75
76This option is only meaningful when B<-std-compile-opts> is given. It simply
77removes the inlining pass from the standard list.
78
79=item B<-disable-opt>
80
81This option is only meaningful when B<-std-compile-opts> is given. It disables
82most, but not all, of the B<-std-compile-opts>. The ones that remain are
83B<-verify>, B<-lower-setjmp>, and B<-funcresolve>.
84
85=item B<-strip-debug>
86
87This option causes opt to strip debug information from the module before
88applying other optimizations. It is essentially the same as B<-strip> but it
89ensures that stripping of debug information is done first.
90
91=item B<-verify-each>
92
93This option causes opt to add a verify pass after every pass otherwise specified
94on the command line (including B<-verify>). This is useful for cases where it
95is suspected that a pass is creating an invalid module but it is not clear which
96pass is doing it. The combination of B<-std-compile-opts> and B<-verify-each>
97can quickly track down this kind of problem.
98
99=item B<-profile-info-file> I<filename>
100
101Specify the name of the file loaded by the -profile-loader option.
102
103=item B<-stats>
104
105Print statistics.
106
107=item B<-time-passes>
108
109Record the amount of time needed for each pass and print it to standard
110error.
111
112=item B<-debug>
113
114If this is a debug build, this option will enable debug printouts
115from passes which use the I<DEBUG()> macro. See the B<LLVM Programmer's
116Manual>, section I<#DEBUG> for more information.
117
118=item B<-load>=I<plugin>
119
120Load the dynamic object I<plugin>. This object should register new optimization
121or analysis passes. Once loaded, the object will add new command line options to
122enable various optimizations or analyses. To see the new complete list of
123optimizations, use the B<-help> and B<-load> options together. For example:
124
125 opt -load=plugin.so -help
126
127=item B<-p>
128
129Print module after each transformation.
130
131=back
132
133=head1 EXIT STATUS
134
135If B<opt> succeeds, it will exit with 0. Otherwise, if an error
136occurs, it will exit with a non-zero value.
137
138=head1 AUTHORS
139
140Maintained by the LLVM Team (L<http://llvm.org>).
141
142=cut