OPT(1)

πŸ“¦
version 11.1.0 Β· 2 versions
, in fedora 43, fedora 44

✨ NAME ✨

okay bestie, gather round πŸ’– this is opt β€” the LLVM optimizer, and she's the main character of your whole compiler pipeline. (It's a page from the LLVM manual, section 1, iykyk.)


πŸ¦‹ SYNOPSIS πŸ¦‹

opt [options] [filename]

🌸 DESCRIPTION 🌸

so opt is the modular LLVM optimizer and analyzer β€” she does both, she contains multitudes πŸ’…. You hand her LLVM source files as input, she runs whatever optimizations or analyses you asked for, and then she gives you back the optimized file or the analysis results. Which of those two things she does depends entirely on whether you passed the -analyze option. It's giving two moods, one binary.

When -analyze is specified, opt runs a bunch of analyses on your input source. Most of the time she'll print the results to standard output, but in a few cases she'll print to standard error instead, or straight-up generate a file with the analysis output β€” which usually happens when that output is meant to be eaten by another program. πŸ“

When -analyze is not given, opt tries to produce an optimized output file. Now listen, the optimizations you can actually use through opt depend on what libraries got linked into her, plus any extra libraries you loaded with the -load option. So use the -help option to see what optimizations you've got available. No guessing, bestie, just ask her. ✨

If filename is omitted from the command line, or if it's just -, 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) β€” either one, she's flexible. 🌈

And if you don't specify an output filename with the -o option, opt writes her output to standard output. Default behaviour, no notes.


πŸ’… OPTIONS πŸ’…

  • -f β€” Enable 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 no matter what the output device is. She's being brave, okay 😭
  • -help β€” Print a summary of command line options.
  • -o <filename> β€” Specify the output filename.
  • -S β€” Write output in LLVM intermediate language instead of bitcode.
  • -{passname} β€” opt can run any of LLVM's optimization or analysis passes, in any order, and that's iconic honestly. 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 get executed (within pass constraints, obviously β€” she has rules).
  • -disable-inlining β€” This option simply removes the inlining pass from the standard list. Gone. Not invited.
  • -disable-opt β€” This option is only meaningful when -std-link-opts is given. It disables most passes. (Read that again: only meaningful with -std-link-opts. Otherwise she's just standing there.)
  • -strip-debug β€” This option causes opt to strip debug information from the module before applying other optimizations. It's essentially the same as -strip, except it makes sure the stripping of debug information happens first. Order matters, periodt.
  • -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 have no idea which one is doing it. Detective mode πŸ”₯
  • -stats β€” Print statistics.
  • -time-passes β€” Record the amount of time needed for each pass and print it to standard error.
  • -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.
  • -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
  • -p β€” Print module after each transformation. She's showing her work πŸ’–

πŸŽ€ EXIT STATUS πŸŽ€

If opt succeeds, she exits with 0. Otherwise, if an error occurs, she exits with a non-zero value. That's it, that's the whole vibe check.


πŸ‘‘ AUTHOR πŸ‘‘

Maintained by the LLVM Team (https://llvm.org/).


2003-2024, LLVM Project


okay that's the whole page bestie, go optimize something slay πŸ’…βœ¨ this was opt, from LLVM, version 11, dated 2024-07-18 β€” mwah, love u, bye 🫢🌸

πŸ“¦ where this page comes from