[llvm-branch-commits] [llvm] llvm: Delete bugpoint (PR #182320)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Feb 19 09:03:07 PST 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-support

Author: Matt Arsenault (arsenm)

<details>
<summary>Changes</summary>

For crash reduction, I don't think it does anything that llvm-reduce
can't. Pass pipeline reduction also has a separate reduction script.
The main thing there isn't a replacement tool is the miscompilation
reducer, but I'm not sure that's actually functioned for years.

There are still some references to bugpoint in various comments
and pieces of documentation that don't all necessarily make sense
to replace or remove. In particular there are a few passes documented
as "only for bugpoint", but I've left those alone in case they are
useful for manual reductions.

---

Patch is 261.08 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/182320.diff


42 Files Affected:

- (removed) llvm/docs/Bugpoint.rst (-227) 
- (removed) llvm/docs/CommandGuide/bugpoint.rst (-197) 
- (modified) llvm/docs/CommandGuide/index.rst (+1-1) 
- (modified) llvm/docs/CommandGuide/llvm-extract.rst (+1-1) 
- (modified) llvm/docs/ReleaseNotes.md (+3) 
- (modified) llvm/lib/Support/Unix/Process.inc (+3-3) 
- (modified) llvm/lib/Support/Windows/Process.inc (+4-4) 
- (modified) llvm/lib/Transforms/Utils/MetaRenamer.cpp (+1-1) 
- (removed) llvm/test/BugPoint/attr-crash.ll (-16) 
- (removed) llvm/test/BugPoint/compile-custom.ll (-12) 
- (removed) llvm/test/BugPoint/compile-custom.ll.py (-12) 
- (removed) llvm/test/BugPoint/crash-narrowfunctiontest.ll (-13) 
- (removed) llvm/test/BugPoint/func-attrs-keyval.ll (-11) 
- (removed) llvm/test/BugPoint/func-attrs.ll (-15) 
- (removed) llvm/test/BugPoint/invalid-debuginfo.ll (-22) 
- (removed) llvm/test/BugPoint/metadata.ll (-54) 
- (removed) llvm/test/BugPoint/named-md.ll (-39) 
- (removed) llvm/test/BugPoint/remove_arguments_test.ll (-18) 
- (removed) llvm/test/BugPoint/replace-funcs-with-null.ll (-17) 
- (removed) llvm/test/BugPoint/retain-crashing-metadata.ll (-22) 
- (removed) llvm/test/BugPoint/unsymbolized.ll (-23) 
- (modified) llvm/test/CMakeLists.txt (-2) 
- (modified) llvm/test/lit.cfg.py (-1) 
- (removed) llvm/tools/bugpoint-passes/CMakeLists.txt (-18) 
- (removed) llvm/tools/bugpoint-passes/TestPasses.cpp (-187) 
- (removed) llvm/tools/bugpoint-passes/bugpoint.exports () 
- (removed) llvm/tools/bugpoint/BugDriver.cpp (-255) 
- (removed) llvm/tools/bugpoint/BugDriver.h (-290) 
- (removed) llvm/tools/bugpoint/CMakeLists.txt (-43) 
- (removed) llvm/tools/bugpoint/CrashDebugger.cpp (-1412) 
- (removed) llvm/tools/bugpoint/ExecutionDriver.cpp (-451) 
- (removed) llvm/tools/bugpoint/ExtractFunction.cpp (-410) 
- (removed) llvm/tools/bugpoint/FindBugs.cpp (-98) 
- (removed) llvm/tools/bugpoint/ListReducer.h (-208) 
- (removed) llvm/tools/bugpoint/Miscompilation.cpp (-1080) 
- (removed) llvm/tools/bugpoint/OptimizerDriver.cpp (-278) 
- (removed) llvm/tools/bugpoint/ToolRunner.cpp (-849) 
- (removed) llvm/tools/bugpoint/ToolRunner.h (-190) 
- (removed) llvm/tools/bugpoint/bugpoint.cpp (-181) 
- (modified) llvm/tools/opt/optdriver.cpp (+2-9) 
- (modified) llvm/utils/gn/secondary/llvm/test/BUILD.gn (-7) 
- (removed) llvm/utils/gn/secondary/llvm/tools/bugpoint-passes/BUILD.gn (-26) 


``````````diff
diff --git a/llvm/docs/Bugpoint.rst b/llvm/docs/Bugpoint.rst
deleted file mode 100644
index ab6bf7004c287..0000000000000
--- a/llvm/docs/Bugpoint.rst
+++ /dev/null
@@ -1,227 +0,0 @@
-====================================
-LLVM bugpoint tool: design and usage
-====================================
-
-.. contents::
-   :local:
-
-Description
-===========
-
-``bugpoint`` narrows down the source of problems in LLVM 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 JIT compilers).  It aims to reduce large test cases to small, useful ones.
-For example, if ``opt`` 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.
-
-For detailed case scenarios, such as debugging ``opt``, or one of the LLVM code
-generators, see :doc:`HowToSubmitABug`.
-
-Design Philosophy
-=================
-
-``bugpoint`` is designed to be a useful tool without requiring any hooks into
-the LLVM infrastructure at all.  It works with any and all LLVM passes and code
-generators, and does not need to "know" how they work.  Because of this, it may
-appear to do stupid things or miss obvious simplifications.  ``bugpoint`` 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 ``bugpoint`` is generally very quick unless debugging a miscompilation
-where each test of the program (which requires executing it) takes a long time.
-
-Automatic Debugger Selection
-----------------------------
-
-``bugpoint`` reads each ``.bc`` or ``.ll`` file specified on the command line
-and links them together into a single module, called the test program.  If any
-LLVM 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), ``bugpoint`` starts the `crash debugger`_.
-
-Otherwise, if the ``-output`` option was not specified, ``bugpoint`` runs the
-test program with the "safe" backend (which is assumed to generate good code) to
-generate a reference output.  Once ``bugpoint`` has a reference output for the
-test program, it tries executing it with the selected code generator.  If the
-selected code generator crashes, ``bugpoint`` starts the `crash debugger`_ 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 `code generator debugger`_.
-
-Finally, if the output of the selected code generator matches the reference
-output, ``bugpoint`` runs the test program after all of the LLVM 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 LLVM passes, and enters the
-`miscompilation debugger`_.  Otherwise, there is no problem ``bugpoint`` can
-debug.
-
-.. _crash debugger:
-
-Crash debugger
---------------
-
-If an optimizer or code generator crashes, ``bugpoint`` will try as hard as it
-can to reduce the list of passes (for optimizer crashes) and the size of the
-test program.  First, ``bugpoint`` figures out which combination of optimizer
-passes triggers the bug. This is useful when debugging a problem exposed by
-``opt``, for example, because it runs over 38 passes.
-
-Next, ``bugpoint`` 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, ``bugpoint``
-deletes any individual LLVM instructions whose absence does not eliminate the
-failure.  At the end, ``bugpoint`` should tell you what passes crash, give you a
-bitcode file, and give you instructions on how to reproduce the failure with
-``opt`` or ``llc``.
-
-.. _code generator debugger:
-
-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
-"safe" backend (into a shared object), and one piece which it runs with either
-the JIT or the static LLC compiler.  It uses several techniques to reduce the
-amount of code pushed through the LLVM code generator, to reduce the potential
-scope of the problem.  After it is finished, it emits two bitcode files (called
-"test" [to be compiled with the code generator] and "safe" [to be compiled with
-the "safe" backend], respectively), and instructions for reproducing the
-problem.  The code generator debugger assumes that the "safe" backend produces
-good code.
-
-.. _miscompilation debugger:
-
-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.
-
-Advice for using bugpoint
-=========================
-
-``bugpoint`` can be a remarkably useful tool, but it sometimes works in
-non-obvious ways.  Here are some hints and tips:
-
-* In the code generator and miscompilation debuggers, ``bugpoint`` only works
-  with programs that have deterministic output.  Thus, if the program outputs
-  ``argv[0]``, the date, time, or any other "random" data, ``bugpoint`` 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.
-
-* In the `crash debugger`_, ``bugpoint`` does not distinguish different crashes
-  during reduction. Thus, if new crash or miscompilation happens, ``bugpoint``
-  will continue with the new crash instead. If you would like to stick to
-  particular crash, you should write check scripts to validate the error
-  message, see ``-compile-command`` in :doc:`CommandGuide/bugpoint`.
-
-* 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.
-
-* ``bugpoint`` is extremely useful when working on a new optimization: it helps
-  track down regressions quickly.  To avoid having to relink ``bugpoint`` every
-  time you change your optimization however, have ``bugpoint`` dynamically load
-  your optimization with the ``-load`` option.
-
-* ``bugpoint`` 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 run:
-
-  .. code-block:: console
-
-    $ bugpoint  ... |& tee bugpoint.log
-
-  to get a copy of ``bugpoint``'s output in the file ``bugpoint.log``, as well
-  as on your terminal.
-
-* ``bugpoint`` cannot debug problems with the LLVM linker. If ``bugpoint``
-  crashes before you see its "All input ok" message, you might try ``llvm-link
-  -v`` on the same set of input files. If that also crashes, you may be
-  experiencing a linker bug.
-
-* ``bugpoint`` is useful for proactively finding bugs in LLVM.  Invoking
-  ``bugpoint`` with the ``-find-bugs`` option will cause the list of specified
-  optimizations to be randomized and applied to the program. This process will
-  repeat until a bug is found or the user kills ``bugpoint``.
-
-* ``bugpoint`` can produce IR which contains long names. Run ``opt
-  -passes=metarenamer`` over the IR to rename everything using easy-to-read,
-  metasyntactic names. Alternatively, run ``opt -passes=strip,instnamer`` to
-  rename everything with very short (often purely numeric) names.
-
-What to do when bugpoint isn't enough
-=====================================
-	
-Sometimes, ``bugpoint`` is not enough. In particular, InstCombine and
-TargetLowering both have visitor structured code with lots of potential
-transformations.  If the process of using bugpoint has left you with still too
-much code to figure out and the problem seems to be in instcombine, the
-following steps may help.  These same techniques are useful with TargetLowering
-as well.
-
-Turn on ``-debug-only=instcombine`` and see which transformations within
-instcombine are firing by selecting out lines with "``IC``" in them.
-
-At this point, you have a decision to make.  Is the number of transformations
-small enough to step through them using a debugger?  If so, then try that.
-
-If there are too many transformations, then a source modification approach may
-be helpful.  In this approach, you can modify the source code of instcombine to
-disable just those transformations that are being performed on your test input
-and perform a binary search over the set of transformations.  One set of places
-to modify are the "``visit*``" methods of ``InstCombiner`` (*e.g.*
-``visitICmpInst``) by adding a "``return false``" as the first line of the
-method.
-
-If that still doesn't remove enough, then change the caller of
-``InstCombiner::DoOneIteration``, ``InstCombiner::runOnFunction`` to limit the
-number of iterations.
-
-You may also find it useful to use "``-stats``" now to see what parts of
-instcombine are firing.  This can guide where to put additional reporting code.
-
-At this point, if the amount of transformations is still too large, then
-inserting code to limit whether or not to execute the body of the code in the
-visit function can be helpful.  Add a static counter which is incremented on
-every invocation of the function.  Then add code which simply returns false on
-desired ranges.  For example:
-
-.. code-block:: c++
-
-
-  static int calledCount = 0;
-  calledCount++;
-  LLVM_DEBUG(if (calledCount < 212) return false);
-  LLVM_DEBUG(if (calledCount > 217) return false);
-  LLVM_DEBUG(if (calledCount == 213) return false);
-  LLVM_DEBUG(if (calledCount == 214) return false);
-  LLVM_DEBUG(if (calledCount == 215) return false);
-  LLVM_DEBUG(if (calledCount == 216) return false);
-  LLVM_DEBUG(dbgs() << "visitXOR calledCount: " << calledCount << "\n");
-  LLVM_DEBUG(dbgs() << "I: "; I->dump());
-
-could be added to ``visitXOR`` to limit ``visitXor`` to being applied only to
-calls 212 and 217. This is from an actual test case and raises an important
-point---a simple binary search may not be sufficient, as transformations that
-interact may require isolating more than one call.  In TargetLowering, use
-``return SDNode();`` instead of ``return false;``.
-
-Now that the number of transformations is down to a manageable number, try
-examining the output to see if you can figure out which transformations are
-being done.  If that can be figured out, then do the usual debugging.  If which
-code corresponds to the transformation being performed isn't obvious, set a
-breakpoint after the call count based disabling and step through the code.
-Alternatively, you can use "``printf``" style debugging to report waypoints.
diff --git a/llvm/docs/CommandGuide/bugpoint.rst b/llvm/docs/CommandGuide/bugpoint.rst
deleted file mode 100644
index 971807e7e983f..0000000000000
--- a/llvm/docs/CommandGuide/bugpoint.rst
+++ /dev/null
@@ -1,197 +0,0 @@
-bugpoint - automatic test case reduction tool
-=============================================
-
-.. program:: bugpoint
-
-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.  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 JIT compilers).  It aims to reduce large test cases to small, useful ones.
-For more information on the design and inner workings of **bugpoint**, as well as
-advice for using bugpoint, see :doc:`/Bugpoint` in the LLVM
-distribution.
-
-OPTIONS
--------
-
-**--additional-so** *library*
-
- Load the dynamic shared object *library* 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.
-
-**--append-exit-code**\ =\ *{true,false}*
-
- Append the test programs exit code to the output file so that a change in exit
- code is considered a test failure. Defaults to false.
-
-**--args** *program args*
-
- Pass 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:
-
- .. code-block:: bash
-
-      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.
-
-**--tool-args** *tool args*
-
- Pass all arguments specified after **--tool-args** to the LLVM tool under test
- (**llc**, **lli**, etc.) whenever it runs.  You should use this option in the
- following way:
-
- .. code-block:: bash
-
-      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*
-
- Pass all arguments specified after **--safe-tool-args** to the "safe" execution
- tool.
-
-**--gcc-tool-args** *gcc tool args*
-
- Pass all arguments specified after **--gcc-tool-args** to the invocation of
- **gcc**.
-
-**--opt-args** *opt args*
-
- Pass 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.  If you're trying to find a bug in one of these passes,
- **bugpoint** may crash.
-
-**--enable-valgrind**
-
- Use valgrind to find faults in the optimization phase. This will allow
- bugpoint to find otherwise asymptomatic problems caused by memory
- mis-management.
-
-**-find-bugs**
-
- Continually randomize the specified passes and run them on the test program
- until a bug is found or the user kills **bugpoint**.
-
-**-help**
-
- Print a summary of command line options.
-
-**--input** *filename*
-
- Open *filename* and redirect the standard input of the test program, whenever
- it runs, to come from that file.
-
-**--load** *plugin*
-
- Load 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:
-
- .. code-block:: bash
-
-      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.
-
-**--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
- do not 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 allow you to choose the
- interpreter, the JIT compiler, the static native code compiler, or a
- custom command (see **--exec-command**) respectively.
-
-**--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 has not been provided, and to
- compile portions of the program that as they are excluded from the testcase.
- These options allow you to 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.
-
-**--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).
-
- 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:
-
- .. code-block:: sh
-
-      #!/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.
-
-**--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. This is useful to make sure it is the same error being
- tracked down and not a different error that happens to crash the compiler as
- well. Defaults to false.
-
-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
---------
-
-:manpage:`opt(1)`
diff --git a/llvm/docs/CommandGuide/index.rst b/llvm/docs/CommandGuide/index.rst
index c6427d1245b9a..c76d302ba41fc 100644
--- a/llvm/docs/CommandGuide/index.rst
+++ b/llvm/docs/CommandGuide/index.rst
@@ -69,9 +69,9 @@ Debugging Tools
 .. toctree::
    :maxdepth: 1
 
-   bugpoint
    llvm-extract
    llvm-bcanalyzer
+   llvm-reduce
 
 Developer Tools
 ~~~~~~~~~~~~~~~
diff --git a/llvm/docs/CommandGuide/llvm-extract.rst b/llvm/docs/CommandGuide/llvm-extract.rst
index af5d3511fac10..704c482a1fd5f 100644
--- a/llvm/docs/CommandGuide/llvm-extract.rst
+++ b/llvm/docs/CommandGuide/llvm-extract.rst
@@ -107,4 +107,4 @@ occurs, it will exit with a non-zero value.
 SEE ALSO
 --------
 
-:manpage:`bugpoint(1)`
+:manpage:`llvm-reduce(1)`
diff --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md
index 69c1cfcd9396c..23290e6e609b1 100644
--- a/llvm/docs/ReleaseNotes.md
+++ b/llvm/docs/ReleaseNotes.md
@@ -80,6 +80,9 @@ Changes to LLVM infrastructure
 
 * Removed TypePromoteFloat legalization from SelectionDAG
 
+* Removed `bugpoint`. Usage has been replaced by `llvm-reduce` and
+  `llvm/utils/reduce_pipeline.py`.
+
 Changes to building LLVM
 ------------------------
 
diff --git a/llvm/lib/Support/Unix/Process.inc b/llvm/lib/Support/Unix/Process.inc
index c6e79af44b9b4..184ff486f7074 100644
--- a/llvm/lib/Support/Unix/Process.inc
+++ b/llvm/lib/Support/Unix/Process.inc
@@ -132,9 +132,9 @@ void Process::GetTimeUsage(TimePoint<> &ela...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/182320


More information about the llvm-branch-commits mailing list