Skip to content

Commit 203db0a

Browse files
committed
Make sure to call find() on basic block arguments
This ensures basic block arguments keep instructions alive, etc.
1 parent 8065c0e commit 203db0a

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

zjit/src/hir.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -743,11 +743,21 @@ impl Function {
743743
}
744744
};
745745
}
746+
macro_rules! find_branch_edge {
747+
( $edge:ident ) => {
748+
{
749+
BranchEdge {
750+
target: $edge.target,
751+
args: $edge.args.iter().map(|x| self.union_find.find_const(*x)).collect(),
752+
}
753+
}
754+
};
755+
}
746756
let insn_id = self.union_find.find_const(insn_id);
747757
use Insn::*;
748758
match &self.insns[insn_id.0] {
749759
result@(PutSelf | Const {..} | Param {..} | NewArray {..} | GetConstantPath {..}
750-
| Jump(_) | PatchPoint {..}) => result.clone(),
760+
| PatchPoint {..}) => result.clone(),
751761
Snapshot { state: FrameState { iseq, insn_idx, pc, stack, locals } } =>
752762
Snapshot {
753763
state: FrameState {
@@ -762,8 +772,9 @@ impl Function {
762772
StringCopy { val } => StringCopy { val: find!(*val) },
763773
StringIntern { val } => StringIntern { val: find!(*val) },
764774
Test { val } => Test { val: find!(*val) },
765-
IfTrue { val, target } => IfTrue { val: find!(*val), target: target.clone() },
766-
IfFalse { val, target } => IfFalse { val: find!(*val), target: target.clone() },
775+
Jump(target) => Jump(find_branch_edge!(target)),
776+
IfTrue { val, target } => IfTrue { val: find!(*val), target: find_branch_edge!(target) },
777+
IfFalse { val, target } => IfFalse { val: find!(*val), target: find_branch_edge!(target) },
767778
GuardType { val, guard_type, state } => GuardType { val: find!(*val), guard_type: *guard_type, state: *state },
768779
GuardBitEquals { val, expected, state } => GuardBitEquals { val: find!(*val), expected: *expected, state: *state },
769780
FixnumAdd { left, right, state } => FixnumAdd { left: find!(*left), right: find!(*right), state: *state },

0 commit comments

Comments
 (0)