From: bernhardheld Date: Sun, 5 Oct 2003 19:18:14 +0000 (+0000) Subject: * src/SDCCloop.c (assignmentsToSym, loopInduction): cast argument of setToNull()... X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=c8e39d11f12330795f42885613450220d8783831;p=fw%2Fsdcc * src/SDCCloop.c (assignmentsToSym, loopInduction): cast argument of setToNull() to (void *) to avoid gcc3.x's warning: "dereferencing type-punned pointer will break strict-aliasing rules" Old LR behaviour is again default; Klaus' LR can be choosen by defining the environment variable LRKLAUS * src/SDCCBBlock.h * src/SDCCloop.c * src/SDCCloop.h * src/SDCClrange.c * src/ds390/ralloc.c (spillThis): applied Klaus' patch git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2923 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index ed814cb3..b8968b16 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2003-10-05 Bernhard Held + + * src/SDCCloop.c (assignmentsToSym, loopInduction): cast argument of + setToNull() to (void *) to avoid gcc3.x's warning: "dereferencing + type-punned pointer will break strict-aliasing rules" + Old LR behaviour is again default; Klaus' LR can be choosen by + defining the environment variable LRKLAUS + * src/SDCCBBlock.h + * src/SDCCloop.c + * src/SDCCloop.h + * src/SDCClrange.c + * src/ds390/ralloc.c (spillThis): applied Klaus' patch + 2003-10-05 Borut Razem * src/SDCC.lex, support/Util/SDCCerr.c, sdcc/support/Util/SDCCerr.h: @@ -7,8 +20,8 @@ 2003-10-04 Frieder Ferlemann * doc/sdccman.lyx: various additions and updates (interrupts, inline - assembly, critical functions, atomic, nojtbound) - + assembly, critical functions, atomic, nojtbound) + 2003-10-04 Bernhard Held Applied liferange patch from Klaus Flittner diff --git a/src/SDCCBBlock.h b/src/SDCCBBlock.h index 6ccd0a7c..995f0a8a 100644 --- a/src/SDCCBBlock.h +++ b/src/SDCCBBlock.h @@ -45,7 +45,8 @@ typedef struct eBBlock iCode *ech; /* pointer to last of code chain */ struct eBBlock *preHeader; /* preheader if this is a loop entry */ - set *partOfLoop; /* set of loop regions this block is part of */ + set *KpartOfLoop; /* set of loop regions this block is part of */ + struct region *partOfLoop; /* pointer to the loop region this block is part of */ /* control flow analysis */ set *succList; /* list eBBlocks which are successors */ diff --git a/src/SDCCloop.c b/src/SDCCloop.c index 6e6b26a6..10c17fc6 100644 --- a/src/SDCCloop.c +++ b/src/SDCCloop.c @@ -235,9 +235,19 @@ DEFSETFUNC (addToExitsMarkDepth) if (ebp->depthdepth = depth; - /* put the loop region info in the block */ - if (!isinSet (ebp->partOfLoop, lr)) - addSetHead (&ebp->partOfLoop, lr); + if (getenv ("LRKLAUS")) + { + /* put the loop region info in the block */ + if (!isinSet (ebp->KpartOfLoop, lr)) + addSetHead (&ebp->KpartOfLoop, lr); + } + else + { + /* NOTE: here we will update only the inner most loop + that it is a part of */ + if (!ebp->partOfLoop) + ebp->partOfLoop = lr; + } /* if any of the successors go out of the loop then */ /* we add this one to the exits */ @@ -327,7 +337,7 @@ assignmentsToSym (set * sset, operand * sym) in this block */ bitVect *defs = bitVectIntersect (ebp->ldefs, OP_DEFS (sym)); assigns += bitVectnBitsOn (defs); - setToNull ((void **) &defs); + setToNull ((void *) &defs); } @@ -1055,7 +1065,7 @@ loopInduction (region * loopReg, eBBlock ** ebbs, int count) lastBlock->linds = bitVectUnion(lastBlock->linds,indVect); } - setToNull ((void **) &indVars); + setToNull ((void *) &indVars); return change; } @@ -1229,13 +1239,13 @@ addLoopBlocks (eBBlock ** ebbs, int count) for (i = 0; i < count; i++) { - if (!ebbs[i]->partOfLoop) + if (!ebbs[i]->KpartOfLoop) continue; /* for all loops this block belongs to */ /* add inner block not already marked as part of this loop */ - aloop = setFirstItem (ebbs[i]->partOfLoop); - for (; aloop; aloop = setNextItem (ebbs[i]->partOfLoop)) + aloop = setFirstItem (ebbs[i]->KpartOfLoop); + for (; aloop; aloop = setNextItem (ebbs[i]->KpartOfLoop)) { if (aloop->visited) @@ -1261,8 +1271,8 @@ addLoopBlocks (eBBlock ** ebbs, int count) if (ebbs[j]->fSeq > seqMin && ebbs[j]->lSeq < seqMax && !isinSet (aloop->regBlocks, ebbs[j])) { - if (!isinSet (ebbs[i]->partOfLoop, aloop)) - addSetHead (&ebbs[j]->partOfLoop, aloop); + if (!isinSet (ebbs[j]->KpartOfLoop, aloop)) + addSetHead (&ebbs[j]->KpartOfLoop, aloop); } } } diff --git a/src/SDCClrange.c b/src/SDCClrange.c index b34565bc..3a86ced9 100644 --- a/src/SDCClrange.c +++ b/src/SDCClrange.c @@ -124,13 +124,24 @@ isLastUse (operand * op, eBBlock * ebp, iCode * ic, if (usedInRemaining (op, ic)) return 0; - /* if not then check any of the following blocks use it */ - for (i = 0; i < count; i++) + if (getenv ("LRKLAUS")) { - if (ebbs[i]->fSeq <= ebp->fSeq) - continue; - if (usedInRemaining (op, ebbs[i]->sch)) - return 0; + /* if not then check any of the following blocks use it */ + for (i = 0; i < count; i++) + { + if (ebbs[i]->fSeq <= ebp->fSeq) + continue; + if (usedInRemaining (op, ebbs[i]->sch)) + return 0; + } + } + else + { + /* if not then check any of the successor blocks use it */ + for (i = 0; i < count;) + ebbs[i++]->visited = 0; + if (applyToSet (ebp->succList, isOpAlive, op, ebp, ic)) + return 0; } /* this is the last use */ @@ -310,31 +321,42 @@ operandLUse (operand * op, eBBlock ** ebbs, int torange = ic->seq; /* if this is a SEND then the toRange should be extended - to the call */ + to the call */ if (ic->op == SEND) { - iCode *lic ; - for (lic = ic->next ; lic ; lic = lic->next) - { - if (lic->op == CALL || lic->op == PCALL) - break; - } - /* found it : mark */ - if (lic) - torange = lic->prev->seq; + iCode *lic ; + for (lic = ic->next ; lic ; lic = lic->next) + { + if (lic->op == CALL || lic->op == PCALL) + break; + } + /* found it : mark */ + 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 then extend the live range to the end of the loop */ - if (ebp->partOfLoop) + if (getenv ("LRKLAUS")) { - region *aloop; - - aloop = setFirstItem (ebp->partOfLoop); - for (; aloop; aloop = setNextItem (ebp->partOfLoop)) + if (ebp->KpartOfLoop) + { + region *aloop; + + aloop = setFirstItem (ebp->KpartOfLoop); + for (; aloop; aloop = setNextItem (ebp->KpartOfLoop)) + { + if (hasIncomingDefs (aloop, op)) + torange = findLoopEndSeq (aloop); + } + } + } + else + { + if (ebp->partOfLoop + && hasIncomingDefs (ebp->partOfLoop, op)) { - if (hasIncomingDefs (aloop, op)) - torange = findLoopEndSeq (aloop); + torange = findLoopEndSeq (ebp->partOfLoop); } } @@ -712,7 +734,7 @@ notUsedInBlock (symbol * sym, eBBlock * ebp, iCode *ic) /*-----------------------------------------------------------------*/ /* computeLiveRanges - computes the live ranges for variables */ /*-----------------------------------------------------------------*/ -void +void computeLiveRanges (eBBlock ** ebbs, int count) { int i = 0; @@ -726,8 +748,11 @@ computeLiveRanges (eBBlock ** ebbs, int count) iCodeSeqhTab = newHashTable (iCodeKey); sequenceiCode (ebbs, count); - /* add blocks between loop blocks as part of that loop */ - addLoopBlocks (ebbs, count); + if (getenv ("LRKLAUS")) + { + /* add blocks between loop blocks as part of that loop */ + addLoopBlocks (ebbs, count); + } /* call routine to mark the from & to live ranges for variables used */ diff --git a/src/ds390/ralloc.c b/src/ds390/ralloc.c index 5da9df45..982021d8 100644 --- a/src/ds390/ralloc.c +++ b/src/ds390/ralloc.c @@ -605,12 +605,12 @@ spillThis (symbol * sym) sym->regs[i] = NULL; } - /* if spilt on stack then free up r0 & r1 + /* if spilt on stack then free up r0 & r1 if they could have been assigned to some LIVE ranges */ - if (!ds390_ptrRegReq && isSpiltOnStack (sym)) + if (!ds390_ptrRegReq && isSpiltOnStack (sym) && !options.stack10bit) { - ds390_ptrRegReq += !options.stack10bit; + ds390_ptrRegReq ++; spillLRWithPtrReg (sym); }