4.7. Optimization passes¶
LLVM gives you the possibility to fine-tune optimization passes. llvmlite
exposes several of these parameters. Optimization passes are managed by
a pass manager; there are two kinds thereof: FunctionPassManager,
for optimizations which work on single functions, and
ModulePassManager, for optimizations which work on whole modules.
To instantiate any of those pass managers, you first have to create and
configure a PassManagerBuilder.
-
class
llvmlite.binding.PassManagerBuilder¶ Create a new pass manager builder. This object centralizes optimization settings. The following method is available:
-
populate(pm)¶ Populate the pass manager pm with the optimization passes configured in this pass manager builder.
The following writable properties are also available:
-
disable_unroll_loops¶ If true, disable loop unrolling.
-
inlining_threshold¶ The integer threshold for inlining a function into another. The higher, the more likely inlining a function is. This attribute is write-only.
-
loop_vectorize¶ If true, allow vectorizing loops.
-
opt_level¶ The general optimization level as an integer between 0 and 3.
-
size_level¶ Whether and how much to optimize for size. An integer between 0 and 2.
-
slp_vectorize¶ If true, enable the “SLP vectorizer”, which uses a different algorithm from the loop vectorizer. Both may be enabled at the same time.
-
-
class
llvmlite.binding.PassManager¶ The base class for pass managers. Use individual
add_*methods orPassManagerBuilder.populate()to add optimization passes.-
add_constant_merge_pass()¶
-
add_dead_arg_elimination_pass()¶
-
add_function_attrs_pass()¶
-
add_function_inlining_pass(self)¶
-
add_global_dce_pass()¶
-
add_global_optimizer_pass()¶
-
add_ipsccp_pass()¶
-
add_dead_code_elimination_pass()¶
-
add_cfg_simplification_pass()¶
-
add_gvn_pass()¶
-
add_instruction_combining_pass()¶
-
add_licm_pass()¶
-
add_sccp_pass()¶
-
add_sroa_pass()¶ See scalarrepl pass documentation.
Note that while the link above describes the transformation performed by the pass added by this function, it corresponds to the
opt -sroacommand-line option and notopt -scalarrepl.
-
add_type_based_alias_analysis_pass()¶
-
add_basic_alias_analysis_pass()¶
-
-
class
llvmlite.binding.ModulePassManager¶ Create a new pass manager to run optimization passes on a module.
The following method is available:
-
class
llvmlite.binding.FunctionPassManager(module)¶ Create a new pass manager to run optimization passes on a function of the given module (an
ModuleRefinstance).The following methods are available:
-
finalize()¶ Run all the finalizers of the optimization passes.
-
initialize()¶ Run all the initializers of the optimization passes.
-