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-hiddenshows 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 toopt -passes.-j <uint>β max number of threads to use when processing chunks. set it to1to 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-symbolizerand core dumps).--print-delta-passesβ prints the list of delta passes, which you can pass to--delta-passesas 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, asirormir.
π 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 π
π COPYRIGHT π
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
- fedora 43: llvm20 20.1.8-2.fc43 Β· Apache-2.0 WITH LLVM-exception OR NCSA
- fedora 43: llvm20 20.1.8-2.fc43 Β· Apache-2.0 WITH LLVM-exception OR NCSA
- fedora 44: llvm20 20.1.8-2.fc44 Β· Apache-2.0 WITH LLVM-exception OR NCSA
- fedora 44: llvm20 20.1.8-2.fc44 Β· Apache-2.0 WITH LLVM-exception OR NCSA
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms