LLVM-REDUCE(1)

πŸ’… LLVM-REDUCE(1) β€” the LLVM automatic testcase reducer, bestie edition

okay so you've stumbled into the LLVM manual pages and this one is genuinely iconic: llvm-reduce is the LLVM automatic testcase reducer ✨


🌸 NAME 🌸

llvm-reduce β€” LLVM automatic testcase reducer. that's it, that's the vibe πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

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

πŸ’– DESCRIPTION πŸ’–

so llvm-reduce is a 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 β€” like, it's giving "declutter my life but keep the important receipts" energy πŸ’…

if input is -, llvm-reduce reads from standard input. otherwise, it will read from the specified filenames. super simple, no notes 🫢

ngl, 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. literally the main character of your debugging session πŸ‘‘


✨ GENERIC OPTIONS ✨

  • --help β€” Display available options (--help-hidden for more). yes queen, read the docs πŸ“–
  • --abort-on-invalid-reduction β€” Abort if any reduction results in invalid IR. like, if the reduction goes off the rails, we stop, periodt πŸ’€
  • --in-place β€” WARNING: This option will replace your input file with the reduced version! 🚨 bestie please back that file up first, i'm begging 😭
  • --ir-passes=<string> β€” a textual description of the pass pipeline, same as what's passed to opt -passes. yep, same thing, no cap πŸ”₯
  • -j <uint> β€” Maximum number of threads to use to process chunks. Set to 1 to disable parallelism. multitasking but make it configurable 🧚
  • --max-pass-iterations=<int> β€” Maximum number of times to run the full set of delta passes (default=5). five rounds, then we're done 🌈
  • --mtriple=<string> β€” Set the target triple. tell it where it's going 🎯
  • --preserve-debug-environment β€” Don't disable features used for crash debugging (crash reports, llvm-symbolizer and core dumps). keep the receipts for the crash investigation πŸ™ˆ
  • --print-delta-passes β€” Print list of delta passes, passable to --delta-passes as a comma separated list. window shopping for passes, obsessed πŸ›οΈ
  • --skip-delta-passes=<string> β€” Delta passes to not run, separated by commas. By default, run all delta passes. it's giving "nah, not that one" πŸ’…
  • --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. like zooming in on a photo β€” low granularity is the whole pic, high granularity is, like, one eyebrow πŸ”
  • --test=<string> β€” Name of the interesting-ness test to be run. the vibe check, essentially ⭐
  • --test-arg=<string> β€” Arguments passed onto the interesting-ness test. extra notes for the vibe check πŸŽ€
  • --verbose β€” Print extra debugging information. yes, talk to me, tell me everything πŸ—£οΈ
  • --write-tmp-files-as-bitcode β€” Always write temporary files as bitcode instead of textual IR. bitcode era, no exceptions πŸ’Ύ
  • -x={ir|mir} β€” Input language as ir or mir. pick your fighter 🌸

πŸ‘‘ EXIT STATUS πŸ‘‘

llvm-reduce returns 0 under normal operation. it returns a non-zero exit code if there were any errors. slay when it works, sad girl hours when it doesn't 😭


πŸ“ EXAMPLE πŸ“

llvm-reduce can be used to simplify a test that causes a compiler crash. classic 🩸

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.) iykyk πŸ”₯

this example can be generalized to other tools that process IR files, for example llc. the technique is transferable, bestie πŸ’œ


🧚 Author 🧚

maintained by the LLVM Team (https://llvm.org/). shoutout to the maintainers, absolute icons 🫢

2003-2026, LLVM Project β€” yeah, they've been at it since before you were born, respectfully πŸ‘΅βœ¨


and that's the whole page, bestie! this cutie came from the LLVM pages, page 15, dated 2026-09-09, and it's filed under LLVM-REDUCE(1) β€” periodt. go reduce something and text me how it goes πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from