Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix multiple reg alloc bugs in xor.
Managed to get lifetimes wrong AND double-release in some cases.
  • Loading branch information
jnthn committed Aug 1, 2014
1 parent 4b6a4af commit b733404
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/vm/moar/QAST/QASTOperationsMAST.nqp
Expand Up @@ -861,6 +861,9 @@ QAST::MASTOperations.add_core_op('xor', -> $qastcomp, $op {
my @ops;
my $res_kind := $MVM_reg_obj;
my $res_reg := $*REGALLOC.fresh_o();
my $t := $*REGALLOC.fresh_i();
my $u := $*REGALLOC.fresh_i();
my $d := $*REGALLOC.fresh_o();
my $falselabel := MAST::Label.new(:name($qastcomp.unique('xor_false')));
my $endlabel := MAST::Label.new(:name($qastcomp.unique('xor_end')));

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

my $t := $*REGALLOC.fresh_i();
my $u := $*REGALLOC.fresh_i();
my $d := $*REGALLOC.fresh_o();

my $apost := nqp::shift(@comp_ops);
push_ilist(@ops, $apost);
push_op(@ops, 'set', $res_reg, $apost.result_reg);
Expand All @@ -905,15 +904,14 @@ QAST::MASTOperations.add_core_op('xor', -> $qastcomp, $op {
push_op(@ops, 'if_i', $t, $truelabel);
push_op(@ops, 'set', $res_reg, $bpost.result_reg);
$*REGALLOC.release_register($bpost.result_reg, $MVM_reg_obj);
$*REGALLOC.release_register($t, $MVM_reg_int64);
push_op(@ops, 'set', $t, $u);
$*REGALLOC.release_register($u, $MVM_reg_int64);
nqp::push(@ops, $truelabel);
}
else {
$have_middle_child := 0;
}
}
$*REGALLOC.release_register($u, $MVM_reg_int64);

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

0 comments on commit b733404

Please sign in to comment.