Prevent BASE register coalescing if parent uses IR_RETF.

This commit is contained in:
Mike Pall 2014-02-19 17:09:22 +01:00
parent e3d5b218d3
commit 2bc63bb6af
4 changed files with 14 additions and 8 deletions

View File

@ -493,6 +493,7 @@ static void asm_retf(ASMState *as, IRIns *ir)
int32_t delta = 1+bc_a(*((const BCIns *)pc - 1)); int32_t delta = 1+bc_a(*((const BCIns *)pc - 1));
as->topslot -= (BCReg)delta; as->topslot -= (BCReg)delta;
if ((int32_t)as->topslot < 0) as->topslot = 0; if ((int32_t)as->topslot < 0) as->topslot = 0;
irt_setmark(IR(REF_BASE)->t); /* Children must not coalesce with BASE reg. */
/* Need to force a spill on REF_BASE now to update the stack slot. */ /* Need to force a spill on REF_BASE now to update the stack slot. */
emit_lso(as, ARMI_STR, base, RID_SP, ra_spill(as, IR(REF_BASE))); emit_lso(as, ARMI_STR, base, RID_SP, ra_spill(as, IR(REF_BASE)));
emit_setgl(as, base, jit_base); emit_setgl(as, base, jit_base);
@ -2102,7 +2103,8 @@ static void asm_head_root_base(ASMState *as)
IRIns *ir; IRIns *ir;
asm_head_lreg(as); asm_head_lreg(as);
ir = IR(REF_BASE); ir = IR(REF_BASE);
if (ra_hasreg(ir->r) && rset_test(as->modset, ir->r)) ra_spill(as, ir); if (ra_hasreg(ir->r) && (rset_test(as->modset, ir->r) || irt_ismarked(ir->t)))
ra_spill(as, ir);
ra_destreg(as, ir, RID_BASE); ra_destreg(as, ir, RID_BASE);
} }
@ -2112,7 +2114,8 @@ static RegSet asm_head_side_base(ASMState *as, IRIns *irp, RegSet allow)
IRIns *ir; IRIns *ir;
asm_head_lreg(as); asm_head_lreg(as);
ir = IR(REF_BASE); ir = IR(REF_BASE);
if (ra_hasreg(ir->r) && rset_test(as->modset, ir->r)) ra_spill(as, ir); if (ra_hasreg(ir->r) && (rset_test(as->modset, ir->r) || irt_ismarked(ir->t)))
ra_spill(as, ir);
if (ra_hasspill(irp->s)) { if (ra_hasspill(irp->s)) {
rset_clear(allow, ra_dest(as, ir, allow)); rset_clear(allow, ra_dest(as, ir, allow));
} else { } else {

View File

@ -394,6 +394,7 @@ static void asm_retf(ASMState *as, IRIns *ir)
int32_t delta = 1+bc_a(*((const BCIns *)pc - 1)); int32_t delta = 1+bc_a(*((const BCIns *)pc - 1));
as->topslot -= (BCReg)delta; as->topslot -= (BCReg)delta;
if ((int32_t)as->topslot < 0) as->topslot = 0; if ((int32_t)as->topslot < 0) as->topslot = 0;
irt_setmark(IR(REF_BASE)->t); /* Children must not coalesce with BASE reg. */
emit_setgl(as, base, jit_base); emit_setgl(as, base, jit_base);
emit_addptr(as, base, -8*delta); emit_addptr(as, base, -8*delta);
asm_guard(as, MIPSI_BNE, RID_TMP, asm_guard(as, MIPSI_BNE, RID_TMP,
@ -1723,7 +1724,7 @@ static void asm_head_root_base(ASMState *as)
if (as->loopinv) as->mctop--; if (as->loopinv) as->mctop--;
if (ra_hasreg(r)) { if (ra_hasreg(r)) {
ra_free(as, r); ra_free(as, r);
if (rset_test(as->modset, r)) if (rset_test(as->modset, r) || irt_ismarked(ir->t))
ir->r = RID_INIT; /* No inheritance for modified BASE register. */ ir->r = RID_INIT; /* No inheritance for modified BASE register. */
if (r != RID_BASE) if (r != RID_BASE)
emit_move(as, r, RID_BASE); emit_move(as, r, RID_BASE);
@ -1738,7 +1739,7 @@ static RegSet asm_head_side_base(ASMState *as, IRIns *irp, RegSet allow)
if (as->loopinv) as->mctop--; if (as->loopinv) as->mctop--;
if (ra_hasreg(r)) { if (ra_hasreg(r)) {
ra_free(as, r); ra_free(as, r);
if (rset_test(as->modset, r)) if (rset_test(as->modset, r) || irt_ismarked(ir->t))
ir->r = RID_INIT; /* No inheritance for modified BASE register. */ ir->r = RID_INIT; /* No inheritance for modified BASE register. */
if (irp->r == r) { if (irp->r == r) {
rset_clear(allow, r); /* Mark same BASE register as coalesced. */ rset_clear(allow, r); /* Mark same BASE register as coalesced. */

View File

@ -381,6 +381,7 @@ static void asm_retf(ASMState *as, IRIns *ir)
int32_t delta = 1+bc_a(*((const BCIns *)pc - 1)); int32_t delta = 1+bc_a(*((const BCIns *)pc - 1));
as->topslot -= (BCReg)delta; as->topslot -= (BCReg)delta;
if ((int32_t)as->topslot < 0) as->topslot = 0; if ((int32_t)as->topslot < 0) as->topslot = 0;
irt_setmark(IR(REF_BASE)->t); /* Children must not coalesce with BASE reg. */
emit_setgl(as, base, jit_base); emit_setgl(as, base, jit_base);
emit_addptr(as, base, -8*delta); emit_addptr(as, base, -8*delta);
asm_guardcc(as, CC_NE); asm_guardcc(as, CC_NE);
@ -1901,7 +1902,7 @@ static void asm_head_root_base(ASMState *as)
Reg r = ir->r; Reg r = ir->r;
if (ra_hasreg(r)) { if (ra_hasreg(r)) {
ra_free(as, r); ra_free(as, r);
if (rset_test(as->modset, r)) if (rset_test(as->modset, r) || irt_ismarked(ir->t))
ir->r = RID_INIT; /* No inheritance for modified BASE register. */ ir->r = RID_INIT; /* No inheritance for modified BASE register. */
if (r != RID_BASE) if (r != RID_BASE)
emit_mr(as, r, RID_BASE); emit_mr(as, r, RID_BASE);
@ -1915,7 +1916,7 @@ static RegSet asm_head_side_base(ASMState *as, IRIns *irp, RegSet allow)
Reg r = ir->r; Reg r = ir->r;
if (ra_hasreg(r)) { if (ra_hasreg(r)) {
ra_free(as, r); ra_free(as, r);
if (rset_test(as->modset, r)) if (rset_test(as->modset, r) || irt_ismarked(ir->t))
ir->r = RID_INIT; /* No inheritance for modified BASE register. */ ir->r = RID_INIT; /* No inheritance for modified BASE register. */
if (irp->r == r) { if (irp->r == r) {
rset_clear(allow, r); /* Mark same BASE register as coalesced. */ rset_clear(allow, r); /* Mark same BASE register as coalesced. */

View File

@ -647,6 +647,7 @@ static void asm_retf(ASMState *as, IRIns *ir)
int32_t delta = 1+bc_a(*((const BCIns *)pc - 1)); int32_t delta = 1+bc_a(*((const BCIns *)pc - 1));
as->topslot -= (BCReg)delta; as->topslot -= (BCReg)delta;
if ((int32_t)as->topslot < 0) as->topslot = 0; if ((int32_t)as->topslot < 0) as->topslot = 0;
irt_setmark(IR(REF_BASE)->t); /* Children must not coalesce with BASE reg. */
emit_setgl(as, base, jit_base); emit_setgl(as, base, jit_base);
emit_addptr(as, base, -8*delta); emit_addptr(as, base, -8*delta);
asm_guardcc(as, CC_NE); asm_guardcc(as, CC_NE);
@ -2481,7 +2482,7 @@ static void asm_head_root_base(ASMState *as)
Reg r = ir->r; Reg r = ir->r;
if (ra_hasreg(r)) { if (ra_hasreg(r)) {
ra_free(as, r); ra_free(as, r);
if (rset_test(as->modset, r)) if (rset_test(as->modset, r) || irt_ismarked(ir->t))
ir->r = RID_INIT; /* No inheritance for modified BASE register. */ ir->r = RID_INIT; /* No inheritance for modified BASE register. */
if (r != RID_BASE) if (r != RID_BASE)
emit_rr(as, XO_MOV, r, RID_BASE); emit_rr(as, XO_MOV, r, RID_BASE);
@ -2495,7 +2496,7 @@ static RegSet asm_head_side_base(ASMState *as, IRIns *irp, RegSet allow)
Reg r = ir->r; Reg r = ir->r;
if (ra_hasreg(r)) { if (ra_hasreg(r)) {
ra_free(as, r); ra_free(as, r);
if (rset_test(as->modset, r)) if (rset_test(as->modset, r) || irt_ismarked(ir->t))
ir->r = RID_INIT; /* No inheritance for modified BASE register. */ ir->r = RID_INIT; /* No inheritance for modified BASE register. */
if (irp->r == r) { if (irp->r == r) {
rset_clear(allow, r); /* Mark same BASE register as coalesced. */ rset_clear(allow, r); /* Mark same BASE register as coalesced. */