OPT(1)

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

okay bestie, listen β€” this is the manual page for opt from the LLVM crew, and by the end of this you're gonna be running optimization passes like it's nothing. no cap. πŸ¦‹


✨ NAME ✨

opt β€” the LLVM optimizer. that's it, that's the whole vibe. she optimizes. πŸ’…


✨ SYNOPSIS ✨

opt [options] [filename]

literally just options and maybe a file. we love a simple girl. πŸŽ€


✨ DESCRIPTION ✨

so opt is the modular LLVM optimizer and analyzer. she takes LLVM source files as input, runs whatever optimizations or analyses you told her to run, and then hands you back either the optimized file or the analysis results. the way she behaves depends entirely on whether you passed the -analyze option. main character energy, honestly ✨

when -analyze is specified, opt does a bunch of analyses of the input source. she'll usually print the results on standard output, but in a few cases she'll print output to standard error or straight-up generate a file with the analysis output β€” which, fyi, is usually what happens when the output is meant for another program. iykyk. πŸ’€

when -analyze is not given, opt tries to produce an optimized output file instead. the optimizations you get through opt depend on what libraries were linked into it plus any extra libraries you loaded with the -load option. to find out which optimizations are actually available to you, use the -help option. go on, she tells you everything. πŸ‘‘

if filename is omitted from the command line, or if it's literally β€œ-”, 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). both icons, tbh. πŸ’–

and if you don't specify an output filename with the -o option, opt writes its output to standard output. simple. gorgeous. no notes. 🌸


✨ OPTIONS ✨

  • -f β€” enables binary output on terminals. normally opt refuses to write raw bitcode output when the output stream is a terminal, but with this option she'll write raw bitcode regardless of the output device. chaotic. love her. πŸ’…
  • -help β€” prints a summary of command line options. your girl is an open book. πŸ“–
  • -o <filename> β€” specifies the output filename.
  • -S β€” writes output in LLVM intermediate language instead of bitcode.
  • -{passname} β€” opt can run any of LLVM's optimization or analysis passes, in any order. the -help option lists all the passes available. and here's the tea: the order in which the options occur on the command line is the order in which they are executed (within pass constraints, obviously β€” she has boundaries). ✨
  • -strip-debug β€” makes opt strip debug information from the module before applying other optimizations. it's essentially the same as -strip, but it makes sure that stripping of debug information happens first. first. always first. she's organized like that. πŸŽ€
  • -verify-each β€” makes opt add a verify pass after every pass otherwise specified on the command line (including -verify). super useful when you suspect a pass is creating an invalid module but you have no idea which pass is the culprit. it's giving detective. πŸ”
  • -stats β€” prints statistics. numbers! data! slay! πŸ“Š
  • -time-passes β€” records the amount of time needed for each pass and prints it to standard error. ⏱️
  • -debug β€” if this is a debug build, this option enables debug printouts from passes that use the LLVM_DEBUG() macro. see the LLVM Programmer's Manual, section #DEBUG for more info. nerd mode: activated. πŸ€“
  • -load=<plugin> β€” loads the dynamic object plugin. this object should register new optimization or analysis passes. once loaded, the object adds 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
  • -print-passes β€” prints all available passes and exits. then she's out. bye bestie. πŸ‘‹

✨ EXIT STATUS ✨

if opt succeeds, she exits with 0. otherwise, if an error occurs, she exits with a non-zero value. she keeps it real either way. πŸ’―


✨ AUTHOR ✨

maintained by the LLVM Team (https://llvm.org/). they're the ones keeping this whole thing alive, show them some love. 🫢


2003-2025, LLVM Project β€” yeah, that's over two decades of optimization. generational. πŸ‘‘


okay so quick recap before you go: opt = modular LLVM optimizer + analyzer, -analyze flips her into analysis mode, no -analyze means optimized output file, no filename or β€œ-” means stdin, no -o means stdout. the rest is just vibes and passes. πŸ’–

and that's the whole page, bestie!! this was opt(1) from the LLVM manual, page 14, dated 2025-05-22. go optimize something iconic. πŸŒˆβœ¨πŸ¦‹

πŸ“¦ where this page comes from