(module: &mut Module)
| 101 | } |
| 102 | |
| 103 | pub fn compact_ids(module: &mut Module) -> u32 { |
| 104 | let mut remap = FxHashMap::default(); |
| 105 | |
| 106 | let mut insert = |current_id: u32| -> u32 { |
| 107 | let len = remap.len(); |
| 108 | *remap.entry(current_id).or_insert_with(|| len as u32 + 1) |
| 109 | }; |
| 110 | |
| 111 | module.all_inst_iter_mut().for_each(|inst| { |
| 112 | if let Some(ref mut result_id) = &mut inst.result_id { |
| 113 | *result_id = insert(*result_id); |
| 114 | } |
| 115 | |
| 116 | if let Some(ref mut result_type) = &mut inst.result_type { |
| 117 | *result_type = insert(*result_type); |
| 118 | } |
| 119 | |
| 120 | inst.operands.iter_mut().for_each(|op| { |
| 121 | if let Some(w) = op.id_ref_any_mut() { |
| 122 | *w = insert(*w); |
| 123 | } |
| 124 | }); |
| 125 | }); |
| 126 | |
| 127 | remap.len() as u32 + 1 |
| 128 | } |
| 129 | |
| 130 | pub fn sort_globals(module: &mut Module) { |
| 131 | // Function declarations come before definitions. TODO: Figure out if it's even possible to |
no outgoing calls
no test coverage detected