MCPcopy Create free account
hub / github.com/Rust-GPU/rust-gpu / insert_phis

Function insert_phis

crates/rustc_codegen_spirv/src/linker/mem2reg.rs:371–395  ·  view source on GitHub ↗
(
    blocks: &[Block],
    dominance_frontier: &[FxHashSet<usize>],
    var_map: &FxHashMap<Word, VarInfo>,
)

Source from the content-addressed store, hash-verified

369}
370
371fn 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.
398fn undef_for(

Callers 1

insert_phis_allFunction · 0.85

Calls 3

has_storeFunction · 0.85
iterMethod · 0.80
insertMethod · 0.80

Tested by

no test coverage detected