More strcpy() strcat() sprintf() squashing
[fw/sdcc] / src / SDCCBBlock.c
index 79126353fafca4d4cd5a4d7275850fc146abd9b4..559d7341844401eaf57732d9388f162d6d8444fa 100644 (file)
@@ -102,8 +102,8 @@ FILE *appendDumpFile (int id) {
 
   if (!dumpFilesPtr->filePtr) {
     // not used before, create it
-    strcpy (scratchFileName, srcFileName);
-    strcat (scratchFileName, dumpFilesPtr->ext);
+    strncpyz (scratchFileName, dstFileName, PATH_MAX);
+    strncatz (scratchFileName, dumpFilesPtr->ext, PATH_MAX);
     if (!(dumpFilesPtr->filePtr = fopen (scratchFileName, "w"))) {
       werror (E_FILE_OPEN_ERR, scratchFileName);
       exit (1);
@@ -141,7 +141,9 @@ dumpLiveRanges (int id, hTab * liveRanges)
   } else {
     file = stdout;
   }
-
+  
+  if (currFunc) 
+      fprintf(file,"------------- Func %s -------------\n",currFunc->name);
   for (sym = hTabFirstItem (liveRanges, &k); sym;
        sym = hTabNextItem (liveRanges, &k))
     {
@@ -160,7 +162,8 @@ dumpLiveRanges (int id, hTab * liveRanges)
        {
          fprintf (file, "}{ sir@ %s", sym->usl.spillLoc->rname);
        }
-      fprintf (file, "}");
+      fprintf (file, "} clashes with ");
+      bitVectDebugOn(sym->clashes,file);
       fprintf (file, "\n");
     }
 
@@ -196,6 +199,10 @@ dumpEbbsToFileExt (int id, eBBlock ** ebbs, int count)
       bitVectDebugOn (ebbs[i]->ldefs, of);
       fprintf (of, "\npointers Set bitvector :");
       bitVectDebugOn (ebbs[i]->ptrsSet, of);
+      if (ebbs[i]->isLastInLoop) {
+             fprintf (of, "\nInductions Set bitvector :");
+             bitVectDebugOn (ebbs[i]->linds, of);
+      }
       fprintf (of, "\n----------------------------------------------------------------\n");
       printiCChain (ebbs[i]->sch, of);
     }
@@ -219,7 +226,7 @@ iCode2eBBlock (iCode * ic)
     ebb->entryLabel = ic->argLabel.label;
   else
     {
-      sprintf (buffer, "_eBBlock%d", eBBNum++);
+      SNPRINTF (buffer, sizeof(buffer), "_eBBlock%d", eBBNum++);
       ebb->entryLabel = newSymbol (buffer, 1);
       ebb->entryLabel->key = labelKey++;
     }
@@ -252,7 +259,7 @@ iCode2eBBlock (iCode * ic)
        {
          ebb->hasFcall = 1;
          if (currFunc)
-           currFunc->hasFcall = 1;
+           FUNC_HASFCALL(currFunc->type) = 1;
        }
 
       /* if the next one is a label */
@@ -412,6 +419,7 @@ addiCodeToeBBlock (eBBlock * ebp, iCode * ic, iCode * ip)
 void 
 remiCodeFromeBBlock (eBBlock * ebb, iCode * ic)
 {
+  wassert (ic->seq>=ebb->fSeq && ic->seq<=ebb->lSeq);
   if (ic->prev)
     ic->prev->next = ic->next;
   else
@@ -555,7 +563,7 @@ replaceSymBySym (set * sset, operand * src, operand * dest)
            {
              bitVectUnSetBit (OP_USES (IC_COND (ic)), ic->key);
              IC_COND (ic) = operandFromOperand (dest);
-             OP_USES (dest) = bitVectSetBit (OP_USES (dest), ic->key);
+             OP_USES_SET ((dest), bitVectSetBit (OP_USES (dest), ic->key));
              continue;
            }
 
@@ -564,7 +572,7 @@ replaceSymBySym (set * sset, operand * src, operand * dest)
              bitVectUnSetBit (OP_USES (IC_RIGHT (ic)), ic->key);
              IC_RIGHT (ic) = operandFromOperand (dest);
              IC_RIGHT (ic)->isaddr = 0;
-             OP_USES (dest) = bitVectSetBit (OP_USES (dest), ic->key);
+             OP_USES_SET ((dest), bitVectSetBit (OP_USES (dest), ic->key));
            }
 
          if (isOperandEqual (IC_LEFT (ic), src))
@@ -580,7 +588,7 @@ replaceSymBySym (set * sset, operand * src, operand * dest)
                  IC_LEFT (ic) = operandFromOperand (dest);
                  IC_LEFT (ic)->isaddr = 0;
                }
-             OP_USES (dest) = bitVectSetBit (OP_USES (dest), ic->key);
+             OP_USES_SET ((dest), bitVectSetBit (OP_USES (dest), ic->key));
            }
 
          /* special case for pointer sets */
@@ -590,7 +598,7 @@ replaceSymBySym (set * sset, operand * src, operand * dest)
              bitVectUnSetBit (OP_USES (IC_RESULT (ic)), ic->key);
              IC_RESULT (ic) = operandFromOperand (dest);
              IC_RESULT (ic)->isaddr = 1;
-             OP_USES (dest) = bitVectSetBit (OP_USES (dest), ic->key);
+             OP_USES_SET ((dest), bitVectSetBit (OP_USES (dest), ic->key));
            }
        }
     }