[llvm-dev] LLVM log file
David Chisnall via llvm-dev
llvm-dev at lists.llvm.org
Tue Jan 26 01:46:52 PST 2021
On 26/01/2021 02:53, Stefanos Baziotis via llvm-dev wrote:
> Alright, now to use that: This is _not_ an option of Clang (or the Clang
> driver; i.e., the command: clang test.c -print-after-all won't work),
> but an option of opt. opt, in case you're not familiar with it, is
> basically the middle-end optimizer of LLVM
I think this is sufficiently close to being true that it ends up being
very misleading. I've seen a lot of posts on the mailing lists from
people who have a mental model of LLVM like this.
The opt tool is a thin wrapper around the LLVM pass pipeline
infrastructure. Most of the command-line flags for opt are not specific
to opt, they are exposed by LLVM libraries. Opt passes all of its
arguments to LLVM, clang passes only the ones prefixed with -mllvm, but
they are both handled by the same logic.
Opt has some default pipelines with names such as -O1 and -O3 but these
are *not* the same as the pipelines of the same names in clang (or other
compilers that use LLVM). This is a common source of confusion from
people wondering why clang and opt give different output at -O2 (for
example).
The opt tool is primarily intended for unit testing. It is a convenient
way of running a single pass or sequence of passes (which is also useful
for producing reduced test cases when a long pass pipeline generates a
miscompile). Almost none of the logic, including most of the
command-line handling, is actually present in opt.
David
More information about the llvm-dev
mailing list