[llvm-dev] Programmatically Toggle Specific LLVM Optimizations

Michael Kruse via llvm-dev llvm-dev at lists.llvm.org
Fri Jun 1 10:16:16 PDT 2018


Some passes have supported options to disable them, e.g.
-fno-vectorize and -fno-unroll-loops, but there is no general option.
Since it's not useful in general to disable arbitrary options, some
handywork is required. Using the legacy (=default) pass manager here.

To get the passes that are run:
$ clang -O3 -mllvm -debug-pass=Arguments

To optimize separately:
$ clang -Xclang -disable-llvm-passes -S -emit-llvm -o - | opt <your
list of passes> | llc
(not tested, so don't expect to work straight out of the box)

This is not strictly the same as optimizing using clang (pass options
are missing), so there will be performance differences. You could
instead customize PassManagerBuilder::populateModulePassManager() and
PassManagerBuilder::populateFunctionPassManager().

Michael


More information about the llvm-dev mailing list