OPT(1)

πŸŽ€ OPT(1) β€” the LLVM optimizer, but make it make sense πŸŽ€

okay so bestie, welcome to opt(1), the LLVM manual page. yes it's a manpage, no it doesn't have to be boring. let's get into it πŸ’…


✨ NAME ✨

opt β€” the LLVM optimizer. that's it, that's the vibe. it optimizes. it analyzes. it slays.


🌸 SYNOPSIS 🌸

opt [options] [filename]

πŸ¦‹ DESCRIPTION πŸ¦‹

so opt is literally the modular LLVM optimizer and analyzer, which is a fancy way of saying it does two jobs and does both of them iconically. it takes LLVM source files as input, runs whatever optimizations or analyses you told it to, and then outputs the optimized file. main character energy fr fr 🫢

now here's the tea: the optimizations you can actually use through opt depend on what libraries were linked into it, plus any extra libraries you loaded with the -load option. so it's not a fixed menu, it's more like a customizable little outfit. use the -help option to figure out what optimizations you actually have access to πŸ‘‘

if filename is omitted from the command line, or if it's -, then opt reads its input from standard input. and your inputs can be in either:

  • the LLVM assembly language format (.ll), or
  • the LLVM bitcode format (.bc)

either one, no stress πŸ’–

and if you don't specify an output filename with the -o option, opt writes its output to standard output. so like, it just goes straight out into the world. no cap.


πŸ’œ OPTIONS πŸ’œ

  • -f β€” enable binary output on terminals. normally opt will straight up refuse to write raw bitcode output if the output stream is a terminal (it's giving protective bestie energy), but with this option opt will write raw bitcode regardless of the output device. do with that information what you will πŸ™ˆ
  • -help β€” print a summary of command line options. your little cheat sheet. your map. your bestie pointing at the menu ✨
  • -o <filename> β€” specify the output filename. that's the one.
  • -S β€” write output in LLVM intermediate language instead of bitcode. so you get the human-readable-ish version, not the raw bytes. we love a readable moment πŸŽ€
  • -{passname} β€” okay this is the big one, the iconic one. opt gives you the ability to run any of LLVM's optimization or analysis passes, in any order. the -help option lists all the passes available to you. and the order in which the options occur on the command line is the order in which they get executed (within pass constraints β€” the constraints said no to total chaos 😭). so like, the way you list them? that's the way they run. periodt.
  • -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 happens first. first! no cutting the line 🧚
  • -verify-each β€” this option causes opt to add a verify pass after every pass otherwise specified on the command line (including -verify). this is useful for cases where it's suspected that a pass is creating an invalid module but it's not clear which pass is doing it. like a little detective checking everyone's work at the door πŸ”₯
  • -stats β€” print statistics. numbers! data! we love a quantified moment ⭐
  • -time-passes β€” record the amount of time needed for each pass and print it to standard error. so you know exactly which pass is taking forever (there's always one πŸ’€)
  • -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, section #DEBUG for more information. ngl this one's for the build engineers, but respect 🫢
  • -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. to see the new complete list of optimizations, use the -help and -load options together. for example:
opt -load=plugin.so -help

iconique. load it, then ask what it can do πŸ’…

  • -print-passes β€” print all available passes and exit. just a full roster, no further obligations, bye 🌈

πŸ’€ EXIT STATUS πŸ’€

if opt succeeds, it will exit with 0. otherwise, if an error occurs, it will exit with a non-zero value. clean success, messy failure, no in-between 😀


πŸ‘‘ AUTHOR πŸ‘‘

maintained by the LLVM Team (https://llvm.org/). absolute legends.


2003-2025, LLVM Project


okay that's the whole page bestie, you're officially caught up. and yes, this was page 19, dated 2025-01-17, brought to you by the LLVM girlies. now go optimize something and make it iconic πŸ¦‹πŸ’–βœ¨

πŸ“¦ where this page comes from