LLVM-REDUCE(1)
π¦ LLVM-REDUCE(1) β llvm-reduce, the LLVM automatic testcase reducer π¦
π NAME π
Okay so this is llvm-reduce β LLVM automatic testcase reducer. Periodt. It's the main character of testcase shrinking, and we're obsessed. π
β¨ SYNOPSIS β¨
llvm-reduce [options] [input...]
Bestie, that's the whole vibe: options plus input. π«Ά
πΈ DESCRIPTION πΈ
llvm-reduce is the tool/project that can be 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. Slay. That's the whole point.
If input is -, llvm-reduce reads from standard input. Otherwise, it will read from the specified filenames. No cap.
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. Iconic behavior, honestly. π«Ά
π GENERIC OPTIONS π
--helpβ display available options (--help-hiddenfor more). The "more" is giving secret menu, iykyk. π--abort-on-invalid-reductionβ abort if any reduction results in invalid IR. No invalid-IR nonsense allowed. π--in-placeβ WARNING: this option will replace your input file with the reduced version! π«£ Not me accidentally nuking my own input file. Be so careful.--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 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 list of delta passes, passable to--delta-passesas a comma separated liste.--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. β¨
--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. Highkey useful when you want the full tea. β--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. Returns 2 if the interestingness test reported the initial input was not interesting. So if you see 2, the test said "nah, not interesting" from the jump. Vibe check: failed. π
π EXAMPLE π
llvm-reduce can be used to simplify a test that causes a compiler crash. Classic main-character bug energy. π₯
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.
π AUTHOR π
Maintained by the LLVM Team (https://llvm.org/). Shoutout to the maintainers, fr fr. π«Ά
π COPYRIGHT π
2003-2026, LLVM Project
π cute sign-off: source/version is LLVM, date is 2026-10-06, page 23, manual page LLVM-REDUCE(1). Byeee bestie, go reduce something iconic! π
β¨
π¦ where this page comes from
- centos-stream 9: llvm 23.1.3-1.el9 Β· Apache-2.0 WITH LLVM-exception OR NCSA
- centos-stream 9: llvm 23.1.3-1.el9 Β· Apache-2.0 WITH LLVM-exception OR NCSA
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms