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. normallyoptwill 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 causesoptto 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 causesoptto 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 theLLVM_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-helpand-loadoptions 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 ๐ซถ
๐ Copyright ๐
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