Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 1 | bugpoint - automatic test case reduction tool |
| 2 | ============================================= |
| 3 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 4 | SYNOPSIS |
| 5 | -------- |
| 6 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 7 | **bugpoint** [*options*] [*input LLVM ll/bc files*] [*LLVM passes*] **--args** |
| 8 | *program arguments* |
| 9 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 10 | DESCRIPTION |
| 11 | ----------- |
| 12 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 13 | **bugpoint** narrows down the source of problems in LLVM tools and passes. It |
| 14 | can be used to debug three types of failures: optimizer crashes, miscompilations |
| 15 | by optimizers, or bad native code generation (including problems in the static |
| 16 | and JIT compilers). It aims to reduce large test cases to small, useful ones. |
| 17 | For more information on the design and inner workings of **bugpoint**, as well as |
| 18 | advice for using bugpoint, see *llvm/docs/Bugpoint.html* in the LLVM |
| 19 | distribution. |
| 20 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 21 | OPTIONS |
| 22 | ------- |
| 23 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 24 | **--additional-so** *library* |
| 25 | |
| 26 | Load the dynamic shared object *library* into the test program whenever it is |
| 27 | run. This is useful if you are debugging programs which depend on non-LLVM |
| 28 | libraries (such as the X or curses libraries) to run. |
| 29 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 30 | **--append-exit-code**\ =\ *{true,false}* |
| 31 | |
| 32 | Append the test programs exit code to the output file so that a change in exit |
| 33 | code is considered a test failure. Defaults to false. |
| 34 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 35 | **--args** *program args* |
| 36 | |
Dmitri Gribenko | 0215368 | 2012-11-28 21:40:54 +0000 | [diff] [blame] | 37 | Pass all arguments specified after **--args** to the test program whenever it runs. |
| 38 | Note that if any of the *program args* start with a "``-``", you should use: |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 39 | |
Dmitri Gribenko | 6bb2b5d | 2012-11-29 12:00:32 +0000 | [diff] [blame^] | 40 | .. code-block:: bash |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 41 | |
| 42 | bugpoint [bugpoint args] --args -- [program args] |
| 43 | |
Dmitri Gribenko | 0215368 | 2012-11-28 21:40:54 +0000 | [diff] [blame] | 44 | The "``--``" right after the **--args** option tells **bugpoint** to consider |
| 45 | any options starting with "``-``" to be part of the **--args** option, not as |
| 46 | options to **bugpoint** itself. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 47 | |
| 48 | **--tool-args** *tool args* |
| 49 | |
Dmitri Gribenko | 0215368 | 2012-11-28 21:40:54 +0000 | [diff] [blame] | 50 | Pass all arguments specified after **--tool-args** to the LLVM tool under test |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 51 | (**llc**, **lli**, etc.) whenever it runs. You should use this option in the |
| 52 | following way: |
| 53 | |
Dmitri Gribenko | 6bb2b5d | 2012-11-29 12:00:32 +0000 | [diff] [blame^] | 54 | .. code-block:: bash |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 55 | |
| 56 | bugpoint [bugpoint args] --tool-args -- [tool args] |
| 57 | |
Dmitri Gribenko | 0215368 | 2012-11-28 21:40:54 +0000 | [diff] [blame] | 58 | The "``--``" right after the **--tool-args** option tells **bugpoint** to |
| 59 | consider any options starting with "``-``" to be part of the **--tool-args** |
| 60 | option, not as options to **bugpoint** itself. (See **--args**, above.) |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 61 | |
| 62 | **--safe-tool-args** *tool args* |
| 63 | |
| 64 | Pass all arguments specified after **--safe-tool-args** to the "safe" execution |
| 65 | tool. |
| 66 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 67 | **--gcc-tool-args** *gcc tool args* |
| 68 | |
| 69 | Pass all arguments specified after **--gcc-tool-args** to the invocation of |
| 70 | **gcc**. |
| 71 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 72 | **--opt-args** *opt args* |
| 73 | |
| 74 | Pass all arguments specified after **--opt-args** to the invocation of **opt**. |
| 75 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 76 | **--disable-{dce,simplifycfg}** |
| 77 | |
| 78 | Do not run the specified passes to clean up and reduce the size of the test |
| 79 | program. By default, **bugpoint** uses these passes internally when attempting to |
| 80 | reduce test programs. If you're trying to find a bug in one of these passes, |
| 81 | **bugpoint** may crash. |
| 82 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 83 | **--enable-valgrind** |
| 84 | |
| 85 | Use valgrind to find faults in the optimization phase. This will allow |
| 86 | bugpoint to find otherwise asymptomatic problems caused by memory |
| 87 | mis-management. |
| 88 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 89 | **-find-bugs** |
| 90 | |
| 91 | Continually randomize the specified passes and run them on the test program |
| 92 | until a bug is found or the user kills **bugpoint**. |
| 93 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 94 | **-help** |
| 95 | |
| 96 | Print a summary of command line options. |
| 97 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 98 | **--input** *filename* |
| 99 | |
| 100 | Open *filename* and redirect the standard input of the test program, whenever |
| 101 | it runs, to come from that file. |
| 102 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 103 | **--load** *plugin* |
| 104 | |
| 105 | Load the dynamic object *plugin* into **bugpoint** itself. This object should |
| 106 | register new optimization passes. Once loaded, the object will add new command |
| 107 | line options to enable various optimizations. To see the new complete list of |
| 108 | optimizations, use the **-help** and **--load** options together; for example: |
| 109 | |
| 110 | |
Dmitri Gribenko | 6bb2b5d | 2012-11-29 12:00:32 +0000 | [diff] [blame^] | 111 | .. code-block:: bash |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 112 | |
| 113 | bugpoint --load myNewPass.so -help |
| 114 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 115 | **--mlimit** *megabytes* |
| 116 | |
| 117 | Specifies an upper limit on memory usage of the optimization and codegen. Set |
| 118 | to zero to disable the limit. |
| 119 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 120 | **--output** *filename* |
| 121 | |
| 122 | Whenever the test program produces output on its standard output stream, it |
| 123 | should match the contents of *filename* (the "reference output"). If you |
| 124 | do not use this option, **bugpoint** will attempt to generate a reference output |
| 125 | by compiling the program with the "safe" backend and running it. |
| 126 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 127 | **--profile-info-file** *filename* |
| 128 | |
| 129 | Profile file loaded by **--profile-loader**. |
| 130 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 131 | **--run-{int,jit,llc,custom}** |
| 132 | |
| 133 | Whenever the test program is compiled, **bugpoint** should generate code for it |
| 134 | using the specified code generator. These options allow you to choose the |
| 135 | interpreter, the JIT compiler, the static native code compiler, or a |
| 136 | custom command (see **--exec-command**) respectively. |
| 137 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 138 | **--safe-{llc,custom}** |
| 139 | |
| 140 | When debugging a code generator, **bugpoint** should use the specified code |
| 141 | generator as the "safe" code generator. This is a known-good code generator |
| 142 | used to generate the "reference output" if it has not been provided, and to |
| 143 | compile portions of the program that as they are excluded from the testcase. |
| 144 | These options allow you to choose the |
| 145 | static native code compiler, or a custom command, (see **--exec-command**) |
| 146 | respectively. The interpreter and the JIT backends cannot currently |
| 147 | be used as the "safe" backends. |
| 148 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 149 | **--exec-command** *command* |
| 150 | |
| 151 | This option defines the command to use with the **--run-custom** and |
| 152 | **--safe-custom** options to execute the bitcode testcase. This can |
| 153 | be useful for cross-compilation. |
| 154 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 155 | **--compile-command** *command* |
| 156 | |
| 157 | This option defines the command to use with the **--compile-custom** |
| 158 | option to compile the bitcode testcase. This can be useful for |
| 159 | testing compiler output without running any link or execute stages. To |
| 160 | generate a reduced unit test, you may add CHECK directives to the |
| 161 | testcase and pass the name of an executable compile-command script in this form: |
| 162 | |
Dmitri Gribenko | 0d887a0 | 2012-06-12 15:45:07 +0000 | [diff] [blame] | 163 | .. code-block:: sh |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 164 | |
| 165 | #!/bin/sh |
| 166 | llc "$@" |
| 167 | not FileCheck [bugpoint input file].ll < bugpoint-test-program.s |
| 168 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 169 | This script will "fail" as long as FileCheck passes. So the result |
| 170 | will be the minimum bitcode that passes FileCheck. |
| 171 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 172 | **--safe-path** *path* |
| 173 | |
| 174 | This option defines the path to the command to execute with the |
| 175 | **--safe-{int,jit,llc,custom}** |
| 176 | option. |
| 177 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 178 | EXIT STATUS |
| 179 | ----------- |
| 180 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 181 | If **bugpoint** succeeds in finding a problem, it will exit with 0. Otherwise, |
| 182 | if an error occurs, it will exit with a non-zero value. |
| 183 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 184 | SEE ALSO |
| 185 | -------- |
| 186 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 187 | opt|opt |