Use rspirv::dr::Function's def_id convenience method. (#397)

This commit is contained in:
Eduard-Mihai Burtescu 2021-01-28 11:52:41 +02:00 committed by GitHub
parent 69b94bb6f9
commit 810ba5d1e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 6 deletions

View File

@ -26,7 +26,7 @@ fn spread_roots(module: &Module, rooted: &mut HashSet<Word>) -> bool {
}
}
for func in &module.functions {
if rooted.contains(&func.def.as_ref().unwrap().result_id.unwrap()) {
if rooted.contains(&func.def_id().unwrap()) {
for inst in &func.def {
any |= root(inst, rooted);
}

View File

@ -139,7 +139,7 @@ fn kill_linkage_instructions(module: &mut Module, rewrite_rules: &HashMap<u32, u
// drop imported functions
module
.functions
.retain(|f| !rewrite_rules.contains_key(&f.def.as_ref().unwrap().result_id.unwrap()));
.retain(|f| !rewrite_rules.contains_key(&f.def_id().unwrap()));
// drop imported variables
module.types_global_values.retain(|v| {

View File

@ -17,7 +17,7 @@ pub fn inline(module: &mut Module) {
let functions = module
.functions
.iter()
.map(|f| (f.def.as_ref().unwrap().result_id.unwrap(), f.clone()))
.map(|f| (f.def_id().unwrap(), f.clone()))
.collect();
let disallowed_argument_types = compute_disallowed_argument_types(module);
let void = module
@ -32,7 +32,7 @@ pub fn inline(module: &mut Module) {
module.functions.retain(|f| {
if should_inline(&disallowed_argument_types, f) {
// TODO: We should insert all defined IDs in this function.
dropped_ids.insert(f.def.as_ref().unwrap().result_id.unwrap());
dropped_ids.insert(f.def_id().unwrap());
false
} else {
true

View File

@ -43,7 +43,7 @@ pub fn structurize(
builder: &mut builder,
};
let func_id = func.function().def.as_ref().unwrap().result_id.unwrap();
let func_id = func.function().def_id().unwrap();
let loop_control = match unroll_loops_decorations.get(&func_id) {
Some(UnrollLoopsDecoration {}) => LoopControl::UNROLL,

View File

@ -176,7 +176,7 @@ pub fn remove_zombies(sess: &Session, module: &mut Module) {
if env::var("PRINT_ZOMBIE").is_ok() {
for f in &module.functions {
if let Some(reason) = is_zombie(f.def.as_ref().unwrap(), &zombies) {
let name_id = f.def.as_ref().unwrap().result_id.unwrap();
let name_id = f.def_id().unwrap();
let name = module.debugs.iter().find(|inst| {
inst.class.opcode == Op::Name && inst.operands[0].unwrap_id_ref() == name_id
});