From: epetrich Date: Thu, 5 Aug 2004 08:29:15 +0000 (+0000) Subject: * src/mcs51/ralloc.c (deassignLR), X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=0892d3692ded8c67ab4df6b26f603bb8d243e39d;p=fw%2Fsdcc * src/mcs51/ralloc.c (deassignLR), * src/ds390/ralloc.c (deassignLR), * src/hc08/ralloc.c (deassignLR), * src/z80/ralloc.c (deassignLR), * src/pic/ralloc.c (deassignLR), * src/pic16/ralloc.c (deassignLR), * src/avr/ralloc.c (deassignLR), * src/SDCClrange.c (findRecursiveSucc, findRecursivePred, findPrevUse, rlivePoint): fixed another part of bug #971834 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3422 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index 55fd9c8d..8c6b6f4e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2004-08-05 Erik Petrich + + * src/mcs51/ralloc.c (deassignLR), + * src/ds390/ralloc.c (deassignLR), + * src/hc08/ralloc.c (deassignLR), + * src/z80/ralloc.c (deassignLR), + * src/pic/ralloc.c (deassignLR), + * src/pic16/ralloc.c (deassignLR), + * src/avr/ralloc.c (deassignLR), + * src/SDCClrange.c (findRecursiveSucc, findRecursivePred, findPrevUse, + rlivePoint): fixed another part of bug #971834 + 2004-08-04 Erik Petrich * src/z80/main.c: enabled "critical" keyword diff --git a/src/SDCClrange.c b/src/SDCClrange.c index 0c6fbc78..31a678b2 100644 --- a/src/SDCClrange.c +++ b/src/SDCClrange.c @@ -321,8 +321,88 @@ void unvisitBlocks (eBBlock ** ebbs, int count) ebbs[i]->visited = 0; } +/*------------------------------------------------------------------*/ +/* findRecursiveSucc - build a bit vector of recursive successors */ +/*------------------------------------------------------------------*/ +DEFSETFUNC (findRecursiveSucc) +{ + eBBlock *ebp = item; + V_ARG (bitVect *, succVect); + + if (ebp->visited) + return 0; + + ebp->visited = 1; + bitVectSetBit (succVect, ebp->bbnum); + applyToSet (ebp->succList, findRecursiveSucc, succVect); + return 0; +} + + +/*------------------------------------------------------------------*/ +/* findRecursivePred - build a bit vector of recursive predecessors */ +/*------------------------------------------------------------------*/ +DEFSETFUNC (findRecursivePred) +{ + eBBlock *ebp = item; + V_ARG (bitVect *, predVect); + + if (ebp->visited) + return 0; + + ebp->visited = 1; + bitVectSetBit (predVect, ebp->bbnum); + applyToSet (ebp->predList, findRecursivePred, predVect); + return 0; +} + + +/*------------------------------------------------------------------*/ +/* findPrevUse - handle degenerate case of a symbol used prior to */ +/* findNextUse() marking any definition. */ +/*------------------------------------------------------------------*/ +void +findPrevUse (eBBlock *ebp, iCode *ic, operand *op, eBBlock **ebbs, int count) +{ + int i; + bitVect * succVect; + bitVect * predVect; + + /* If liveness is already known, then a previous call to findNextUse() */ + /* has already taken care of everything. */ + if (ic && bitVectBitValue(ic->rlive, op->key)) + return; + + if (op->isaddr) + OP_SYMBOL (op)->isptr = 1; + + OP_SYMBOL (op)->key = op->key; + + /* Otherwise, it appears that this symbol was used prior to definition. */ + /* Just fix the live range; we'll deal with a diagnostic message elsewhere. */ + /* If the symbol use was in a loop, we need to extend the live range to the */ + /* outermost loop. */ + unvisitBlocks (ebbs, count); + succVect = newBitVect (count); + applyToSet (ebp->succList, findRecursiveSucc, succVect); + unvisitBlocks (ebbs, count); + predVect = newBitVect (count); + applyToSet (ebp->predList, findRecursivePred, predVect); + + /* Blocks that are both recursively predecessors and successors are in */ + /* a loop with the current iCode. Mark the operand as alive in them. */ + for (i = 0; i < count; i++) + { + if (bitVectBitValue(succVect, i) && bitVectBitValue(predVect, i)) + markAlive (ebbs[i]->sch, ebbs[i]->ech, op->key); + } + + freeBitVect (succVect); + freeBitVect (predVect); +} + /*-----------------------------------------------------------------*/ -/* unvisitBlocks - clears visited in all blocks */ +/* incUsed - increment a symbol's usage count */ /*-----------------------------------------------------------------*/ void incUsed (iCode *ic, operand *op) @@ -387,6 +467,7 @@ rlivePoint (eBBlock ** ebbs, int count) if (!IS_ITEMP(IC_JTCOND(ic))) continue; + findPrevUse (ebbs[i], ic->prev, IC_JTCOND(ic), ebbs, count); unvisitBlocks(ebbs, count); ic->rlive = bitVectSetBit (ic->rlive, IC_JTCOND(ic)->key); findNextUse (ebbs[i], ic->next, IC_JTCOND(ic)); @@ -401,6 +482,7 @@ rlivePoint (eBBlock ** ebbs, int count) if (!IS_ITEMP(IC_COND(ic))) continue; + findPrevUse (ebbs[i], ic->prev, IC_COND(ic), ebbs, count); unvisitBlocks (ebbs, count); ic->rlive = bitVectSetBit (ic->rlive, IC_COND(ic)->key); findNextUse (ebbs[i], ic->next, IC_COND(ic)); @@ -414,6 +496,7 @@ rlivePoint (eBBlock ** ebbs, int count) if (IS_ITEMP(IC_LEFT(ic))) { + findPrevUse (ebbs[i], ic->prev, IC_LEFT(ic), ebbs, count); unvisitBlocks(ebbs, count); ic->rlive = bitVectSetBit (ic->rlive, IC_LEFT(ic)->key); findNextUse (ebbs[i], ic->next, IC_LEFT(ic)); @@ -439,6 +522,7 @@ rlivePoint (eBBlock ** ebbs, int count) incUsed (ic, IC_RIGHT(ic)); if (IS_ITEMP(IC_RIGHT(ic))) { + findPrevUse (ebbs[i], ic->prev, IC_RIGHT(ic), ebbs, count); unvisitBlocks(ebbs, count); ic->rlive = bitVectSetBit (ic->rlive, IC_RIGHT(ic)->key); findNextUse (ebbs[i], ic->next, IC_RIGHT(ic)); @@ -450,6 +534,10 @@ rlivePoint (eBBlock ** ebbs, int count) if (IS_ITEMP(IC_RESULT(ic))) { + if (POINTER_SET(ic)) + { + findPrevUse (ebbs[i], ic->prev, IC_RESULT(ic), ebbs, count); + } unvisitBlocks(ebbs, count); ic->rlive = bitVectSetBit (ic->rlive, IC_RESULT(ic)->key); findNextUse (ebbs[i], ic->next, IC_RESULT(ic)); diff --git a/src/avr/ralloc.c b/src/avr/ralloc.c index fce0f802..706ae3ce 100644 --- a/src/avr/ralloc.c +++ b/src/avr/ralloc.c @@ -1163,6 +1163,7 @@ deassignLRs (iCode * ic, eBBlock * ebp) (result = OP_SYMBOL (IC_RESULT (ic))) && /* has a result */ result->liveTo > ic->seq && /* and will live beyond this */ result->liveTo <= ebp->lSeq && /* does not go beyond this block */ + result->liveFrom == ic->seq && /* does not start before here */ result->regType == sym->regType && /* same register types */ result->nRegs && /* which needs registers */ !result->isspilt && /* and does not already have them */ diff --git a/src/ds390/ralloc.c b/src/ds390/ralloc.c index 1bb265e9..c25c6d46 100644 --- a/src/ds390/ralloc.c +++ b/src/ds390/ralloc.c @@ -991,6 +991,7 @@ deassignLRs (iCode * ic, eBBlock * ebp) (result = OP_SYMBOL (IC_RESULT (ic))) && /* has a result */ result->liveTo > ic->seq && /* and will live beyond this */ result->liveTo <= ebp->lSeq && /* does not go beyond this block */ + result->liveFrom == ic->seq && /* does not start before here */ result->regType == sym->regType && /* same register types */ result->nRegs && /* which needs registers */ !result->isspilt && /* and does not already have them */ diff --git a/src/hc08/ralloc.c b/src/hc08/ralloc.c index 25c75138..382c2ede 100644 --- a/src/hc08/ralloc.c +++ b/src/hc08/ralloc.c @@ -1032,6 +1032,7 @@ deassignLRs (iCode * ic, eBBlock * ebp) (result = OP_SYMBOL (IC_RESULT (ic))) && /* has a result */ result->liveTo > ic->seq && /* and will live beyond this */ result->liveTo <= ebp->lSeq && /* does not go beyond this block */ + result->liveFrom == ic->seq && /* does not start before here */ result->regType == sym->regType && /* same register types */ result->nRegs && /* which needs registers */ !result->isspilt && /* and does not already have them */ diff --git a/src/mcs51/ralloc.c b/src/mcs51/ralloc.c index ffa28c05..ec01a646 100644 --- a/src/mcs51/ralloc.c +++ b/src/mcs51/ralloc.c @@ -981,6 +981,7 @@ deassignLRs (iCode * ic, eBBlock * ebp) (result = OP_SYMBOL (IC_RESULT (ic))) && /* has a result */ result->liveTo > ic->seq && /* and will live beyond this */ result->liveTo <= ebp->lSeq && /* does not go beyond this block */ + result->liveFrom == ic->seq && /* does not start before here */ result->regType == sym->regType && /* same register types */ result->nRegs && /* which needs registers */ !result->isspilt && /* and does not already have them */ @@ -1409,7 +1410,7 @@ static void fillGaps() bitVectBitValue(_G.totRegAssigned,i) == 0) /* and are still assigned to registers */ continue ; - clr = hTabItemWithKey(liveRanges,i); + clr = hTabItemWithKey(liveRanges,i); assert(clr); /* mark these registers as used */ diff --git a/src/pic/ralloc.c b/src/pic/ralloc.c index 3be54b56..d12186f7 100644 --- a/src/pic/ralloc.c +++ b/src/pic/ralloc.c @@ -2066,7 +2066,7 @@ deassignLRs (iCode * ic, eBBlock * ebp) (result = OP_SYMBOL (IC_RESULT (ic))) && /* has a result */ result->liveTo > ic->seq && /* and will live beyond this */ result->liveTo <= ebp->lSeq && /* does not go beyond this block */ - result->regType == sym->regType && /* same register types */ + result->liveFrom == ic->seq && /* does not start before here */ result->regType == sym->regType && /* same register types */ result->nRegs && /* which needs registers */ !result->isspilt && /* and does not already have them */ !result->remat && diff --git a/src/pic16/ralloc.c b/src/pic16/ralloc.c index eeb4e787..4a026fcc 100644 --- a/src/pic16/ralloc.c +++ b/src/pic16/ralloc.c @@ -2000,6 +2000,7 @@ deassignLRs (iCode * ic, eBBlock * ebp) (result = OP_SYMBOL (IC_RESULT (ic))) && /* has a result */ result->liveTo > ic->seq && /* and will live beyond this */ result->liveTo <= ebp->lSeq && /* does not go beyond this block */ + result->liveFrom == ic->seq && /* does not start before here */ result->regType == sym->regType && /* same register types */ result->nRegs && /* which needs registers */ !result->isspilt && /* and does not already have them */ diff --git a/src/z80/ralloc.c b/src/z80/ralloc.c index 53f21219..b480b990 100644 --- a/src/z80/ralloc.c +++ b/src/z80/ralloc.c @@ -886,6 +886,7 @@ deassignLRs (iCode * ic, eBBlock * ebp) (result = OP_SYMBOL (IC_RESULT (ic))) && /* has a result */ result->liveTo > ic->seq && /* and will live beyond this */ result->liveTo <= ebp->lSeq && /* does not go beyond this block */ + result->liveFrom == ic->seq && /* does not start before here */ result->regType == sym->regType && /* same register types */ result->nRegs && /* which needs registers */ !result->isspilt && /* and does not already have them */