(
blocks: &[Block],
dominance_frontier: &[FxHashSet<usize>],
var_map: &FxHashMap<Word, VarInfo>,
)
| 369 | } |
| 370 | |
| 371 | fn insert_phis( |
| 372 | blocks: &[Block], |
| 373 | dominance_frontier: &[FxHashSet<usize>], |
| 374 | var_map: &FxHashMap<Word, VarInfo>, |
| 375 | ) -> FxHashSet<usize> { |
| 376 | // TODO: Some algorithms check if the var is trivial in some way, e.g. all loads and stores are |
| 377 | // in a single block. We should probably do that too. |
| 378 | let mut ever_on_work_list = FxHashSet::default(); |
| 379 | let mut work_list = Vec::new(); |
| 380 | let mut blocks_with_phi = FxHashSet::default(); |
| 381 | for (block_idx, block) in blocks.iter().enumerate() { |
| 382 | if has_store(block, var_map) { |
| 383 | ever_on_work_list.insert(block_idx); |
| 384 | work_list.push(block_idx); |
| 385 | } |
| 386 | } |
| 387 | while let Some(x) = work_list.pop() { |
| 388 | for &y in &dominance_frontier[x] { |
| 389 | if blocks_with_phi.insert(y) && ever_on_work_list.insert(y) { |
| 390 | work_list.push(y); |
| 391 | } |
| 392 | } |
| 393 | } |
| 394 | blocks_with_phi |
| 395 | } |
| 396 | |
| 397 | // These can't be part of the Renamer impl due to borrowck rules. |
| 398 | fn undef_for( |
no test coverage detected