]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Fix register mask for stack check in head of side trace.
authorMike Pall <mike>
Sat, 8 Jul 2023 17:36:24 +0000 (19:36 +0200)
committerMike Pall <mike>
Sat, 8 Jul 2023 17:36:24 +0000 (19:36 +0200)
Analyzed by Sergey Kaplun. #1016

src/lj_asm.c

index 9ff9215fd5210cff9369e078d874dd80963aa2b2..cfdfa99f5ccd65121b76349698bf714decd219dd 100644 (file)
@@ -1365,6 +1365,7 @@ static void asm_head_side(ASMState *as)
   IRRef1 sloadins[RID_MAX];
   RegSet allow = RSET_ALL;  /* Inverse of all coalesced registers. */
   RegSet live = RSET_EMPTY;  /* Live parent registers. */
+  RegSet pallow = RSET_GPR;  /* Registers needed by the parent stack check. */
   IRIns *irp = &as->parent->ir[REF_BASE];  /* Parent base. */
   int32_t spadj, spdelta;
   int pass2 = 0;
@@ -1404,6 +1405,7 @@ static void asm_head_side(ASMState *as)
       sloadins[rs] = (IRRef1)i;
       rset_set(live, rs);  /* Block live parent register. */
     }
+    if (!ra_hasspill(regsp_spill(rs))) rset_clear(pallow, regsp_reg(rs));
   }
 
   /* Calculate stack frame adjustment. */
@@ -1520,7 +1522,7 @@ static void asm_head_side(ASMState *as)
     ExitNo exitno = as->J->exitno;
 #endif
     as->T->topslot = (uint8_t)as->topslot;  /* Remember for child traces. */
-    asm_stack_check(as, as->topslot, irp, allow & RSET_GPR, exitno);
+    asm_stack_check(as, as->topslot, irp, pallow, exitno);
   }
 }