OPT(1)

πŸ‘‘ opt β€” the LLVM optimizer, but make it a group chat

okay so real quick, this is the man page for opt from the LLVM manual set (that's OPT(1), bestie, and yes the whole thing is about LLVM) πŸ’…

πŸ’– NAME πŸ’–

opt β€” the modular LLVM optimizer and analyzer. that's it. that's the whole name. iconic.

✨ SYNOPSIS ✨

opt [options] [filename]

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so picture this: opt is the modular LLVM optimizer and analyzer β€” it does both, main character energy fr. you hand it LLVM source files as input, it runs whatever optimizations or analyses you told it to, and then it outputs the optimized file. slay.

but here's the tea πŸ«– β€” the optimizations you actually get via opt depend on what libraries were linked into it, plus any extra libraries you loaded with the -load option. so like, your opt and my opt might be different girlies. use the -help option to find out what optimizations you can use. iykyk.

if filename is omitted from the command line, or if it's literally just -, then opt reads its input from standard input. no cap. and the inputs can be in either the LLVM assembly language format (.ll) or the LLVM bitcode format (.bc) β€” either one works, we're flexible πŸ’β€β™€οΈ

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


🌸 OPTIONS 🌸

  • -f β€” enable binary output on terminals. normally opt will refuse to write raw bitcode output if the output stream is a terminal (she's got boundaries βœ‹). with this option, opt will write raw bitcode regardless of the output device. it's giving "i do what i want."
  • -help β€” print a summary of command line options. your bestie when you're lost 🫢
  • -o filename β€” specify the output filename. that's it, that's the vibe.
  • -S β€” write output in LLVM intermediate language instead of bitcode. uppercase S, very demure, very mindful.
  • -{passname} β€” okay this one's the moment πŸ”₯ 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. and the order in which the options occur on the command line is the order in which they're executed (within pass constraints β€” she has rules). so like, order matters, bestie. don't come for me.
  • -strip-debug β€” this option makes opt 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 happens first. priority queen πŸ‘‘
  • -verify-each β€” this 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 you literally cannot tell which pass is doing it 😭 it's the "who among us" option, fr.
  • -stats β€” print statistics. numbers! data! she's analyzing πŸ’…
  • -time-passes β€” record the amount of time needed for each pass and print it to standard error. basically a screen time report for your passes πŸ™ˆ
  • -debug β€” if this is a debug build, this option enables debug printouts from passes which use the LLVM_DEBUG() macro. see the LLVM Programmer's Manual, section #DEBUG for more info. only works on debug builds, so don't come crying to me if it does nothing ngl.
  • -load=plugin β€” load 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

that's the combo meal right there πŸ“

  • -print-passes β€” print all available passes and exit. no notes, she said what she said.

πŸ’€ EXIT STATUS πŸ’€

if opt succeeds, it will exit with 0. πŸŽ‰ otherwise, if an error occurs, it will exit with a non-zero value. so like, check your exit codes, bestie. 0 = we ate. non-zero = something's up.

🧚 AUTHOR 🧚

maintained by the LLVM Team (https://llvm.org/). we stan a whole team keeping it alive πŸ’œ

2003-2023, LLVM Project β€” that's a two-decade run, literally legendary behavior.


okay that's the whole page, you're welcome, go optimize something and text me how it goes πŸŽ€

sign-off gossip: this page is number 17 in the man set, dated 2023-12-01, and it belongs to OPT(1). catch you on the next one, bestie πŸ’–
πŸ“¦ where this page comes from