LLVM-REDUCE(1)
π LLVM-REDUCE(1) π
okay bestie, gather round, because today we're talking about llvm-reduce from the LLVM manual pages, and honestly? she's a baddie.
β¨ NAME β¨
llvm-reduce β the LLVM automatic testcase reducer. she shrinks your test cases. that's the whole vibe. π
πΈ SYNOPSIS πΈ
llvm-reduce [options] [input...]
π¦ DESCRIPTION π¦
so llvm-reduce is this whole tool/project sitch that reduces the size of LLVM test cases. the way it works is iconic: it strips out redundant or unnecessary code from your LLVM test cases while still preserving their ability to detect bugs. like, it's giving "cut the filler, keep the plot". π
if the input is -, llvm-reduce reads from standard input. otherwise, bestie, it reads from the filenames you specified. simple as. β¨
basically, LLVM-Reduce is super 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. main character debugging energy, no cap. π
π GENERIC OPTIONS π
--helpβ display available options (--help-hiddenfor more, if you're nosy, which, same).--abort-on-invalid-reductionβ abort if any reduction results in invalid IR. she's strict, and honestly? respect.--in-placeβ > β οΈ WARNING: this option will replace your input file with the reduced version! not a drill bestie, she WILL overwrite your file. π--ir-passes=<string>β a textual description of the pass pipeline, same as what's passed toopt -passes.-j <uint>β maximum number of threads to use to process chunks. set it to1to disable parallelism. (single-threaded era, if that's what you want.)--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-symbolizerand core dumps).--print-delta-passesβ print the list of delta passes, passable to--delta-passesas a comma separated list.--skip-delta-passes=<string>β delta passes to not run, separated by commas. by default, she runs 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 the reduction process operates at a more coarse-grained level, while a higher granularity means it operates at a more fine-grained level. (coarse = big chunks, fine = tiny chunks, iykyk π§)
--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.--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, periodt. she returns a non-zero exit code if there were any errors. and she returns 2 if the interestingness test reported the initial input was not interesting. π
π 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.
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. cute, right? π«Ά)
this example can be generalized to other tools that process IR files, for example llc.
π Author π
maintained by the LLVM Team (https://llvm.org/). slay.
π Copyright π
2003-2026, LLVM Project
and that's the whole page bestie!! this one came from the LLVM manual, page 22, dated 2026-07-16, and she's filed under LLVM-REDUCE(1) β go forth and reduce responsibly (and please remember what --in-place does, i am begging ππ)
π¦ where this page comes from
- fedora 44: llvm 22.1.8-4.fc44 Β· Apache-2.0 WITH LLVM-exception OR NCSA
- fedora 44: llvm 22.1.8-4.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