* src/SDCCast.c: fixed feature request
[fw/sdcc] / src / SDCCBBlock.c
index 1156434e59f5d056fd2c92fd7d09540ccb40cc7b..28d56e5a99645bc66c2e046bb167573cb1a65a5c 100644 (file)
@@ -243,6 +243,15 @@ dumpEbbsToFileExt (int id, ebbIndex * ebbi)
       bitVectDebugOn (ebbs[i]->ldefs, of);
       fprintf (of, "\npointers Set bitvector :");
       bitVectDebugOn (ebbs[i]->ptrsSet, of);
+#if 0
+      fprintf (of, "\nin coming definitions :");
+      bitVectDebugOn (ebbs[i]->inDefs, of);
+      fprintf (of, "\nout going definitions :");
+      bitVectDebugOn (ebbs[i]->outDefs, of);
+      fprintf (of, "\ndefines used :");
+      bitVectDebugOn (ebbs[i]->usesDefs, of);
+#endif
+
       if (ebbs[i]->isLastInLoop) {
              fprintf (of, "\nInductions Set bitvector :");
              bitVectDebugOn (ebbs[i]->linds, of);
@@ -454,7 +463,10 @@ addiCodeToeBBlock (eBBlock * ebp, iCode * ic, iCode * ip)
   /* if this is true then we put it before the condition else */
   /* we put it before if, this is to reduce register pressure, */
   /* we don't have to hold  condition too long in a register  */
-  if (ebp->ech->op == IFX)
+
+  /* loop induction sometimes appends a GOTO instruction, */
+  /* it must be at the very end */
+  if (ebp->ech->op == IFX && ic->op != GOTO)
     {
       iCode *ipoint;
 
@@ -518,13 +530,13 @@ iCodeBreakDown (iCode * ic)
   iCode *loop = ic;
   ebbIndex *ebbi;
   
-  ebbi = Safe_alloc (sizeof (ebbIndex *));
+  ebbi = Safe_alloc (sizeof (ebbIndex));
   ebbi->count = 0;
   ebbi->dfOrder = NULL; /* no depth first order information yet */
 
   /* allocate for the first entry */
 
-  ebbs = Safe_alloc (sizeof (eBBlock **));
+  ebbs = Safe_alloc (sizeof (eBBlock *));
   ebbi->bbOrder = ebbs;
 
   while (loop)
@@ -544,7 +556,7 @@ iCodeBreakDown (iCode * ic)
       /* allocate for the next one. Remember to clear the new */
       /*  pointer at the end, that was created by realloc. */
 
-      ebbs = Safe_realloc (ebbs, (ebbi->count + 1) * sizeof (eBBlock **));
+      ebbs = Safe_realloc (ebbs, (ebbi->count + 1) * sizeof (eBBlock *));
       ebbi->bbOrder = ebbs;
 
       ebbs[ebbi->count] = 0;
@@ -572,7 +584,7 @@ iCodeBreakDown (iCode * ic)
              otherPathsPresent (ebbs, destBlock))
            {
 
-             symbol *preHeaderLabel = newiTempPreheaderLabel ();
+             symbol *preHeaderLabel  = newiTempLoopHeaderLabel (1);
              int i, j;
              eBBlock *pBlock;
 
@@ -589,7 +601,7 @@ iCodeBreakDown (iCode * ic)
 
              /* if we have stopped at the block , allocate for an extra one */
 
-             ebbs = Safe_realloc (ebbs, (ebbi->count + 1) * sizeof (eBBlock **));
+             ebbs = Safe_realloc (ebbs, (ebbi->count + 1) * sizeof (eBBlock *));
              ebbi->bbOrder = ebbs;
 
              ebbs[ebbi->count] = 0;