OPT(1)
π OPT(1) β the LLVM optimizer, but make it make sense
okay bestie, gather round, because this is opt(1) from the LLVM manual and it's genuinely one of the most useful little tools in the whole compiler-nerd universe π«Ά
β¨ NAME β¨
opt β the LLVM optimizer π no cap, that's literally its whole job.
πΈ SYNOPSIS πΈ
opt [options] [filename]
π¦ DESCRIPTION π¦
so the opt command is the modular LLVM optimizer and analyzer β¨ and here's the vibe: it takes LLVM source files as input, runs whatever optimizations or analyses you told it to run, and then outputs the optimized file. that's it. that's the whole main character moment.
the optimizations available through opt depend on what libraries were linked into it as well as any additional libraries you loaded in with the -load option π so it's giving "your mileage may vary, bestie." use the -help option to figure out which optimizations you actually have access to π
if filename is left out of the command line, or if it's -, opt reads its input from standard input. and the inputs can be in either the LLVM assembly language format (.ll) or the LLVM bitcode format (.bc) π
and if you don't specify an output filename with the -o option, opt writes its output straight to standard output. iconic behaviour, honestly.
π OPTIONS π
-fβ enables binary output on terminals π normallyoptflat-out refuses to write raw bitcode output if the output stream is a terminal, but with this option it'll write raw bitcode regardless of what the output device is. chaotic, but slay.-helpβ prints a summary of the command line options. your bestie when you're lost.-o<filename>β specifies the output filename π-Sβ writes the output in LLVM intermediate language instead of bitcode. that's the.llvibe, not the.bcvibe β¨-{passname}βoptgives you the ability to run any of LLVM's optimization or analysis passes, in any order π the-helpoption lists all the passes available to you. and the order in which the options occur on the command line is the order in which they're executed (within pass constraints). so like, order matters, bestie, don't come for me.-strip-debugβ makesoptstrip debug information from the module before applying other optimizations. it's essentially the same as-strip, but it makes sure the stripping of debug info happens first π§-verify-eachβ makesoptadd a verify pass after every pass otherwise specified on the command line (including-verify) π₯ this is genuinely so useful when you suspect a pass is creating an invalid module but you can't tell which pass is the culprit. detective mode: activated π΅οΈββοΈ-statsβ prints statistics π-time-passesβ records how much time each pass needed and prints it to standard error β±οΈ-debugβ if this is a debug build, this option enables debug printouts from passes that use theLLVM_DEBUG()macro. see the LLVM Programmer's Manual, section#DEBUGfor more info π-load=<plugin>β loads the dynamic object plugin. this object should register new optimization or analysis passes β¨ once loaded, the object adds new command line options that enable various optimizations or analyses. to see the new complete list of optimizations, use-helpand-loadtogether. for example:
opt -load=plugin.so -help
-print-passesβ prints all available passes and exits π like a little parade of passes, then it dips.
ok real talk for a sec:-fis the one where you're overriding a safety-ish default (writing raw bitcode to a terminal).optnormally refuses for a reason β so use it on purpose, not by accident π
β EXIT STATUS β
if opt succeeds, it exits with 0 π otherwise, if an error occurs, it exits with a non-zero value. sad girl hours π
π AUTHOR π
maintained by the LLVM Team (https://llvm.org/) π«Ά
π COPYRIGHT π
2003-2023, LLVM Project
alright bestie, that's the whole page π go optimize something and think of me. this was LLVM, page 15, dated 2023-07-14, and that's the vibe check: passed β
periodt π
π¦ where this page comes from
- ubuntu jammy: llvm-15 1:15.0.7-0ubuntu0.22.04.3 Β· APACHE-2-LLVM-EXCEPTIONS
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms