LLVM-REDUCE(1)

πŸŽ€ NAME πŸŽ€

llvm-reduce β€” LLVM automatic testcase reducer. This is the LLVM-REDUCE(1) manual page, and bestie, it’s literally here to make giant testcases smaller while keeping the bug detectable. Iconic behavior. πŸ’…

✨ SYNOPSIS ✨

llvm-reduce [options] [input...]

πŸ’… DESCRIPTION πŸ’…

The llvm-reduce tool/project is used for reducing the size of LLVM test cases. It works by removing redundant or unnecessary code from LLVM test cases while still preserving their ability to detect bugs. No cap, that’s the whole vibe. πŸ¦‹

If input is -, llvm-reduce reads from standard input. Otherwise, it will read from the specified filenames.

LLVM-Reduce is a useful tool for reducing the size and complexity of LLVM test cases, making it easier to identify and debug issues in the LLVM compiler infrastructure. Literally making debugging less of a nightmare. 😭

🌈 GENERIC OPTIONS 🌈

  • --help β€” displays the available options (--help-hidden for more). iykyk
  • --abort-on-invalid-reduction β€” aborts if any reduction results in invalid IR.
  • --in-place β€” ⚠️ WARNING: this option will replace your input file with the reduced version! Like, read that twice, bestie.
  • --ir-passes=<string> β€” a textual description of the pass pipeline, same as what’s passed to opt -passes.
  • -j <uint> β€” maximum number of threads to use to process chunks. Set to 1 to disable parallelism.
  • --max-pass-iterations=<int> β€” maximum number of times to run the full set of delta passes (default=5).
  • --mtriple=<string> β€” set the target triple.
  • --preserve-debug-environment β€” don’t disable features used for crash debugging (crash reports, llvm-symbolizer and core dumps).
  • --print-delta-passes β€” print the list of delta passes, passable to --delta-passes as a comma separated liste. (yes, β€œliste” is exactly what it says πŸ’€)
  • --skip-delta-passes=<string> β€” delta passes to not run, separated by commas. By default, run all delta passes.
  • --starting-granularity-level=<uint> β€” number of times to divide chunks prior to first test. Note: granularity refers to the level of detail at which the reduction process operates. A lower granularity means that the reduction process operates at a more coarse-grained level, while a higher granularity means that it operates at a more fine-grained level. It’s giving β€œzoom level for reduction.”
  • --test=<string> β€” name of the interesting-ness test to be run.
  • --test-arg=<string> β€” arguments passed onto the interesting-ness test.
  • --verbose β€” print extra debugging information. Spill the tea, tool.
  • --write-tmp-files-as-bitcode β€” always write temporary files as bitcode instead of textual IR.
  • -x={ir|mir} β€” input language as ir or mir.

🚦 EXIT STATUS 🚦

llvm-reduce returns 0 under normal operation. It returns a non-zero exit code if there were any errors. Returns 2 if the interestingness test reported the initial input was not interesting. Vibe check complete. βœ…

πŸ§ͺ EXAMPLE πŸ§ͺ

llvm-reduce can be used to simplify a test that causes a compiler crash.

For example, let’s assume that opt is crashing on the IR file test.ll with error message Assertion failed at line 1234 of WhateverFile.cpp, when running at -O2. Oof, compiler crash moment. 😭

The test case of test.ll can be reduced by invoking the following command:

$(LLVM_BUILD_FOLDER)/bin/llvm-reduce --test=script.sh <path to>/test.ll

The shell script passed to the option test consists of the following:

$(LLVM_BUILD_FOLDER)/bin/opt -O2 -disable-output $1 \
  |& grep "Assertion failed at line 1234 of WhateverFile.cpp"

(In this script, grep exits with 0 if it finds the string and that becomes the whole script’s status.)

This example can be generalized to other tools that process IR files, for example llc. Slay, reusable recipe. 🧚

πŸ‘‘ Author πŸ‘‘

Maintained by the LLVM Team (https://llvm.org/).

2003-2026, LLVM Project.


πŸ’– cute sign-off: this page is from LLVM 21, dated 2026-05-15. Bye bestie, go make that testcase smaller β€” periodt. πŸ’…βœ¨

πŸ“¦ where this page comes from