LLVM-REDUCE(1)
π LLVM-REDUCE β the llvm-reduce manual, but make it make sense
okay so bestie, welcome to LLVM-REDUCE(1) from the LLVM manual set β¨ this is the page for llvm-reduce, and by the end you're gonna be obsessed, trust.
πΈ NAME πΈ
llvm-reduce β the LLVM automatic testcase reducer. yes, that's her whole job. iconic.
π¦ SYNOPSIS π¦
llvm-reduce [options] [input...]
β¨ DESCRIPTION β¨
so llvm-reduce is this tool that shrinks your LLVM test cases down to size π it does it by yeeting redundant or unnecessary code out of your test cases, while still preserving their ability to detect bugs. like, the whole point is that the bug stays caught. no cap.
if input is -, llvm-reduce reads from standard input. otherwise it reads from the filenames you gave it. simple as that.
basically it's the useful tool 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 "less is more" and honestly? slay.
π GENERIC OPTIONS π
--helpβ display available options. there's also--help-hiddenfor more, if you're nosy like me π--abort-on-invalid-reductionβ abort if any reduction results in invalid IR--in-placeβ β οΈ WARNING: this option will replace your input file with the reduced version! like she will literally eat your original file. back it up first bestie, i'm begging π--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--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 liste (that's their spelling, not mine π )--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 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β 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. it returns a non-zero exit code if there were any errors. that's the whole vibe check π
π₯ EXAMPLE π₯
llvm-reduce can be used to simplify a test that causes a compiler crash. (yes, this is the good part, stay with me π«Ά)
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.)
this example can be generalized to other tools that process IR files, for example llc. main character energy, honestly π
π AUTHOR π
maintained by the LLVM Team (https://llvm.org/).
π COPYRIGHT π
2003-2025, LLVM Project
k that's the whole page, you ate that π and just so you have the receipts: this was LLVM's LLVM-REDUCE(1) page, LLVM version 19, dated 2025-01-17. go forth and reduce, bestie π
π¦ where this page comes from
- opensuse-leap 16.0: llvm19 19.1.7-160000.2.2 Β· Apache-2.0 WITH LLVM-exception AND NCSA
- opensuse-leap 16.0: llvm19 19.1.7-160000.2.2 Β· Apache-2.0 WITH LLVM-exception AND NCSA
- opensuse-leap 16.0: llvm19 19.1.7-160000.2.2 Β· Apache-2.0 WITH LLVM-exception AND NCSA
- opensuse-leap 16.0: llvm19 19.1.7-160000.2.2 Β· Apache-2.0 WITH LLVM-exception AND NCSA
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms