Skip to content

Commit 993c7a2

Browse files
authored
ZJIT: Don't use find() in clean_cfg (ruby#16284)
We don't need to materialize an instruction or even look at its operands.
1 parent 2ccb44c commit 993c7a2

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

zjit/src/hir.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5141,11 +5141,15 @@ impl Function {
51415141
let mut num_in_edges = vec![0; self.blocks.len()];
51425142
for block in self.rpo() {
51435143
for &insn in &self.blocks[block.0].insns {
5144-
match self.find(insn) {
5145-
Insn::IfTrue { target, .. } | Insn::IfFalse { target, .. } | Insn::Jump(target) => {
5146-
num_in_edges[target.target.0] += 1;
5144+
// Instructions without output, including branch instructions, can't be targets of
5145+
// make_equal_to, so we don't need find() here.
5146+
match &self.insns[insn.0] {
5147+
Insn::IfTrue { target: BranchEdge { target, .. }, .. }
5148+
| Insn::IfFalse { target: BranchEdge { target, .. }, .. }
5149+
| Insn::Jump(BranchEdge { target, .. }) => {
5150+
num_in_edges[target.0] += 1;
51475151
}
5148-
Insn::Entries { ref targets } => {
5152+
Insn::Entries { targets } => {
51495153
for target in targets {
51505154
num_in_edges[target.0] += 1;
51515155
}

0 commit comments

Comments
 (0)