OPT(1)

πŸ“¦
version 12.0.1 Β· 4 versions
, in fedora 43, fedora 44

✨ OPT(1) β€” the LLVM optimizer, but make it a vibe ✨

okay bestie, welcome to the opt manual page πŸ’– this is LLVM's very own section 1 page, and by the end of it you're gonna be running passes like it's nothing. no cap.


🌸 SYNOPSIS 🌸

opt [options] [filename]

πŸ¦‹ DESCRIPTION πŸ¦‹

So like, opt is the modular LLVM optimizer and analyzer. It's giving main character energy fr. You feed it LLVM source files as input, it runs whatever optimizations or analyses you asked for, and then it outputs either the optimized file or the analysis results. The whole personality of opt depends on whether you passed the -analyze option. Like, that flag is the vibe check. πŸ’…

When -analyze is specified, opt runs a bunch of analyses on the input source. Usually it prints the results to standard output, but in a few cases it'll print to standard error or straight up generate a file with the analysis output β€” which is typically what happens when the output is meant for another program to consume. iykyk 🫢

When -analyze is not given, opt tries to produce an optimized output file instead. Which optimizations you actually get depends on what libraries got linked into it, plus any extra libraries you loaded with the -load option. Not sure what's on the menu? Just hit the -help option and it'll tell you which optimizations you can use. periodt. ✨

If filename is omitted from the command line, or if it's "-", 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 slay, honestly. 🌈

And if you didn't specify an output filename with the -o option? opt writes its output to standard output. Simple as that, babe.


πŸ’… OPTIONS πŸ’…

  • -f β€” enables binary output on terminals. Normally opt flat out refuses to write raw bitcode output if the output stream is a terminal (it's being protective, okay 😭). With this option, opt writes raw bitcode no matter what the output device is.
  • -help β€” prints a summary of the command line options. your bestie when you're lost. πŸŽ€
  • -o <filename> β€” specify the output filename. that's it, that's the whole thing.
  • -S β€” write output in LLVM intermediate language instead of bitcode. iconic behavior.
  • -{passname} β€” opt lets you run any of LLVM's optimization or analysis passes, in any order. The -help option lists all the passes available. The order the options show up on the command line is the order they get executed in (within pass constraints, obviously, we're not chaotic). πŸ”₯
  • -disable-inlining β€” simply removes the inlining pass from the standard list. bye bestie πŸ‘‹
  • -disable-opt β€” this one is only meaningful when -std-link-opts is given. It disables most passes.
  • -strip-debug β€” causes opt to strip debug information from the module before applying other optimizations. It's essentially the same as -strip, except it guarantees that the stripping of debug information happens first. order matters, queen. πŸ‘‘
  • -verify-each β€” causes opt to add a verify pass after every pass otherwise specified on the command line (including -verify). This is so useful when you suspect a pass is creating an invalid module but you have no idea which pass is the culprit. detective mode activated πŸ•΅οΈ
  • -stats β€” print statistics.
  • -time-passes β€” record the amount of time needed for each pass and print it to standard error. clocking the girls ⏱️
  • -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.
  • -load=<plugin> β€” load the dynamic object plugin. This object should register new optimization or analysis passes. Once it's loaded, the object adds new command line options to enable various optimizations or analyses. Wanna 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. little progress pics for your IR πŸ“Έ

πŸ’€ EXIT STATUS πŸ’€

If opt succeeds, it exits with 0. Otherwise, if an error occurs, it exits with a non-zero value. no in-between, she's decisive.


🫢 AUTHOR 🫢

Maintained by the LLVM Team (<https://llvm.org/>). yes they're the blueprint, we love them.


2003-2024, LLVM Project


and that's the whole page bestie πŸŽ€ this was opt from the LLVM manual, page 12, dated 2024-07-18 β€” go optimize something and make it iconic βœ¨πŸ’œ

πŸ“¦ where this page comes from