llvmlite.binding
LLVM gives you the opportunity to fine-tune optimization passes. Optimization passes are managed by a pass manager. There are 2 kinds of pass managers:
FunctionPassManager
, for optimizations that work on single functions.ModulePassManager
, for optimizations that work on whole modules.
To instantiate either of these pass managers, you first need to create and configure a PassManagerBuilder
.
Create a new pass manager builder. This object centralizes optimization settings.
The populate
method is available:
populate(pm)
Populate the pass manager pm with the optimization passes configured in this pass manager builder.
The following writable attributes are available:
disable_unroll_loops
If
True
, disable loop unrolling.inlining_threshold
The integer threshold for inlining one function into another. The higher the number, the more likely that inlining will occur. 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, as an integer between 0 and 2.
slp_vectorize
If
True
, enable the SLP vectorizer, which uses a different algorithm than the loop vectorizer. Both may be enabled at the same time.
The base class for pass managers. Use individual add_*
methods or PassManagerBuilder.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.
While the scalarrepl pass documentation describes the transformation performed by the pass added by this function, the pass corresponds to the
opt -sroa
command-line option and not toopt -scalarrepl
.add_type_based_alias_analysis_pass()
add_basic_alias_analysis_pass()
add_instruction_namer_pass()
Create a new pass manager to run optimization passes on a module.
The run
method is available:
run(module)
Run optimization passes on the module, a ModuleRef
instance.
Returns True
if the optimizations made any modification to the module. Otherwise returns False
.
Create a new pass manager to run optimization passes on a function of the given module, a ModuleRef
instance.
The following methods are available:
finalize()
Run all the finalizers of the optimization passes.
initialize()
Run all the initializers of the optimization passes.
run(function)
Run optimization passes on function, a
ValueRef
instance.Returns
True
if the optimizations made any modification to the module. Otherwise returnsFalse
.