diff --git a/src/spesh/graph.h b/src/spesh/graph.h index 55d96b4213..bd69f7083f 100644 --- a/src/spesh/graph.h +++ b/src/spesh/graph.h @@ -118,6 +118,9 @@ struct MVMSpeshTemporary { MVMuint16 orig; MVMuint16 i; + /* The SSA index currently loaned out. */ + MVMuint16 used_i; + /* What kind of register is it? */ MVMuint16 kind; diff --git a/src/spesh/manipulate.c b/src/spesh/manipulate.c index 8c4ed0ddb9..b86cc569b6 100644 --- a/src/spesh/manipulate.c +++ b/src/spesh/manipulate.c @@ -281,7 +281,7 @@ MVMSpeshOperand MVM_spesh_manipulate_get_temp_reg(MVMThreadContext *tc, MVMSpesh /* Produce and return result. */ result.reg.orig = orig; - result.reg.i = g->temps[i].i; + result.reg.i = g->temps[i].used_i = g->temps[i].i; return result; } } @@ -299,6 +299,7 @@ MVMSpeshOperand MVM_spesh_manipulate_get_temp_reg(MVMThreadContext *tc, MVMSpesh /* Allocate temporary and set up result. */ g->temps[g->num_temps].orig = result.reg.orig = g->num_locals; g->temps[g->num_temps].i = result.reg.i = 0; + g->temps[g->num_temps].used_i = 0; g->temps[g->num_temps].kind = kind; g->temps[g->num_temps].in_use = 1; g->num_temps++; @@ -332,7 +333,7 @@ MVMSpeshOperand MVM_spesh_manipulate_get_temp_reg(MVMThreadContext *tc, MVMSpesh void MVM_spesh_manipulate_release_temp_reg(MVMThreadContext *tc, MVMSpeshGraph *g, MVMSpeshOperand temp) { MVMuint16 i; for (i = 0; i < g->num_temps; i++) { - if (g->temps[i].orig == temp.reg.orig && g->temps[i].i == temp.reg.i) { + if (g->temps[i].orig == temp.reg.orig && g->temps[i].used_i == temp.reg.i) { if (g->temps[i].in_use) g->temps[i].in_use = 0; else