OPT(1)

πŸ’… opt β€” the LLVM optimizer, but make it make sense πŸ’…

ok so this is opt(1) from the LLVM fam β€” the modular LLVM optimizer and analyzer, and honestly she's kind of a big deal. bestie, let's get into it 🫢


✨ SYNOPSIS ✨

opt [options] [filename]

🌸 DESCRIPTION 🌸

okay so the opt command is literally the modular LLVM optimizer and analyzer. it takes LLVM source files as input, runs the optimizations or analyses you told it to run on them, and then spits out the optimized file. gorgeous, iconic, no notes πŸ’…

the optimizations available through opt depend on what libraries were linked into it, plus any extra libraries you loaded in with the -load option. so like, your opt and my opt might not have the same bag of tricks β€” check with -help to see what optimizations you've actually got. iykyk ✨

if filename is omitted from the command line, or if it's -, then opt reads its input from standard input. inputs can be in either the LLVM assembly language format (.ll) or the LLVM bitcode format (.bc). she's flexible like that πŸ¦‹

if you don't specify an output filename with the -o option, opt writes its output to the standard output. default behavior, lowkey slay.


πŸŽ€ OPTIONS πŸŽ€

  • -f β€” enables binary output on terminals. normally opt will refuse to write raw bitcode output if the output stream is a terminal (it's being protective of your poor little screen 😭). with this option, opt will write raw bitcode regardless of the output device. so yeah, you can override it, but like… she warned you.
  • -help β€” prints a summary of command line options. your bestie for figuring out what's even available πŸ’–
  • -o <filename> β€” specify the output filename. that's it, that's the whole job πŸŽ€
  • -S β€” write output in LLVM intermediate language (instead of bitcode). so you get the readable .ll vibe instead of the binary .bc vibe ✨
  • -{passname} β€” opt provides the ability to run any of LLVM's optimization or analysis passes, in any order. the -help option lists all the passes available. the order in which the options occur on the command line is the order in which they are executed (within pass constraints). so like, the order slays in a specific way β€” respect the constraints bestie πŸ‘‘
  • -strip-debug β€” this option causes opt to strip debug information from the module before applying other optimizations. it's essentially the same as -strip, but it ensures that the stripping of debug information is done first. first come, first stripped πŸ’€
  • -verify-each β€” this option causes opt to add a verify pass after every pass otherwise specified on the command line (including -verify). super useful when you suspect some pass is creating an invalid module but you literally cannot tell which pass is doing it. she'll narc on them for you πŸ•΅οΈβ€β™€οΈ
  • -stats β€” print statistics. numbers! data! we love her πŸ“Š
  • -time-passes β€” record the amount of time needed for each pass and print it to standard error. perfect for when you need to know exactly which pass is eating your whole afternoon 😭
  • -debug β€” if this is a debug build, this option will enable debug printouts from passes which use the LLVM_DEBUG() macro. see the LLVM Programmer's Manual <../ProgrammersManual.html>, section #DEBUG for more information. (note the "if this is a debug build" β€” she's conditional, not magic πŸ™ˆ)
  • -load=<plugin> β€” load the dynamic object plugin. this object should register new optimization or analysis passes. once loaded, the object will add new command line options to enable various optimizations or analyses. and to see the new complete list of optimizations, use the -help and -load options together, like this:
opt -load=plugin.so -help

that's the move. load first, then -help, then go off πŸ’…

  • -print-passes β€” print all available passes and exit. short, sweet, informative, iconic ✨

πŸ”₯ EXIT STATUS πŸ”₯

if opt succeeds, it will exit with 0 πŸŽ‰. otherwise, if an error occurs, it will exit with a non-zero value πŸ’€. that's the whole vibe check.


🧚 Author 🧚

maintained by the LLVM Team (https://llvm.org/). they're the main characters here, fr fr πŸ‘‘

2003-2026, LLVM Project β€” yeah, they've been at this a minute. respect the legacy 🫢


okay that's the whole page bestie, go optimize something and slay πŸ’œβœ¨

signed, sealed, and delivered by the LLVM version 21 crew, dated 2026-05-15 β€” OPT(1), periodt πŸŽ€

πŸ“¦ where this page comes from