18f4a8a63SDaniel Dunbarbugpoint - automatic test case reduction tool 28f4a8a63SDaniel Dunbar============================================= 38f4a8a63SDaniel Dunbar 4a056684cSJames Henderson.. program:: bugpoint 5a056684cSJames Henderson 68f4a8a63SDaniel DunbarSYNOPSIS 78f4a8a63SDaniel Dunbar-------- 88f4a8a63SDaniel Dunbar 98f4a8a63SDaniel Dunbar**bugpoint** [*options*] [*input LLVM ll/bc files*] [*LLVM passes*] **--args** 108f4a8a63SDaniel Dunbar*program arguments* 118f4a8a63SDaniel Dunbar 128f4a8a63SDaniel DunbarDESCRIPTION 138f4a8a63SDaniel Dunbar----------- 148f4a8a63SDaniel Dunbar 158f4a8a63SDaniel Dunbar**bugpoint** narrows down the source of problems in LLVM tools and passes. It 168f4a8a63SDaniel Dunbarcan be used to debug three types of failures: optimizer crashes, miscompilations 178f4a8a63SDaniel Dunbarby optimizers, or bad native code generation (including problems in the static 188f4a8a63SDaniel Dunbarand JIT compilers). It aims to reduce large test cases to small, useful ones. 198f4a8a63SDaniel DunbarFor more information on the design and inner workings of **bugpoint**, as well as 20c28b4955SSean Silvaadvice for using bugpoint, see :doc:`/Bugpoint` in the LLVM 218f4a8a63SDaniel Dunbardistribution. 228f4a8a63SDaniel Dunbar 238f4a8a63SDaniel DunbarOPTIONS 248f4a8a63SDaniel Dunbar------- 258f4a8a63SDaniel Dunbar 268f4a8a63SDaniel Dunbar**--additional-so** *library* 278f4a8a63SDaniel Dunbar 288f4a8a63SDaniel Dunbar Load the dynamic shared object *library* into the test program whenever it is 298f4a8a63SDaniel Dunbar run. This is useful if you are debugging programs which depend on non-LLVM 308f4a8a63SDaniel Dunbar libraries (such as the X or curses libraries) to run. 318f4a8a63SDaniel Dunbar 328f4a8a63SDaniel Dunbar**--append-exit-code**\ =\ *{true,false}* 338f4a8a63SDaniel Dunbar 348f4a8a63SDaniel Dunbar Append the test programs exit code to the output file so that a change in exit 358f4a8a63SDaniel Dunbar code is considered a test failure. Defaults to false. 368f4a8a63SDaniel Dunbar 378f4a8a63SDaniel Dunbar**--args** *program args* 388f4a8a63SDaniel Dunbar 395cb3f109SDmitri Gribenko Pass all arguments specified after **--args** to the test program whenever it runs. 405cb3f109SDmitri Gribenko Note that if any of the *program args* start with a "``-``", you should use: 418f4a8a63SDaniel Dunbar 42194d3685SDmitri Gribenko .. code-block:: bash 438f4a8a63SDaniel Dunbar 448f4a8a63SDaniel Dunbar bugpoint [bugpoint args] --args -- [program args] 458f4a8a63SDaniel Dunbar 465cb3f109SDmitri Gribenko The "``--``" right after the **--args** option tells **bugpoint** to consider 475cb3f109SDmitri Gribenko any options starting with "``-``" to be part of the **--args** option, not as 485cb3f109SDmitri Gribenko options to **bugpoint** itself. 498f4a8a63SDaniel Dunbar 508f4a8a63SDaniel Dunbar**--tool-args** *tool args* 518f4a8a63SDaniel Dunbar 525cb3f109SDmitri Gribenko Pass all arguments specified after **--tool-args** to the LLVM tool under test 538f4a8a63SDaniel Dunbar (**llc**, **lli**, etc.) whenever it runs. You should use this option in the 548f4a8a63SDaniel Dunbar following way: 558f4a8a63SDaniel Dunbar 56194d3685SDmitri Gribenko .. code-block:: bash 578f4a8a63SDaniel Dunbar 588f4a8a63SDaniel Dunbar bugpoint [bugpoint args] --tool-args -- [tool args] 598f4a8a63SDaniel Dunbar 605cb3f109SDmitri Gribenko The "``--``" right after the **--tool-args** option tells **bugpoint** to 615cb3f109SDmitri Gribenko consider any options starting with "``-``" to be part of the **--tool-args** 625cb3f109SDmitri Gribenko option, not as options to **bugpoint** itself. (See **--args**, above.) 638f4a8a63SDaniel Dunbar 648f4a8a63SDaniel Dunbar**--safe-tool-args** *tool args* 658f4a8a63SDaniel Dunbar 668f4a8a63SDaniel Dunbar Pass all arguments specified after **--safe-tool-args** to the "safe" execution 678f4a8a63SDaniel Dunbar tool. 688f4a8a63SDaniel Dunbar 698f4a8a63SDaniel Dunbar**--gcc-tool-args** *gcc tool args* 708f4a8a63SDaniel Dunbar 718f4a8a63SDaniel Dunbar Pass all arguments specified after **--gcc-tool-args** to the invocation of 728f4a8a63SDaniel Dunbar **gcc**. 738f4a8a63SDaniel Dunbar 748f4a8a63SDaniel Dunbar**--opt-args** *opt args* 758f4a8a63SDaniel Dunbar 768f4a8a63SDaniel Dunbar Pass all arguments specified after **--opt-args** to the invocation of **opt**. 778f4a8a63SDaniel Dunbar 788f4a8a63SDaniel Dunbar**--disable-{dce,simplifycfg}** 798f4a8a63SDaniel Dunbar 808f4a8a63SDaniel Dunbar Do not run the specified passes to clean up and reduce the size of the test 818f4a8a63SDaniel Dunbar program. By default, **bugpoint** uses these passes internally when attempting to 828f4a8a63SDaniel Dunbar reduce test programs. If you're trying to find a bug in one of these passes, 838f4a8a63SDaniel Dunbar **bugpoint** may crash. 848f4a8a63SDaniel Dunbar 858f4a8a63SDaniel Dunbar**--enable-valgrind** 868f4a8a63SDaniel Dunbar 878f4a8a63SDaniel Dunbar Use valgrind to find faults in the optimization phase. This will allow 888f4a8a63SDaniel Dunbar bugpoint to find otherwise asymptomatic problems caused by memory 898f4a8a63SDaniel Dunbar mis-management. 908f4a8a63SDaniel Dunbar 918f4a8a63SDaniel Dunbar**-find-bugs** 928f4a8a63SDaniel Dunbar 938f4a8a63SDaniel Dunbar Continually randomize the specified passes and run them on the test program 948f4a8a63SDaniel Dunbar until a bug is found or the user kills **bugpoint**. 958f4a8a63SDaniel Dunbar 968f4a8a63SDaniel Dunbar**-help** 978f4a8a63SDaniel Dunbar 988f4a8a63SDaniel Dunbar Print a summary of command line options. 998f4a8a63SDaniel Dunbar 1008f4a8a63SDaniel Dunbar**--input** *filename* 1018f4a8a63SDaniel Dunbar 1028f4a8a63SDaniel Dunbar Open *filename* and redirect the standard input of the test program, whenever 1038f4a8a63SDaniel Dunbar it runs, to come from that file. 1048f4a8a63SDaniel Dunbar 1058f4a8a63SDaniel Dunbar**--load** *plugin* 1068f4a8a63SDaniel Dunbar 1078f4a8a63SDaniel Dunbar Load the dynamic object *plugin* into **bugpoint** itself. This object should 1088f4a8a63SDaniel Dunbar register new optimization passes. Once loaded, the object will add new command 1098f4a8a63SDaniel Dunbar line options to enable various optimizations. To see the new complete list of 1108f4a8a63SDaniel Dunbar optimizations, use the **-help** and **--load** options together; for example: 1118f4a8a63SDaniel Dunbar 112194d3685SDmitri Gribenko .. code-block:: bash 1138f4a8a63SDaniel Dunbar 1148f4a8a63SDaniel Dunbar bugpoint --load myNewPass.so -help 1158f4a8a63SDaniel Dunbar 1168f4a8a63SDaniel Dunbar**--mlimit** *megabytes* 1178f4a8a63SDaniel Dunbar 1188f4a8a63SDaniel Dunbar Specifies an upper limit on memory usage of the optimization and codegen. Set 1198f4a8a63SDaniel Dunbar to zero to disable the limit. 1208f4a8a63SDaniel Dunbar 1218f4a8a63SDaniel Dunbar**--output** *filename* 1228f4a8a63SDaniel Dunbar 1238f4a8a63SDaniel Dunbar Whenever the test program produces output on its standard output stream, it 1248f4a8a63SDaniel Dunbar should match the contents of *filename* (the "reference output"). If you 1258f4a8a63SDaniel Dunbar do not use this option, **bugpoint** will attempt to generate a reference output 1268f4a8a63SDaniel Dunbar by compiling the program with the "safe" backend and running it. 1278f4a8a63SDaniel Dunbar 1288f4a8a63SDaniel Dunbar**--run-{int,jit,llc,custom}** 1298f4a8a63SDaniel Dunbar 1308f4a8a63SDaniel Dunbar Whenever the test program is compiled, **bugpoint** should generate code for it 1318f4a8a63SDaniel Dunbar using the specified code generator. These options allow you to choose the 1328f4a8a63SDaniel Dunbar interpreter, the JIT compiler, the static native code compiler, or a 1338f4a8a63SDaniel Dunbar custom command (see **--exec-command**) respectively. 1348f4a8a63SDaniel Dunbar 1358f4a8a63SDaniel Dunbar**--safe-{llc,custom}** 1368f4a8a63SDaniel Dunbar 1378f4a8a63SDaniel Dunbar When debugging a code generator, **bugpoint** should use the specified code 1388f4a8a63SDaniel Dunbar generator as the "safe" code generator. This is a known-good code generator 1398f4a8a63SDaniel Dunbar used to generate the "reference output" if it has not been provided, and to 1408f4a8a63SDaniel Dunbar compile portions of the program that as they are excluded from the testcase. 1418f4a8a63SDaniel Dunbar These options allow you to choose the 1428f4a8a63SDaniel Dunbar static native code compiler, or a custom command, (see **--exec-command**) 1438f4a8a63SDaniel Dunbar respectively. The interpreter and the JIT backends cannot currently 1448f4a8a63SDaniel Dunbar be used as the "safe" backends. 1458f4a8a63SDaniel Dunbar 1468f4a8a63SDaniel Dunbar**--exec-command** *command* 1478f4a8a63SDaniel Dunbar 1488f4a8a63SDaniel Dunbar This option defines the command to use with the **--run-custom** and 1498f4a8a63SDaniel Dunbar **--safe-custom** options to execute the bitcode testcase. This can 1508f4a8a63SDaniel Dunbar be useful for cross-compilation. 1518f4a8a63SDaniel Dunbar 1528f4a8a63SDaniel Dunbar**--compile-command** *command* 1538f4a8a63SDaniel Dunbar 1548f4a8a63SDaniel Dunbar This option defines the command to use with the **--compile-custom** 155232c3317SSean Silva option to compile the bitcode testcase. The command should exit with a 156232c3317SSean Silva failure exit code if the file is "interesting" and should exit with a 157232c3317SSean Silva success exit code (i.e. 0) otherwise (this is the same as if it crashed on 158232c3317SSean Silva "interesting" inputs). 159232c3317SSean Silva 160232c3317SSean Silva This can be useful for 1618f4a8a63SDaniel Dunbar testing compiler output without running any link or execute stages. To 1628f4a8a63SDaniel Dunbar generate a reduced unit test, you may add CHECK directives to the 1638f4a8a63SDaniel Dunbar testcase and pass the name of an executable compile-command script in this form: 1648f4a8a63SDaniel Dunbar 165a99fa5b0SDmitri Gribenko .. code-block:: sh 1668f4a8a63SDaniel Dunbar 1678f4a8a63SDaniel Dunbar #!/bin/sh 1688f4a8a63SDaniel Dunbar llc "$@" 1698f4a8a63SDaniel Dunbar not FileCheck [bugpoint input file].ll < bugpoint-test-program.s 1708f4a8a63SDaniel Dunbar 1718f4a8a63SDaniel Dunbar This script will "fail" as long as FileCheck passes. So the result 1728f4a8a63SDaniel Dunbar will be the minimum bitcode that passes FileCheck. 1738f4a8a63SDaniel Dunbar 1748f4a8a63SDaniel Dunbar**--safe-path** *path* 1758f4a8a63SDaniel Dunbar 1768f4a8a63SDaniel Dunbar This option defines the path to the command to execute with the 1778f4a8a63SDaniel Dunbar **--safe-{int,jit,llc,custom}** 1788f4a8a63SDaniel Dunbar option. 1798f4a8a63SDaniel Dunbar 1808f7d0199SSebastian Pop**--verbose-errors**\ =\ *{true,false}* 1818f7d0199SSebastian Pop 1828f7d0199SSebastian Pop The default behavior of bugpoint is to print "<crash>" when it finds a reduced 1838f7d0199SSebastian Pop test that crashes compilation. This flag prints the output of the crashing 1848f7d0199SSebastian Pop program to stderr. This is useful to make sure it is the same error being 1858f7d0199SSebastian Pop tracked down and not a different error that happens to crash the compiler as 1868f7d0199SSebastian Pop well. Defaults to false. 1878f7d0199SSebastian Pop 1888f4a8a63SDaniel DunbarEXIT STATUS 1898f4a8a63SDaniel Dunbar----------- 1908f4a8a63SDaniel Dunbar 1918f4a8a63SDaniel DunbarIf **bugpoint** succeeds in finding a problem, it will exit with 0. Otherwise, 1928f4a8a63SDaniel Dunbarif an error occurs, it will exit with a non-zero value. 1938f4a8a63SDaniel Dunbar 1948f4a8a63SDaniel DunbarSEE ALSO 1958f4a8a63SDaniel Dunbar-------- 1968f4a8a63SDaniel Dunbar 197*09a066b3SAlex Brachet:manpage:`opt(1)` 198