bugpoint.rst 6.7 KB

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