Fixed BUG #519583. If a conditional block ended in a return/break
authorsandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 20 Feb 2002 08:32:37 +0000 (08:32 +0000)
committersandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 20 Feb 2002 08:32:37 +0000 (08:32 +0000)
statement inside a loop, it was not being considered part of the loop.

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1939 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCloop.c

index ef902a31db34666905e4353dd7078146e3d806f9..d65d40c78af651e8c12e2766201d18d09120bba6 100644 (file)
@@ -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))
@@ -279,7 +282,20 @@ 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) {
+             loopInsert(&aloop->regBlocks,ebbs[i]);
+      }
+  }
   /* now add it to the set */
   addSetHead (allRegion, aloop);
   return 0;
@@ -1154,7 +1170,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 */