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,
)
| 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 | /// |