(
header: &mut ModuleHeader,
types_global_values: &mut Vec<Instruction>,
pointer_to_pointee: &FxHashMap<Word, Word>,
constants: &FxHashMap<Word, u32>,
func: &mut Function,
)
| 18 | use std::collections::hash_map; |
| 19 | |
| 20 | pub fn mem2reg( |
| 21 | header: &mut ModuleHeader, |
| 22 | types_global_values: &mut Vec<Instruction>, |
| 23 | pointer_to_pointee: &FxHashMap<Word, Word>, |
| 24 | constants: &FxHashMap<Word, u32>, |
| 25 | func: &mut Function, |
| 26 | ) { |
| 27 | let reachable = compute_reachable(&func.blocks); |
| 28 | let preds = compute_preds(&func.blocks, &reachable); |
| 29 | let idom = compute_idom(&preds, &reachable); |
| 30 | let dominance_frontier = compute_dominance_frontier(&preds, &idom); |
| 31 | loop { |
| 32 | let changed = insert_phis_all( |
| 33 | header, |
| 34 | types_global_values, |
| 35 | pointer_to_pointee, |
| 36 | constants, |
| 37 | &mut func.blocks, |
| 38 | &dominance_frontier, |
| 39 | ); |
| 40 | if !changed { |
| 41 | break; |
| 42 | } |
| 43 | // mem2reg produces minimal SSA form, not pruned, so DCE the dead ones |
| 44 | super::dce::dce_phi(func); |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | fn label_to_index(blocks: &[Block], id: Word) -> usize { |
| 49 | blocks |
no test coverage detected