Skip to content

Commit b733404

Browse files
committed
Fix multiple reg alloc bugs in xor.
Managed to get lifetimes wrong AND double-release in some cases.
1 parent 4b6a4af commit b733404

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/vm/moar/QAST/QASTOperationsMAST.nqp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,9 @@ QAST::MASTOperations.add_core_op('xor', -> $qastcomp, $op {
861861
my @ops;
862862
my $res_kind := $MVM_reg_obj;
863863
my $res_reg := $*REGALLOC.fresh_o();
864+
my $t := $*REGALLOC.fresh_i();
865+
my $u := $*REGALLOC.fresh_i();
866+
my $d := $*REGALLOC.fresh_o();
864867
my $falselabel := MAST::Label.new(:name($qastcomp.unique('xor_false')));
865868
my $endlabel := MAST::Label.new(:name($qastcomp.unique('xor_end')));
866869

@@ -875,10 +878,6 @@ QAST::MASTOperations.add_core_op('xor', -> $qastcomp, $op {
875878
}
876879
}
877880

878-
my $t := $*REGALLOC.fresh_i();
879-
my $u := $*REGALLOC.fresh_i();
880-
my $d := $*REGALLOC.fresh_o();
881-
882881
my $apost := nqp::shift(@comp_ops);
883882
push_ilist(@ops, $apost);
884883
push_op(@ops, 'set', $res_reg, $apost.result_reg);
@@ -905,15 +904,14 @@ QAST::MASTOperations.add_core_op('xor', -> $qastcomp, $op {
905904
push_op(@ops, 'if_i', $t, $truelabel);
906905
push_op(@ops, 'set', $res_reg, $bpost.result_reg);
907906
$*REGALLOC.release_register($bpost.result_reg, $MVM_reg_obj);
908-
$*REGALLOC.release_register($t, $MVM_reg_int64);
909907
push_op(@ops, 'set', $t, $u);
910-
$*REGALLOC.release_register($u, $MVM_reg_int64);
911908
nqp::push(@ops, $truelabel);
912909
}
913910
else {
914911
$have_middle_child := 0;
915912
}
916913
}
914+
$*REGALLOC.release_register($u, $MVM_reg_int64);
917915

918916
push_op(@ops, 'if_i', $t, $endlabel);
919917
$*REGALLOC.release_register($t, $MVM_reg_int64);

0 commit comments

Comments
 (0)