Skip to content

Commit 0c44e5a

Browse files
tekknolagik0kubun
authored andcommitted
Make sure to call find() on basic block arguments
This ensures basic block arguments keep instructions alive, etc.
1 parent b970ff1 commit 0c44e5a

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

zjit/src/hir.rs

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

0 commit comments

Comments
 (0)