OPT(1)

๐Ÿ’… OPT โ€” the LLVM optimizer (yes bestie, opt(1) from the LLVM manual)

okay so picture this: it's giving compiler-core, it's giving main character energy, and it's literally the tool every LLVM girlie needs in her back pocket. ๐Ÿซถ


โœจ NAME โœจ

opt โ€” the LLVM optimizer. that's it. that's the vibe. ๐Ÿ‘‘


๐ŸŒธ SYNOPSIS ๐ŸŒธ

opt [options] [filename]

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

so opt is the modular LLVM optimizer and analyzer โ€” it does both, she contains multitudes ๐Ÿ’…. You feed it LLVM source files as input, it runs whatever optimizations or analyses you asked for, and then it outputs the optimized file. slay.

here's the thing though: which optimizations you actually get depends on what libraries were linked into it, plus any extra libraries you loaded with the -load option. so if you're like "where is my pass ๐Ÿ˜ญ" โ€” check that first. and use the -help option to figure out exactly what optimizations are available to you. 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 your inputs can be in either the LLVM assembly language format (.ll) or the LLVM bitcode format (.bc) โ€” both are iconic, both are welcome here โœจ.

and if you don't specify an output filename with the -o option? opt writes its output to standard output. periodt.


๐ŸŽ€ OPTIONS ๐ŸŽ€

  • -f โ€” enables binary output on terminals. normally opt will straight-up refuse to write raw bitcode output if the output stream is a terminal (she's protective like that ๐Ÿ™ˆ), but with this option she'll write raw bitcode regardless of the output device. no vibe check, just bytes.
  • -help โ€” prints a summary of command line options. your bestie when you're lost ๐ŸŒˆ.
  • -o <filename> โ€” specify the output filename. simple, elegant, iconic.
  • -S โ€” write output in LLVM intermediate language instead of bitcode. so like, human-readable-ish instead of the crunchy binary stuff ๐Ÿ“.
  • -passes=<string> โ€” a textual (comma-separated) description of the pass pipeline, e.g. -passes="sroa,instcombine". see invoking opt <../NewPassManager.html#invoking-opt> for more details on the pass pipeline syntax. this is the one you'll be typing a million times, ngl.
  • -mtune=<cpuname> โ€” specify a specific chip microarchitecture in the current architecture to tune code for. by default this is inferred from the target triple and autodetected to the current architecture. for a list of available tuning CPUs, use:
llvm-as < /dev/null | opt -march=xyz -mtune=help

lowkey my favorite incantation, it's giving spellwork ๐Ÿงš

  • -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, bestie ๐Ÿ’€
  • -verify-each โ€” this option causes opt to add a verify pass after every pass otherwise specified on the command line (including -verify). super useful for those cases where you suspect a pass is creating an invalid module but you have no idea which pass is doing it โ€” the classic "who did this ๐Ÿ˜ญ" situation.
  • -stats โ€” print statistics. numbers! data! we love her ๐Ÿ“Š
  • --save-stats, --save-stats=cwd, --save-stats=obj โ€” save LLVM statistics to a file in the current directory (--save-stats/--save-stats=cwd) or the directory of the output file (--save-stats=obj), in JSON format. fancy โœจ
  • -time-passes โ€” record the amount of time needed for each pass and print it to standard error. great for when you need to know which pass is eating all your minutes โฑ๏ธ
  • -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 <../ProgrammersManual.html>, section #DEBUG for more information. debug build only, so don't come for her if it does nothing on release ๐Ÿ™ˆ
  • -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

yes, you can stack them. we stan a modular queen ๐Ÿ‘‘

  • -print-passes โ€” print all available passes and exit. like a little yearbook of every pass she knows ๐Ÿ“–

๐Ÿ’€ EXIT STATUS ๐Ÿ’€

if opt succeeds, she will exit with 0 โ€” we love a clean win ๐ŸŽ‰. otherwise, if an error occurs, she'll exit with a non-zero value. so if your script's $? is acting sus, you know what's up.


๐Ÿ’– Author ๐Ÿ’–

maintained by the LLVM Team (https://llvm.org/). absolute legends, fr fr ๐Ÿซถ


2003-2026, LLVM Project. that's a long-running main character era, honestly.


and that's the whole page bestie ๐Ÿ’… โ€” LLVM release 23, dated 2026-10-20, opt(1), signing off ๐Ÿฆ‹โœจ

๐Ÿ“ฆ where this page comes from
  • arch rolling: llvm 23.1.4-1 ยท Apache-2.0 WITH LLVM-exception
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms