BUGPOINT(1)

πŸ’… BUGPOINT(1) β€” the LLVM one, bestie

okay so real talk: this is bugpoint(1) from the LLVM manual, and it's genuinely the loml of debugging tools. buckle up πŸŽ€


✨ NAME ✨

bugpoint β€” the automatic test case reduction tool, aka the friend who takes your 40,000-line nightmare and hands you back the three lines that actually matter. icon behavior.


🌸 SYNOPSIS 🌸

bugpoint [options] [input LLVM ll/bc files] [LLVM passes] --args program
arguments

πŸ¦‹ DESCRIPTION πŸ¦‹

bugpoint narrows down the source of problems in LLVM tools and passes. literally its whole job. πŸ’…

it can debug three types of failures, no cap:

  • optimizer crashes 😭
  • miscompilations by optimizers πŸ™ˆ
  • bad native code generation β€” including problems in the static and JIT compilers πŸ”₯

the goal? take a large test case and reduce it to a small, useful one. it's giving glow-up, but for test cases.

for more info on the design and inner workings of bugpoint, plus advice for using bugpoint, see LLVM bugpoint tool: design and usage in the LLVM distribution. iykyk πŸ“š


πŸ’– OPTIONS πŸ’–

  • --additional-so library β€” loads the dynamic shared object library into the test program whenever it runs. this is useful if you're debugging programs which depend on non-LLVM libraries (like the X or curses libraries) to run. we love a supporting cast 🫢
  • --append-exit-code={true,false} β€” appends the test program's exit code to the output file so that a change in exit code counts as a test failure. defaults to false. no accidental vibes-based passing, periodt.
  • --args program args β€” passes all arguments specified after --args to the test program whenever it runs. ⚠️ note that if any of the program args start with a -, you should use:
bugpoint [bugpoint args] --args -- [program args]

the -- right after the --args option tells bugpoint to consider any options starting with - to be part of the --args option, NOT as options to bugpoint itself. so basically -- is the bouncer at the club πŸšͺ

  • --tool-args tool args β€” passes all arguments specified after --tool-args to the LLVM tool under test (llc, lli, etc.) whenever it runs. use it like this:
bugpoint [bugpoint args] --tool-args -- [tool args]

the -- right after the --tool-args option tells bugpoint to consider any options starting with - to be part of the --tool-args option, not as options to bugpoint itself. (see --args, above.) πŸ’«

  • --safe-tool-args tool args β€” passes all arguments specified after --safe-tool-args to the "safe" execution tool.
  • --gcc-tool-args gcc tool args β€” passes all arguments specified after --gcc-tool-args to the invocation of gcc.
  • --opt-args opt args β€” passes all arguments specified after --opt-args to the invocation of opt.
  • --disable-{dce,simplifycfg} β€” do not run the specified passes to clean up and reduce the size of the test program. by default, bugpoint uses these passes internally when attempting to reduce test programs. 🚨 but heads up: if you're trying to find a bug in one of these passes, bugpoint may crash. you've been warned, babe.
  • --enable-valgrind β€” uses valgrind to find faults in the optimization phase. this lets bugpoint find otherwise asymptomatic problems caused by memory mis-management. detective mode πŸ”
  • -find-bugs β€” continually randomizes the specified passes and runs them on the test program until a bug is found or the user kills bugpoint. it's giving chaos gremlin and honestly? respect πŸŒͺ️
  • -help β€” prints a summary of command line options. the classic.
  • --input filename β€” opens filename and redirects the standard input of the test program, whenever it runs, to come from that file.
  • --load plugin β€” loads the dynamic object plugin into bugpoint 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 -help and --load options together; for example:
bugpoint --load myNewPass.so -help
  • --mlimit megabytes β€” specifies an upper limit on memory usage of the optimization and codegen. set to zero to disable the limit. 🧠 set it, don't regret it.
  • --output filename β€” whenever the test program produces output on its standard output stream, it should match the contents of filename (the "reference output"). if you don't use this option, bugpoint will attempt to generate a reference output by compiling the program with the "safe" backend and running it.
  • --run-{int,jit,llc,custom} β€” whenever the test program is compiled, bugpoint should generate code for it using the specified code generator. these options let you choose the interpreter, the JIT compiler, the static native code compiler, or a custom command (see --exec-command) respectively. pick your fighter πŸ‘‘
  • --safe-{llc,custom} β€” when debugging a code generator, bugpoint should use the specified code generator as the "safe" code generator. this is a known-good code generator used to generate the "reference output" if it hasn't been provided, and to compile portions of the program as they are excluded from the testcase. these options let you choose the static native code compiler, or a custom command (see --exec-command) respectively. ⚠️ the interpreter and the JIT backends cannot currently be used as the "safe" backends. not them, bestie.
  • --exec-command command β€” this option defines the command to use with the --run-custom and --safe-custom options to execute the bitcode testcase. this can be useful for cross-compilation. 🧚
  • --compile-command command β€” this option defines the command to use with the --compile-custom option to compile the bitcode testcase. the command should exit with a failure exit code if the file is "interesting" and should exit with a success exit code (i.e. 0) otherwise (this is the same as if it crashed on "interesting" inputs). yes, the logic is upside-down-flip, that's just how it is πŸ™ƒ

this can be useful for testing compiler output without running any link or execute stages. to generate a reduced unit test, you may add CHECK directives to the testcase and pass the name of an executable compile-command script in this form:

#!/bin/sh
llc "$@"
not FileCheck [bugpoint input file].ll < bugpoint-test-program.s

this script will "fail" as long as FileCheck passes. so the result will be the minimum bitcode that passes FileCheck. absolute galaxy brain 🧠✨

  • --safe-path path β€” this option defines the path to the command to execute with the --safe-{int,jit,llc,custom} option.
  • --verbose-errors={true,false} β€” the default behavior of bugpoint is to print <crash> when it finds a reduced test that crashes compilation. this flag prints the output of the crashing program to stderr. useful to make sure it's the same error being tracked down and not a different error that happens to crash the compiler as well. defaults to false. because "a crash is a crash" is NOT the vibe we're going for πŸ”₯

⭐ EXIT STATUS ⭐

if bugpoint succeeds in finding a problem, it will exit with 0. πŸŽ‰

otherwise, if an error occurs, it will exit with a non-zero value. πŸ’€


πŸ“ SEE ALSO πŸ“

opt(1) β€” the other one you'll be spending your whole personality on.


πŸ‘‘ AUTHOR πŸ‘‘

maintained by the LLVM Team (https://llvm.org/). legends fr fr 🫢


2003-2023, LLVM Project


and that's the whole page, bestie β€” no notes πŸ’…

this one's page 17 of the LLVM set, dated 2023-12-01 β€” so if you see that date in the wild, that's just this exact manual page showing up to say hi πŸ¦‹ mwah, go reduce some test cases πŸ’œ

πŸ“¦ where this page comes from