Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mono][jit] Fix an assert in the local register allocator. #66054

Merged
merged 1 commit into from
Mar 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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