X-Git-Url: https://git.gag.com/?a=blobdiff_plain;ds=sidebyside;f=src%2FSDCClrange.c;h=6c77fd3a42dc8671b396887b098ce803fd5ac555;hb=c1f59c961baefb83d1186f61ee8bd764a86ed56a;hp=b200b578424f6117da9f2608b46fcfba20a7bd57;hpb=b1eed0b8de55d56dfbf452880c54ba7d764184f6;p=fw%2Fsdcc diff --git a/src/SDCClrange.c b/src/SDCClrange.c index b200b578..6c77fd3a 100644 --- a/src/SDCClrange.c +++ b/src/SDCClrange.c @@ -280,7 +280,9 @@ useDefLoopCheck (operand * op, iCode * ic) OP_SYMBOL (op)->name, ic->filename, ic->lineno); } +#if 0 // this will create a segfault: bug #498971 OP_SYMBOL (op)->isspilt = 1; +#endif } } @@ -311,7 +313,7 @@ operandLUse (operand * op, eBBlock ** ebbs, if (lic->op == CALL || lic->op == PCALL) break; } /* found it : mark */ - if (lic) torange = lic->seq; + if (lic) torange = lic->prev->seq; } /* if this is the last use then if this block belongs to a loop & some definition comes into the loop @@ -578,10 +580,13 @@ rlivePoint (eBBlock ** ebbs, int count) /* if it is live then add the lrange to ic->rlive */ if (lrange->liveFrom <= ic->seq && lrange->liveTo >= ic->seq) { - lrange->isLiveFcall |= (ic->op == CALL || ic->op == PCALL || ic->op == SEND); + lrange->isLiveFcall |= ((lrange->liveFrom < ic->seq) && + (ic->op == CALL || ic->op == PCALL || ic->op == SEND)); + if (ic->op == CALL && lrange->liveFrom == ic->seq) continue; ic->rlive = bitVectSetBit (ic->rlive, lrange->key); } } +#if 0 /* overlapping live ranges should be eliminated */ if (ASSIGN_ITEMP_TO_ITEMP (ic)) { if (SPIL_LOC(IC_RIGHT(ic)) == SPIL_LOC(IC_RESULT(ic)) && /* left & right share the same spil location */ @@ -592,6 +597,7 @@ rlivePoint (eBBlock ** ebbs, int count) SPIL_LOC(IC_RIGHT(ic)) = NULL; /* then cannot share */ } } +#endif } } } @@ -652,6 +658,44 @@ static void computeClash () } } +/*-----------------------------------------------------------------*/ +/* allDefsOutOfRange - all definitions are out of a range */ +/*-----------------------------------------------------------------*/ +bool +allDefsOutOfRange (bitVect * defs, int fseq, int toseq) +{ + int i; + + if (!defs) + return TRUE; + + for (i = 0; i < defs->size; i++) + { + iCode *ic; + + if (bitVectBitValue (defs, i) && + (ic = hTabItemWithKey (iCodehTab, i)) && + (ic->seq >= fseq && ic->seq <= toseq)) + + return FALSE; + + } + + return TRUE; +} + +/*-----------------------------------------------------------------*/ +/* notUsedInBlock - not used in this block */ +/*-----------------------------------------------------------------*/ +int +notUsedInBlock (symbol * sym, eBBlock * ebp, iCode *ic) +{ + return (!bitVectBitsInCommon (sym->defs, ebp->usesDefs) && + allDefsOutOfRange (sym->defs, ebp->fSeq, ebp->lSeq) && + allDefsOutOfRange (sym->uses, ebp->fSeq, ebp->lSeq)); +} + + /*-----------------------------------------------------------------*/ /* computeLiveRanges - computes the live ranges for variables */ /*-----------------------------------------------------------------*/ @@ -681,3 +725,4 @@ computeLiveRanges (eBBlock ** ebbs, int count) /* compute which overlaps with what */ computeClash(); } +