sway_ir

Module optimize

Source
Expand description

A collection of optimization passes.

Each of these modules are a collection of typical code optimisation passes.

Currently there is no pass manager, as there are only a couple of passes, but this is something which will be added in the future.

So each of the functions under this module will return a boolean indicating whether a modification to the IR was made. Typically the passes will be just re-run until they no longer make any such modifications, implying they’ve optimized as much possible.

When writing passes one should keep in mind that when a modification is made then any iterators over blocks or instructions can be invalidated, and starting over is a safer option than trying to attempt multiple changes at once.

Re-exports§

pub use arg_demotion::*;
pub use const_demotion::*;
pub use constants::*;
pub use conditional_constprop::*;
pub use cse::*;
pub use dce::*;
pub use inline::*;
pub use mem2reg::*;
pub use memcpyopt::*;
pub use misc_demotion::*;
pub use ret_demotion::*;
pub use simplify_cfg::*;
pub use sroa::*;
pub use fn_dedup::*;

Modules§

arg_demotion
conditional_constprop
When a value is guaranteed to have a constant value in a region of the CFG, this optimization replaces uses of that value with the constant in that region.
const_demotion
constants
Optimization passes for manipulating constant values.
cse
Value numbering based common subexpression elimination. Reference: Value Driven Redundancy Elimination - Loren Taylor Simpson.
dce
Dead Code Elimination
fn_dedup
Deduplicate functions.
inline
Function inlining.
mem2reg
memcpyopt
Optimisations related to mem_copy.
misc_demotion
ret_demotion
simplify_cfg
Simplify Control Flow Graph
sroa
Scalar Replacement of Aggregates