.\" Automatically generated by Pod::Man version 1.15 .\" Sat Jul 10 01:00:16 2004 .\" .\" Standard preamble: .\" ====================================================================== .de Sh \" Subsection heading .br .if t .Sp .ne 5 .PP \fB\\$1\fR .PP .. .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Ip \" List item .br .ie \\n(.$>=3 .ne \\$3 .el .ne 3 .IP "\\$1" \\$2 .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. | will give a .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used .\" to do unbreakable dashes and therefore won't be available. \*(C` and .\" \*(C' expand to `' in nroff, nothing in troff, for use with C<> .tr \(*W-|\(bv\*(Tr .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" If the F register is turned on, we'll generate index entries on stderr .\" for titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and .\" index entries marked with X<> in POD. Of course, you'll have to process .\" the output yourself in some meaningful fashion. .if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .\" .\" For nroff, turn off justification. Always turn off hyphenation; it .\" makes way too many mistakes in technical documents. .hy 0 .if n .na .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. .bd B 3 . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ====================================================================== .\" .IX Title "BUGPOINT 1" .TH BUGPOINT 1 "1.3" "2004-07-04" "LLVM Command Guide" .UC .SH "NAME" bugpoint \- automatic test case reduction tool .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBbugpoint\fR [\fIoptions\fR] [\fIinput \s-1LLVM\s0 ll/bc files\fR] [\fI\s-1LLVM\s0 passes\fR] \fB\*(--args\fR \&\fIprogram arguments\fR .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fBbugpoint\fR narrows down the source of problems in \s-1LLVM\s0 tools and passes. It can be used to debug three types of failures: optimizer crashes, miscompilations by optimizers, or bad native code generation (including problems in the static and \s-1JIT\s0 compilers). It aims to reduce large test cases to small, useful ones. For example, if \fBgccas\fR crashes while optimizing a file, it will identify the optimization (or combination of optimizations) that causes the crash, and reduce the file down to a small example which triggers the crash. .Sh "Design Philosophy" .IX Subsection "Design Philosophy" \&\fBbugpoint\fR is designed to be a useful tool without requiring any hooks into the \&\s-1LLVM\s0 infrastructure at all. It works with any and all \s-1LLVM\s0 passes and code generators, and does not need to \*(L"know\*(R" how they work. Because of this, it may appear to do stupid things or miss obvious simplifications. \fBbugpoint\fR is also designed to trade off programmer time for computer time in the compiler-debugging process; consequently, it may take a long period of (unattended) time to reduce a test case, but we feel it is still worth it. Note that \fBbugpoint\fR is generally very quick unless debugging a miscompilation where each test of the program (which requires executing it) takes a long time. .Sh "Automatic Debugger Selection" .IX Subsection "Automatic Debugger Selection" \&\fBbugpoint\fR reads each \fI.bc\fR or \fI.ll\fR file specified on the command line and links them together into a single module, called the test program. If any \s-1LLVM\s0 passes are specified on the command line, it runs these passes on the test program. If any of the passes crash, or if they produce malformed output (which causes the verifier to abort), \fBbugpoint\fR starts the crash debugger. .PP Otherwise, if the \fB\-output\fR option was not specified, \fBbugpoint\fR runs the test program with the C backend (which is assumed to generate good code) to generate a reference output. Once \fBbugpoint\fR has a reference output for the test program, it tries executing it with the selected code generator. If the selected code generator crashes, \fBbugpoint\fR starts the the Crash debugger entry elsewhere in this document on the code generator. Otherwise, if the resulting output differs from the reference output, it assumes the difference resulted from a code generator failure, and starts the the Code generator debugger entry elsewhere in this document. .PP Finally, if the output of the selected code generator matches the reference output, \fBbugpoint\fR runs the test program after all of the \s-1LLVM\s0 passes have been applied to it. If its output differs from the reference output, it assumes the difference resulted from a failure in one of the \s-1LLVM\s0 passes, and enters the miscompilation debugger. Otherwise, there is no problem \fBbugpoint\fR can debug. .Sh "Crash debugger" .IX Subsection "Crash debugger" If an optimizer or code generator crashes, \fBbugpoint\fR will try as hard as it can to reduce the list of passes (for optimizer crashes) and the size of the test program. First, \fBbugpoint\fR figures out which combination of optimizer passes triggers the bug. This is useful when debugging a problem exposed by \&\fBgccas\fR, for example, because it runs over 38 passes. .PP Next, \fBbugpoint\fR tries removing functions from the test program, to reduce its size. Usually it is able to reduce a test program to a single function, when debugging intraprocedural optimizations. Once the number of functions has been reduced, it attempts to delete various edges in the control flow graph, to reduce the size of the function as much as possible. Finally, \fBbugpoint\fR deletes any individual \s-1LLVM\s0 instructions whose absence does not eliminate the failure. At the end, \fBbugpoint\fR should tell you what passes crash, give you a bytecode file, and give you instructions on how to reproduce the failure with \&\fBopt\fR, \fBanalyze\fR, or \fBllc\fR. .Sh "Code generator debugger" .IX Subsection "Code generator debugger" The code generator debugger attempts to narrow down the amount of code that is being miscompiled by the selected code generator. To do this, it takes the test program and partitions it into two pieces: one piece which it compiles with the C backend (into a shared object), and one piece which it runs with either the \&\s-1JIT\s0 or the static compiler (\fBllc\fR). It uses several techniques to reduce the amount of code pushed through the \s-1LLVM\s0 code generator, to reduce the potential scope of the problem. After it is finished, it emits two bytecode files (called \&\*(L"test\*(R" [to be compiled with the code generator] and \*(L"safe\*(R" [to be compiled with the C backend], respectively), and instructions for reproducing the problem. The code generator debugger assumes that the C backend produces good code. .Sh "Miscompilation debugger" .IX Subsection "Miscompilation debugger" The miscompilation debugger works similarly to the code generator debugger. It works by splitting the test program into two pieces, running the optimizations specified on one piece, linking the two pieces back together, and then executing the result. It attempts to narrow down the list of passes to the one (or few) which are causing the miscompilation, then reduce the portion of the test program which is being miscompiled. The miscompilation debugger assumes that the selected code generator is working properly. .Sh "Advice for using bugpoint" .IX Subsection "Advice for using bugpoint" \&\fBbugpoint\fR can be a remarkably useful tool, but it sometimes works in non-obvious ways. Here are some hints and tips: .Ip "\(bu" 4 In the code generator and miscompilation debuggers, \fBbugpoint\fR only works with programs that have deterministic output. Thus, if the program outputs \f(CW\*(C`argv[0]\*(C'\fR, the date, time, or any other \*(L"random\*(R" data, \fBbugpoint\fR may misinterpret differences in these data, when output, as the result of a miscompilation. Programs should be temporarily modified to disable outputs that are likely to vary from run to run. .Ip "\(bu" 4 In the code generator and miscompilation debuggers, debugging will go faster if you manually modify the program or its inputs to reduce the runtime, but still exhibit the problem. .Ip "\(bu" 4 \&\fBbugpoint\fR is extremely useful when working on a new optimization: it helps track down regressions quickly. To avoid having to relink \fBbugpoint\fR every time you change your optimization, make \fBbugpoint\fR dynamically load your optimization by using the \fB\-load\fR option. .Ip "\(bu" 4 \&\fBbugpoint\fR can generate a lot of output and run for a long period of time. It is often useful to capture the output of the program to file. For example, in the C shell, you can type: .Sp .Vb 1 \& bugpoint ... |& tee bugpoint.log .Ve to get a copy of \fBbugpoint\fR's output in the file \fIbugpoint.log\fR, as well as on your terminal. .Ip "\(bu" 4 \&\fBbugpoint\fR cannot debug problems with the \s-1LLVM\s0 linker. If \fBbugpoint\fR crashes before you see its \f(CW\*(C`All input ok\*(C'\fR message, you might try running \f(CW\*(C`llvm\-link \&\-v\*(C'\fR on the same set of input files. If that also crashes, you may be experiencing a linker bug. .Ip "\(bu" 4 If your program is supposed to crash, \fBbugpoint\fR will be confused. One way to deal with this is to cause \fBbugpoint\fR to ignore the exit code from your program, by giving it the \fB\-check-exit-code=false\fR option. .SH "OPTIONS" .IX Header "OPTIONS" .Ip "\fB\*(--additional-so\fR \fIlibrary\fR" 4 .IX Item "additional-so library" Load the dynamic shared object \fIlibrary\fR into the test program whenever it is run. This is useful if you are debugging programs which depend on non-LLVM libraries (such as the X or curses libraries) to run. .Ip "\fB\*(--args\fR \fIprogram args\fR" 4 .IX Item "args program args" Pass all arguments specified after \-args to the test program whenever it runs. Note that if any of the \fIprogram args\fR start with a '\-', you should use: .Sp .Vb 1 \& bugpoint [bugpoint args] --args -- [program args] .Ve The \*(L"\-\-\*(R" right after the \fB\*(--args\fR option tells \fBbugpoint\fR to consider any options starting with \f(CW\*(C`\-\*(C'\fR to be part of the \fB\*(--args\fR option, not as options to \&\fBbugpoint\fR itself. .Ip "\fB\*(--tool-args\fR \fItool args\fR" 4 .IX Item "tool-args tool args" Pass all arguments specified after \-\-tool-args to the \s-1LLVM\s0 tool under test (\fBllc\fR, \fBlli\fR, etc.) whenever it runs. You should use this option in the following way: .Sp .Vb 1 \& bugpoint [bugpoint args] --tool-args -- [tool args] .Ve The \*(L"\-\-\*(R" right after the \fB\*(--tool-args\fR option tells \fBbugpoint\fR to consider any options starting with \f(CW\*(C`\-\*(C'\fR to be part of the \fB\*(--tool-args\fR option, not as options to \fBbugpoint\fR itself. (See \fB\*(--args\fR, above.) .Ip "\fB\*(--check-exit-code\fR=\fI{true,false}\fR" 4 .IX Item "check-exit-code={true,false}" Assume a non-zero exit code or core dump from the test program is a failure. Defaults to true. .Ip "\fB\*(--disable-{dce,simplifycfg}\fR" 4 .IX Item "disable-{dce,simplifycfg}" Do not run the specified passes to clean up and reduce the size of the test program. By default, \fBbugpoint\fR uses these passes internally when attempting to reduce test programs. If you're trying to find a bug in one of these passes, \&\fBbugpoint\fR may crash. .Ip "\fB\*(--help\fR" 4 .IX Item "help" Print a summary of command line options. .Ip "\fB\*(--input\fR \fIfilename\fR" 4 .IX Item "input filename" Open \fIfilename\fR and redirect the standard input of the test program, whenever it runs, to come from that file. .Ip "\fB\*(--load\fR \fIplugin\fR" 4 .IX Item "load plugin" Load the dynamic object \fIplugin\fR into \fBbugpoint\fR itself. This object should register new optimization passes. Once loaded, the object will add new command line options to enable various optimizations. To see the new complete list of optimizations, use the \fB\*(--help\fR and \fB\*(--load\fR options together; for example: .Sp .Vb 1 \& bugpoint --load myNewPass.so --help .Ve .Ip "\fB\*(--output\fR \fIfilename\fR" 4 .IX Item "output filename" Whenever the test program produces output on its standard output stream, it should match the contents of \fIfilename\fR (the \*(L"reference output\*(R"). If you do not use this option, \fBbugpoint\fR will attempt to generate a reference output by compiling the program with the C backend and running it. .Ip "\fB\*(--profile-info-file\fR \fIfilename\fR" 4 .IX Item "profile-info-file filename" Profile file loaded by \fB\*(--profile-loader\fR. .Ip "\fB\*(--run-{int,jit,llc,cbe}\fR" 4 .IX Item "run-{int,jit,llc,cbe}" Whenever the test program is compiled, \fBbugpoint\fR should generate code for it using the specified code generator. These options allow you to choose the interpreter, the \s-1JIT\s0 compiler, the static native code compiler, or the C backend, respectively. .SH "EXIT STATUS" .IX Header "EXIT STATUS" If \fBbugpoint\fR succeeds in finding a problem, it will exit with 0. Otherwise, if an error occurs, it will exit with a non-zero value. .SH "SEE ALSO" .IX Header "SEE ALSO" opt, analyze .SH "AUTHOR" .IX Header "AUTHOR" Maintained by the \s-1LLVM\s0 Team (http://llvm.cs.uiuc.edu).