OPT(1)

✨ OPT(1) β€” it's giving "the LLVM optimizer" πŸ’…

okay so bestie, pull up a chair, we're talking about opt from the LLVM manual, section 1 (that's the user commands section, iykyk). this is the glow-up page. let's get into it 🫢


🌸 NAME 🌸

opt β€” the LLVM optimizer. literally what it says on the tin, no cap. ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

opt [options] [filename]

that's it. that's the whole vibe. ✨


πŸ’– DESCRIPTION πŸ’–

okay so opt is the modular LLVM optimizer and analyzer πŸ‘‘. here's the tea:

  • it takes LLVM source files as input πŸ“
  • it runs the optimizations or analyses you told it to run on them πŸ”₯
  • then it outputs the optimized file πŸ’…

and here's the part that gets people: the optimizations available via opt depend upon what libraries were linked into it, as well as any additional libraries that have been loaded with the -load option. so like, it's not a fixed menu, it's a build-your-own-sundae situation 🍨. to find out what optimizations you can actually use, hit up the -help option. periodt.

now, about input πŸ“₯: if filename is omitted from the command line, or is "-", then opt reads its input from standard input. flexible queen πŸ’….

inputs can be in either of these formats, and yes you can mix and match, she doesn't judge:

  • LLVM assembly language format (.ll) πŸ“
  • LLVM bitcode format (.bc) 🧊

and for output πŸ“€: if you don't specify an output filename with the -o option, opt writes its output to the standard output. so like, if you don't tell her where to put it, she's just gonna yell it at your terminal. iconic honestly 🌈.


πŸŽ€ OPTIONS πŸŽ€

here come the flags, bestie. every single one. buckle up πŸ¦‹

  • -f β€” Enable binary output on terminals. normally opt will refuse to write raw bitcode output if the output stream is a terminal (she's polite like that πŸ™ˆ). with this option, opt will write raw bitcode regardless of the output device. so yeah, this is the "i know what i'm doing, let me cook" flag πŸ’€.
  • -help β€” print a summary of command line options. your bestie for figuring out what's even available ✨.
  • -o <filename> β€” specify the output filename. that's the whole thing. where the output goes πŸ“€.
  • -S β€” write output in LLVM intermediate language (instead of bitcode). the "give me the readable stuff please" flag πŸ“.
  • -{passname} β€” okay this one is lowkey the main character πŸ‘‘. 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. and here's the crucial bit: the order in which the options occur on the command line are the order in which they are executed (within pass constraints). so the order you type them = the order they run. sequencing matters, bestie, no cap 🫢.
  • -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 stripping of debug information is done first. order matters, we love a priority queen πŸ’….
  • -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 a pass is creating an invalid module but it's not clear which pass is doing it β€” she snitches on the culprit πŸ”.
  • -stats β€” print statistics. numbers! data! πŸ“Š
  • -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
  • -print-passes β€” print all available passes and exit. she shows you the menu and then immediately leaves πŸšͺπŸ’¨.

πŸ’€ EXIT STATUS πŸ’€

  • if opt succeeds, it will exit with 0. we love a clean win πŸŽ‰
  • otherwise, if an error occurs, it will exit with a non-zero value. something went wrong, bestie 😭

🫢 AUTHOR 🫢

maintained by the LLVM Team (<https://llvm.org/>). they're the ones keeping this whole thing running, respect πŸ‘‘


2003-2025, LLVM Project 🌈


okay that's the whole page bestie, you ate that reading πŸŽ€ and just so you know, this page is from the LLVM source, dated 2025-09-03 πŸ’… go forth and optimize, no cap πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from