Skip to content

Commit

Permalink
[mono][jit] Fix an assert in the local register allocator. (#66054)
Browse files Browse the repository at this point in the history
The assertion is hit when an instruction has a fixed sreg
(like shifts on x86) which was spilled to the stack.
  • Loading branch information
vargaz authored Mar 3, 2022
1 parent 1cfa6d6 commit fdbdb9a
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/mono/mono/mini/mini-codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -1436,6 +1436,7 @@ mono_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
continue;
}

gboolean need_assign = FALSE;
if (rs->ifree_mask & (regmask (dest_sreg))) {
if (is_global_ireg (sreg)) {
int k;
Expand All @@ -1454,8 +1455,8 @@ mono_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
DEBUG (printf ("\tshortcut assignment of R%d to %s\n", sreg, mono_arch_regname (dest_sreg)));
assign_reg (cfg, rs, sreg, dest_sreg, 0);
} else if (val < -1) {
/* FIXME: */
g_assert_not_reached ();
/* sreg is spilled, it can be assigned to dest_sreg */
need_assign = TRUE;
} else {
/* Argument already in hard reg, need to copy */
MonoInst *copy = create_copy_ins (cfg, bb, tmp, dest_sreg, val, NULL, ip, 0);
Expand All @@ -1476,9 +1477,9 @@ mono_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
}
} else {
gboolean need_spill = TRUE;
gboolean need_assign = TRUE;
int k;

need_assign = TRUE;
dreg_mask &= ~ (regmask (dest_sreg));
for (k = 0; k < num_sregs; ++k) {
if (k != j)
Expand Down Expand Up @@ -1538,18 +1539,17 @@ mono_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
if (need_spill) {
free_up_hreg (cfg, bb, tmp, ins, dest_sreg, 0);
}
}
if (need_assign) {
if (rs->vassign [sreg] < -1) {
int spill;

if (need_assign) {
if (rs->vassign [sreg] < -1) {
int spill;

/* Need to emit a spill store */
spill = - rs->vassign [sreg] - 1;
create_spilled_store (cfg, bb, spill, dest_sreg, sreg, tmp, NULL, ins, bank);
}
/* force-set sreg2 */
assign_reg (cfg, rs, sregs [j], dest_sreg, 0);
/* Need to emit a spill store */
spill = - rs->vassign [sreg] - 1;
create_spilled_store (cfg, bb, spill, dest_sreg, sreg, tmp, NULL, ins, bank);
}
/* force-set sreg */
assign_reg (cfg, rs, sregs [j], dest_sreg, 0);
}
sregs [j] = dest_sreg;
}
Expand Down

0 comments on commit fdbdb9a

Please sign in to comment.