MCPcopy Create free account
hub / github.com/LPC4/Full-Stack / optimize_function

Function optimize_function

crates/hll-to-ir/src/compiler/opt/mod.rs:46–60  ·  view source on GitHub ↗

Run enabled passes over one function to a fixpoint (folding + DCE alternate).

(func: &mut IrFunction, opts: OptOptions)

Source from the content-addressed store, hash-verified

44 optimize_function(func, opts);
45 }
46}
47
48// Run enabled passes over one function to a fixpoint (folding + DCE alternate).
49fn optimize_function(func: &mut IrFunction, opts: OptOptions) {
50 const MAX_ROUNDS: usize = 16;
51 for _ in 0..MAX_ROUNDS {
52 let mut changed = false;
53 if opts.phi_simplify {
54 changed |= phi::run(func);
55 }
56 if opts.const_fold {
57 changed |= const_fold::run(func);
58 }
59 if opts.dce {
60 changed |= dce::run(func);
61 }
62 if !changed {
63 break;

Callers 1

optimizeFunction · 0.85

Calls 1

runFunction · 0.70

Tested by

no test coverage detected