OPT(1)

πŸ“¦ version 15.0.7, in opensuse-leap 16.0

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

okay so bestie, welcome to opt, the LLVM one. This page is from the LLVM manual set (section 1, we're fancy like that) and it's literally just the optimizer. Let me walk you through it 🫢


✨ NAME ✨

opt β€” the LLVM optimizer. that's her. that's the whole name. iconic πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

opt [options] [filename]

yes queen, that's it. options, maybe a filename, go off ✨


🌸 DESCRIPTION 🌸

okay so the tea β˜•: opt is the modular LLVM optimizer and analyzer. She's modular, she's flexible, she contains multitudes.

Here's the vibe: you hand her LLVM source files as input, she runs whatever optimizations or analyses you asked for on them, and then she hands you back the optimized file. Main character energy all around πŸ’–

Now β€” which optimizations can you actually use? That depends on what libraries were linked into her when she was built, plus any extra libraries you loaded in with the -load option. So it's giving "your mileage may vary" but in the most literal way possible. Use the -help option to figure out what optimizations you actually have available, bestie. Don't guess, just ask her 🌈

More details you need to know:

  • If filename is omitted from the command line, or if it's literally just -, opt reads its input from standard input. Very chill of her.
  • Inputs can be in either the LLVM assembly language format (.ll) or the LLVM bitcode format (.bc). Either one, she speaks both ✨
  • If you don't specify an output filename with the -o option, opt writes her output to the standard output. no -o, no problem πŸ’«

πŸŽ€ OPTIONS πŸŽ€

here's the full menu, no skips, no cuts, we're listing every single one because I'm not doing you dirty like that πŸ’–

  • -f β€” Enable binary output on terminals. Normally opt will refuse to write raw bitcode output if the output stream is a terminal (she's protecting you, and honestly? valid). With this option she'll write raw bitcode regardless of what the output device is. So like, she stops checking. You've been warned bestie πŸ™ˆ
  • -help β€” Print a summary of command line options. the classic "what can you even do" button πŸ’…
  • -o <filename> β€” Specify the output filename. where she drops her work πŸŽ€
  • -S β€” Write output in LLVM intermediate language (instead of bitcode). Reading it with your eyeballs? this one's for you ✨
  • -{passname} β€” okay this is the good part πŸ”₯ 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 sequence you type is the sequence she runs. Order matters, bestie, don't come for me when it does πŸ’€
  • -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. same energy, but first in line πŸ‘‘
  • -verify-each β€” This option causes opt to add a verify pass after every pass otherwise specified on the command line (including -verify). Useful for cases where you suspect a pass is creating an invalid module but it's genuinely not clear which pass is doing it. detective mode πŸ” she checks after literally every step
  • -stats β€” Print statistics. numbers!! πŸ“Š
  • -time-passes β€” Record the amount of time needed for each pass and print it to standard error. so you can find out exactly which pass is eating your afternoon 😭
  • -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. (note: if this is a debug build β€” normal builds, she stays quiet πŸ™ˆ)
  • -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

like adding DLC to your compiler, genuinely obsessed 🧚

  • -print-passes β€” Print all available passes and exit. just the list, nothing else, then she's out ✌️

⭐ 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 rule.


🌺 AUTHOR 🌺

Maintained by the LLVM Team (https://llvm.org/). the group chat admins fr fr 🫢


2003-2023, LLVM Project. all the legal bits, respectfully preserved πŸ‘‘


lowkey reminder bestie: every fact above is exactly what the page says β€” nothing added, nothing skipped. if a pass blows up your module, that's between you and -verify-each πŸ’€

and that's the page!! 🌈 written on 2023-01-14, page 15 of the manual, straight from the LLVM Project β€” mwah, go optimize something gorgeous πŸ’…βœ¨

πŸ“¦ where this page comes from