diff --git a/src/lj_jit.h b/src/lj_jit.h index b69e4f4e..ecd79de5 100644 --- a/src/lj_jit.h +++ b/src/lj_jit.h @@ -279,6 +279,7 @@ typedef struct BPropEntry { /* Scalar evolution analysis cache. */ typedef struct ScEvEntry { + MRef pc; /* Bytecode PC of FORI. */ IRRef1 idx; /* Index reference. */ IRRef1 start; /* Constant start reference. */ IRRef1 stop; /* Constant stop reference. */ diff --git a/src/lj_record.c b/src/lj_record.c index c6848fc0..95957d31 100644 --- a/src/lj_record.c +++ b/src/lj_record.c @@ -421,6 +421,7 @@ static void rec_for_loop(jit_State *J, const BCIns *fori, ScEvEntry *scev, J->base[ra+FORL_IDX] = idx = emitir(IRT(IR_ADD, t), idx, step); J->base[ra+FORL_EXT] = idx; scev->idx = tref_ref(idx); + setmref(scev->pc, fori); J->maxslot = ra+FORL_EXT+1; } @@ -436,7 +437,7 @@ static LoopEvent rec_for(jit_State *J, const BCIns *fori, int isforl) IRType t; if (isforl) { /* Handle FORL/JFORL opcodes. */ TRef idx = tr[FORL_IDX]; - if (tref_ref(idx) == J->scev.idx) { + if (mref(J->scev.pc, const BCIns) == fori) { t = J->scev.t.irt; stop = J->scev.stop; idx = emitir(IRT(IR_ADD, t), idx, J->scev.step); @@ -2153,6 +2154,7 @@ void lj_record_setup(jit_State *J) memset(J->chain, 0, sizeof(J->chain)); memset(J->bpropcache, 0, sizeof(J->bpropcache)); J->scev.idx = REF_NIL; + setmref(J->scev.pc, NULL); J->baseslot = 1; /* Invoking function is at base[-1]. */ J->base = J->slot + J->baseslot;