Refactor matches that used to consume BranchInfo (#5734)

Explicitly borrow the instruction data, and use a mutable borrow to avoid rematch.
This commit is contained in:
Trevor Elliott
2023-02-07 13:29:42 -08:00
committed by GitHub
parent fdd4a778fc
commit 2c8425998b
8 changed files with 24 additions and 50 deletions

View File

@@ -175,7 +175,7 @@ pub(crate) fn visit_block_succs<F: FnMut(Inst, Block, bool)>(
mut visit: F,
) {
if let Some(inst) = f.layout.last_inst(block) {
match f.dfg.insts[inst] {
match &f.dfg.insts[inst] {
ir::InstructionData::Jump {
destination: dest, ..
} => {
@@ -197,9 +197,9 @@ pub(crate) fn visit_block_succs<F: FnMut(Inst, Block, bool)>(
} => {
// The default block is reached via a direct conditional branch,
// so it is not part of the table.
visit(inst, dest, false);
visit(inst, *dest, false);
for &dest in f.jump_tables[table].as_slice() {
for &dest in f.jump_tables[*table].as_slice() {
visit(inst, dest, true);
}
}