Skip to content

Commit a7cc8db

Browse files
committed
linker/inline: make a proper closure in fuse_trivial_branches
1 parent c048909 commit a7cc8db

File tree

1 file changed

+8
-1
lines changed
  • crates/rustc_codegen_spirv/src/linker

1 file changed

+8
-1
lines changed

crates/rustc_codegen_spirv/src/linker/inline.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,14 @@ fn fuse_trivial_branches(function: &mut Function) {
519519
}
520520
}
521521
function.blocks.retain(|b| !b.instructions.is_empty());
522-
apply_rewrite_rules(&rewrite_rules, &mut function.blocks);
522+
// Calculate a closure, as these rules can be transitive
523+
let mut rewrite_rules_new = rewrite_rules.clone();
524+
for value in rewrite_rules_new.values_mut() {
525+
while let Some(next) = rewrite_rules.get(value) {
526+
*value = *next;
527+
}
528+
}
529+
apply_rewrite_rules(&rewrite_rules_new, &mut function.blocks);
523530
}
524531

525532
fn compute_outgoing_1to1_branches(blocks: &[Block]) -> Vec<Option<usize>> {

0 commit comments

Comments
 (0)