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

Function remove_old_variables

crates/rustc_codegen_spirv/src/linker/mem2reg.rs:581–605  ·  view source on GitHub ↗
(
    blocks: &mut [Block],
    var_maps_and_types: &[(FxHashMap<u32, VarInfo>, u32)],
)

Source from the content-addressed store, hash-verified

579}
580
581fn remove_old_variables(
582 blocks: &mut [Block],
583 var_maps_and_types: &[(FxHashMap<u32, VarInfo>, u32)],
584) {
585 blocks[0].instructions.retain(|inst| {
586 inst.class.opcode != Op::Variable || {
587 let result_id = inst.result_id.unwrap();
588 var_maps_and_types
589 .iter()
590 .all(|(var_map, _)| !var_map.contains_key(&result_id))
591 }
592 });
593 for block in blocks {
594 block.instructions.retain(|inst| {
595 !matches!(inst.class.opcode, Op::AccessChain | Op::InBoundsAccessChain)
596 || inst.operands.iter().all(|op| {
597 op.id_ref_any().map_or(true, |id| {
598 var_maps_and_types
599 .iter()
600 .all(|(var_map, _)| !var_map.contains_key(&id))
601 })
602 })
603 });
604 }
605}

Callers 1

insert_phis_allFunction · 0.85

Calls 1

iterMethod · 0.80

Tested by

no test coverage detected