LLVM-REDUCE(1)

πŸ’– LLVM-REDUCE(1) πŸ’–

okay bestie, welcome to the llvm-reduce manual page β€” it's the LLVM automatic testcase reducer and it's genuinely one of the most iconic little tools in the whole LLVM toolbox. come sit with me, this is gonna be good 🫢


✨ NAME ✨

llvm-reduce β€” the LLVM automatic testcase reducer, no cap.


🌸 SYNOPSIS 🌸

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

πŸ¦‹ DESCRIPTION πŸ¦‹

So like, llvm-reduce is the project that shrinks your LLVM test cases down to size. it does this by yeeting the redundant or unnecessary code out of your test cases, while still preserving their ability to detect bugs. that last part? that's the whole point. the test still has to catch the bug. periodt.

If your input is literally just "-", then llvm-reduce reads from standard input. otherwise? it reads from the filenames you gave it. simple as that πŸ’…

And listen β€” LLVM-Reduce is genuinely useful for reducing the size and complexity of LLVM test cases, which makes it way easier to identify and debug issues in the LLVM compiler infrastructure. it's giving "debugging but make it cute" πŸ’€


⭐ GENERIC OPTIONS ⭐

okay here's the full menu, every single one, don't skip:

  • --help β€” shows you all the available options (--help-hidden shows even more πŸ‘€).
  • --abort-on-invalid-reduction β€” bails out (aborts) if any reduction results in invalid IR.
  • --in-place β€” > WARNING: this option will replace your input file with the reduced version! like, it will literally eat your original file. back it up bestie 😭
  • --ir-passes=<string> β€” a textual description of the pass pipeline, same as what's passed to opt -passes.
  • -j <uint> β€” max number of threads to use when processing chunks. set it to 1 to disable parallelism entirely.
  • --max-pass-iterations=<int> β€” max number of times to run the full set of delta passes (default=5).
  • --mtriple=<string> β€” sets the target triple.
  • --preserve-debug-environment β€” don't disable the features used for crash debugging (that's crash reports, llvm-symbolizer and core dumps).
  • --print-delta-passes β€” prints the list of delta passes, which you can pass to --delta-passes as a comma separated liste.
  • --skip-delta-passes=<string> β€” delta passes to not run, separated by commas. by default it runs all delta passes.
  • --starting-granularity-level=<uint> β€” number of times to divide chunks prior to the first test.
    • Note: granularity refers to the level of detail at which the reduction process operates. a lower granularity means the reduction process operates at a more coarse-grained level, while a higher granularity means it operates at a more fine-grained level. iykyk 🧚
  • --test=<string> β€” name of the interesting-ness test to be run.
  • --test-arg=<string> β€” arguments passed onto the interesting-ness test.
  • --verbose β€” prints extra debugging information. main character energy, she's chatty πŸ’…
  • --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. that's it, that's the vibe check.


🌈 EXAMPLE 🌈

so llvm-reduce can be used to simplify a test that causes a compiler crash. let's walk through it 🫢

for example, let's assume that opt is crashing on the IR file test.ll with the error message Assertion failed at line 1234 of WhateverFile.cpp, when running at -O2.

you can reduce the test case of test.ll by invoking this command:

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

and the shell script you pass to the test option consists of this:

$(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. cute, right? ✨)

this example can be generalized to other tools that process IR files β€” for example llc. slay.


πŸ‘‘ AUTHOR πŸ‘‘

maintained by the LLVM Team (https://llvm.org/). kings fr fr πŸ’œ


2003-2025, LLVM Project


and that's the whole page bestie!! this was page 20, from the LLVM fam, dated 2025-09-03 β€” LLVM-REDUCE(1), mwah, go reduce something iconic πŸ’…πŸŽ€βœ¨

πŸ“¦ where this page comes from