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