mirror of
https://github.com/EmbarkStudios/rust-gpu.git
synced 2025-02-16 17:04:16 +00:00
Use the cute Function::all_inst_iter helper, because it's cute. (#535)
This commit is contained in:
parent
dea67c686c
commit
15d96cde8c
@ -1,3 +1,12 @@
|
||||
//! Dead code elimination
|
||||
//!
|
||||
//! This pass removes any instruction that doesn't affect the module. It does so by considering all
|
||||
//! `OpEntryPoint` instructions to be "rooted", and then everything a rooted instruction touches is
|
||||
//! also rooted (done transitively). Then, any instruction not rooted is removed. It gets a little
|
||||
//! weird with things like `OpDecorate`, where the reference is reversed - an `OpDecorate` that
|
||||
//! *references* a rooted thing is also rooted, not the other way around - but that's the basic
|
||||
//! concept.
|
||||
|
||||
use rspirv::dr::{Instruction, Module};
|
||||
use rspirv::spirv::Word;
|
||||
use std::collections::HashSet;
|
||||
@ -27,17 +36,9 @@ fn spread_roots(module: &Module, rooted: &mut HashSet<Word>) -> bool {
|
||||
}
|
||||
for func in &module.functions {
|
||||
if rooted.contains(&func.def_id().unwrap()) {
|
||||
for inst in &func.def {
|
||||
for inst in func.all_inst_iter() {
|
||||
any |= root(inst, rooted);
|
||||
}
|
||||
for inst in &func.parameters {
|
||||
any |= root(inst, rooted);
|
||||
}
|
||||
for block in &func.blocks {
|
||||
for inst in &block.instructions {
|
||||
any |= root(inst, rooted);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
any
|
||||
|
Loading…
Reference in New Issue
Block a user