X-Git-Url: https://git.gag.com/?a=blobdiff_plain;ds=sidebyside;f=src%2FSDCCloop.c;fp=src%2FSDCCloop.c;h=55021f34798aa1a0d80e920e8a9a29bd86e22f6a;hb=633d4639c3ebce5f6b7ef04223e5d7842f841a6b;hp=f43e48373dcb31f3d42fb12b71aae3101e9177f4;hpb=bc04edccb1ca8d1dafb8ae5c96b047005029b866;p=fw%2Fsdcc diff --git a/src/SDCCloop.c b/src/SDCCloop.c index f43e4837..55021f34 100644 --- a/src/SDCCloop.c +++ b/src/SDCCloop.c @@ -259,8 +259,11 @@ DEFSETFUNC (createLoop) { edge *ep = item; V_ARG (set **, allRegion); + V_ARG (eBBlock **,ebbs); + V_ARG (int,count); region *aloop = newRegion (); eBBlock *block; + int dfMin = count ,dfMax =0, i; /* make sure regionStack is empty */ while (!STACK_EMPTY (regionStack)) @@ -280,6 +283,32 @@ DEFSETFUNC (createLoop) aloop->entry = ep->to; + /* set max & min dfNum for loopRegion */ + for ( block = setFirstItem(aloop->regBlocks); block; + block = setNextItem(aloop->regBlocks)) { + if (block->dfnum > dfMax) dfMax = block->dfnum; + if (block->dfnum < dfMin) dfMin = block->dfnum; + } + + /* all blocks that have dfnumbers between dfMin & dfMax are also + part of loop */ + for (i = 0 ; i < count ; i++) { + if (ebbs[i]->dfnum > dfMin && + ebbs[i]->dfnum < dfMax && + !isinSet(aloop->regBlocks,ebbs[i])) { + if (!ebbs[i]->partOfLoop) { + ebbs[i]->partOfLoop = aloop; + } + } + } + + /* and if this is a conditional block, the other side of the IFX + (if any, that could have a greater dfnum) is too */ + { + // just a burp, but I'm getting close :) + } + + /* now add it to the set */ addSetHead (allRegion, aloop); return 0; @@ -1154,7 +1183,7 @@ createLoopRegions (eBBlock ** ebbs, int count) /* for each of these back edges get the blocks that */ /* constitute the loops */ - applyToSet (bEdges, createLoop, &allRegion); + applyToSet (bEdges, createLoop, &allRegion, ebbs,count); /* now we will create regions from these loops */ /* loops with the same entry points are considered to be the */