MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / optimize

Method optimize

cranelift/codegen/src/context.rs:151–190  ·  view source on GitHub ↗

Optimize the function, performing all compilation steps up to but not including machine-code lowering and register allocation. Public only for testing purposes.

(
        &mut self,
        isa: &dyn TargetIsa,
        ctrl_plane: &mut ControlPlane,
    )

Source from the content-addressed store, hash-verified

149 ///
150 /// Public only for testing purposes.
151 pub fn optimize(
152 &mut self,
153 isa: &dyn TargetIsa,
154 ctrl_plane: &mut ControlPlane,
155 ) -> CodegenResult<()> {
156 log::debug!(
157 "Number of CLIF instructions to optimize: {}",
158 self.func.dfg.num_insts()
159 );
160 log::debug!(
161 "Number of CLIF blocks to optimize: {}",
162 self.func.dfg.num_blocks()
163 );
164
165 let opt_level = isa.flags().opt_level();
166 crate::trace!(
167 "Optimizing (opt level {:?}):\n{}",
168 opt_level,
169 self.func.display()
170 );
171
172 if isa.flags().enable_nan_canonicalization() {
173 self.canonicalize_nans(isa)?;
174 }
175
176 self.legalize(isa)?;
177
178 self.compute_cfg();
179 self.compute_domtree();
180 self.eliminate_unreachable_code(isa)?;
181 self.remove_constant_phis(isa)?;
182
183 self.func.dfg.resolve_all_aliases();
184
185 if opt_level != OptLevel::None {
186 self.egraph_pass(isa, ctrl_plane)?;
187 }
188
189 Ok(())
190 }
191
192 /// Perform function call inlining.
193 ///

Callers 5

runMethod · 0.80
runMethod · 0.80
runFunction · 0.80
compile_stencilMethod · 0.80
to_optimizedMethod · 0.80

Calls 10

OkFunction · 0.85
legalizeMethod · 0.80
compute_cfgMethod · 0.80
remove_constant_phisMethod · 0.80
resolve_all_aliasesMethod · 0.80
egraph_passMethod · 0.80
flagsMethod · 0.45
canonicalize_nansMethod · 0.45
compute_domtreeMethod · 0.45

Tested by 2

runMethod · 0.64
runMethod · 0.64