Skip to content

Commit 5065da2

Browse files
committed
linker/inline: make a proper closure in fuse_trivial_branches
1 parent 381ad53 commit 5065da2

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
@@ -521,7 +521,14 @@ fn fuse_trivial_branches(function: &mut Function) {
521521
}
522522
}
523523
function.blocks.retain(|b| !b.instructions.is_empty());
524-
apply_rewrite_rules(&rewrite_rules, &mut function.blocks);
524+
// Calculate a closure, as these rules can be transitive
525+
let mut rewrite_rules_new = rewrite_rules.clone();
526+
for value in rewrite_rules_new.values_mut() {
527+
while let Some(next) = rewrite_rules.get(value) {
528+
*value = *next;
529+
}
530+
}
531+
apply_rewrite_rules(&rewrite_rules_new, &mut function.blocks);
525532
}
526533

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

0 commit comments

Comments
 (0)