* src/SDCCicode.h: removed buggy semicolon in unused macro
authorbernhardheld <bernhardheld@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 29 Jun 2006 13:58:34 +0000 (13:58 +0000)
committerbernhardheld <bernhardheld@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 29 Jun 2006 13:58:34 +0000 (13:58 +0000)
* src/SDCClrange.c (findPrevUseSym, rlivePoint): fixed bug #1486853, search for previous definiton of auto symbols too,
(findPrevUse): fixed logic of emitWarnings

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

ChangeLog
src/SDCCicode.h
src/SDCClrange.c

index 5223636d02a0550d5e04b9c9655980558ccf4713..168b52d70fb1e7a048ce0fd76b973e6fa19d662d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-06-29 Bernhard Held <bernhard AT bernhardheld.de>
+
+       * src/SDCCicode.h: removed buggy semicolon in unused macro
+       * src/SDCClrange.c (findPrevUseSym, rlivePoint): fixed bug #1486853,
+       search for previous definiton of auto symbols too,
+       (findPrevUse): fixed logic of emitWarnings
+
 2006-06-26 Raphael Neider <rneider AT web.de>
 
        * src/pic16/gen.c (genFunction, genEndFunction): also preserve
index b37b5f426c074fb107329355189a5f75c311d4ec..e4c3c1be1d55c3fc3e1d86a6c1024b5b7a5c0b8c 100644 (file)
@@ -61,7 +61,7 @@ OPTYPE;
 #define LRTYPE        LRFTYPE LRETYPE
 #define IS_ITEMP(op)       (IS_SYMOP(op) && op->operand.symOperand->isitmp == 1)
 #define IS_PARM(op)        (IS_SYMOP(op) && op->operand.symOperand->_isparm)
-#define IS_ITEMPLBL(op)    (IS_ITEMP(op) && op->operand.symOperand->isilbl == 1);
+#define IS_ITEMPLBL(op)    (IS_ITEMP(op) && op->operand.symOperand->isilbl == 1)
 #define IS_OP_VOLATILE(op) (IS_SYMOP(op) && op->isvolatile)
 #define IS_OP_LITERAL(op)  (op && op->isLiteral)
 #define IS_OP_GLOBAL(op)   (IS_SYMOP(op) && op->isGlobal)
index e7208a2fc37da96a650911adb8dc7436876d3e9f..91c31cfd927513a88ce2ccbaacadd14cd44ef592 100644 (file)
@@ -31,6 +31,11 @@ hTab *liveRanges = NULL;
 hTab *iCodehTab = NULL;
 hTab *iCodeSeqhTab = NULL;
 
+/* all symbols, for which the previous definition is searched
+   and warning is emitted if there's none. */
+#define IS_AUTOSYM(op) (IS_ITEMP(op) || \
+                        (IS_SYMOP(op) && IS_AUTO(op->operand.symOperand) && !IS_PARM(op)))
+
 /*-----------------------------------------------------------------*/
 /* hashiCodeKeys - add all iCodes to the hash table                */
 /*-----------------------------------------------------------------*/
@@ -386,7 +391,7 @@ findPrevUseSym  (eBBlock *ebp, iCode *ic, symbol * sym)
   /* search backward in the current block */
   for (uic = ic; uic; uic = uic->prev)
     {
-      if (!POINTER_SET (uic) && IS_ITEMP (IC_RESULT (uic)))
+      if (!POINTER_SET (uic) && IS_AUTOSYM (IC_RESULT (uic)))
         {
           if (IC_RESULT (uic)->key == sym->key)
             {
@@ -394,6 +399,15 @@ findPrevUseSym  (eBBlock *ebp, iCode *ic, symbol * sym)
               return TRUE;
             }
         }
+      /* address taken from symbol? */
+      if (uic->op == ADDRESS_OF && IS_AUTOSYM (IC_LEFT (uic)))
+        {
+          if (IC_LEFT (uic)->key == sym->key)
+            {
+              /* Ok, found a definition */
+              return TRUE;
+            }
+        }
     }
 
   /* There's no definition in this bblock, */
@@ -441,15 +455,20 @@ findPrevUse (eBBlock *ebp, iCode *ic, operand *op,
   if (!findPrevUseSym (ebp, ic->prev, OP_SYMBOL(op)))
     {
       /* computeLiveRanges() is called twice */
-      if (!emitWarnings)
+      if (emitWarnings)
         {
           werrorfl (ic->filename, ic->lineno, W_LOCAL_NOINIT,
-                    OP_SYMBOL (op)->prereqv);
-          OP_SYMBOL (op)->prereqv->reqv = NULL;
-          OP_SYMBOL (op)->prereqv->allocreq = 1;
+                    IS_ITEMP (op) ? OP_SYMBOL (op)->prereqv->name :
+                                    OP_SYMBOL (op)->name);
+          if (IS_ITEMP (op))
+            {
+              OP_SYMBOL (op)->prereqv->reqv = NULL;
+              OP_SYMBOL (op)->prereqv->allocreq = 1;
+            }
         }
       /* is this block part of a loop? */
-      if (ebp->depth != 0)
+      if (IS_ITEMP (op) &&
+          ebp->depth != 0)
         {
           /* extend the life range to the outermost loop */
           unvisitBlocks(ebbs, count);
@@ -494,6 +513,8 @@ rliveClear (eBBlock ** ebbs, int count)
 
 /*-----------------------------------------------------------------*/
 /* rlivePoint - for each point compute the ranges that are alive   */
+/* The live range is only stored for ITEMPs; the same code is used */
+/* to find use of unitialized AUTOSYMs (an ITEMP is an AUTOSYM).   */
 /*-----------------------------------------------------------------*/
 static void
 rlivePoint (eBBlock ** ebbs, int count, bool emitWarnings)
@@ -521,13 +542,16 @@ rlivePoint (eBBlock ** ebbs, int count, bool emitWarnings)
            {
              incUsed (ic, IC_JTCOND(ic));
 
-             if (!IS_ITEMP(IC_JTCOND(ic)))
+             if (!IS_AUTOSYM(IC_JTCOND(ic)))
                continue;
 
              findPrevUse (ebbs[i], ic, IC_JTCOND(ic), ebbs, count, emitWarnings);
-             unvisitBlocks(ebbs, count);
-             ic->rlive = bitVectSetBit (ic->rlive, IC_JTCOND(ic)->key);
-             findNextUse (ebbs[i], ic->next, IC_JTCOND(ic));
+              if (IS_ITEMP(IC_JTCOND(ic)))
+                {
+                  unvisitBlocks(ebbs, count);
+                  ic->rlive = bitVectSetBit (ic->rlive, IC_JTCOND(ic)->key);
+                  findNextUse (ebbs[i], ic->next, IC_JTCOND(ic));
+                }
 
              continue;
            }
@@ -536,13 +560,16 @@ rlivePoint (eBBlock ** ebbs, int count, bool emitWarnings)
            {
              incUsed (ic, IC_COND(ic));
 
-             if (!IS_ITEMP(IC_COND(ic)))
+             if (!IS_AUTOSYM(IC_COND(ic)))
                continue;
 
              findPrevUse (ebbs[i], ic, IC_COND(ic), ebbs, count, emitWarnings);
-             unvisitBlocks (ebbs, count);
-             ic->rlive = bitVectSetBit (ic->rlive, IC_COND(ic)->key);
-             findNextUse (ebbs[i], ic->next, IC_COND(ic));
+              if (IS_ITEMP(IC_COND(ic)))
+                {
+                  unvisitBlocks (ebbs, count);
+                  ic->rlive = bitVectSetBit (ic->rlive, IC_COND(ic)->key);
+                  findNextUse (ebbs[i], ic->next, IC_COND(ic));
+                }
 
              continue;
            }
@@ -550,53 +577,63 @@ rlivePoint (eBBlock ** ebbs, int count, bool emitWarnings)
          if (IS_SYMOP(IC_LEFT(ic)))
            {
              incUsed (ic, IC_LEFT(ic));
-             if (IS_ITEMP(IC_LEFT(ic)))
+             if (IS_AUTOSYM(IC_LEFT(ic)) &&
+                 ic->op != ADDRESS_OF)
                {
                  findPrevUse (ebbs[i], ic, IC_LEFT(ic), ebbs, count, emitWarnings);
-                 unvisitBlocks(ebbs, count);
-                 ic->rlive = bitVectSetBit (ic->rlive, IC_LEFT(ic)->key);
-                 findNextUse (ebbs[i], ic->next, IC_LEFT(ic));
-
-                 /* if this is a send extend the LR to the call */
-                 if (ic->op == SEND)
-                   {
-                     iCode *lic;
-                     for (lic = ic; lic; lic = lic->next)
-                       {
-                         if (lic->op == CALL || lic->op == PCALL)
-                           {
-                             markAlive (ic, lic->prev, IC_LEFT (ic)->key);
-                             break;
-                           }
-                       }
-                   }
+                  if (IS_ITEMP(IC_LEFT(ic)))
+                    {
+                      unvisitBlocks(ebbs, count);
+                      ic->rlive = bitVectSetBit (ic->rlive, IC_LEFT(ic)->key);
+                      findNextUse (ebbs[i], ic->next, IC_LEFT(ic));
+
+                      /* if this is a send extend the LR to the call */
+                      if (ic->op == SEND)
+                        {
+                          iCode *lic;
+                          for (lic = ic; lic; lic = lic->next)
+                            {
+                              if (lic->op == CALL || lic->op == PCALL)
+                                {
+                                  markAlive (ic, lic->prev, IC_LEFT (ic)->key);
+                                  break;
+                                }
+                            }
+                        }
+                    }
                }
            }
 
          if (IS_SYMOP(IC_RIGHT(ic)))
            {
              incUsed (ic, IC_RIGHT(ic));
-             if (IS_ITEMP(IC_RIGHT(ic)))
+              if (IS_AUTOSYM(IC_RIGHT(ic)))
                {
                  findPrevUse (ebbs[i], ic, IC_RIGHT(ic), ebbs, count, emitWarnings);
-                 unvisitBlocks(ebbs, count);
-                 ic->rlive = bitVectSetBit (ic->rlive, IC_RIGHT(ic)->key);
-                 findNextUse (ebbs[i], ic->next, IC_RIGHT(ic));
+                  if (IS_ITEMP(IC_RIGHT(ic)))
+                    {
+                      unvisitBlocks(ebbs, count);
+                      ic->rlive = bitVectSetBit (ic->rlive, IC_RIGHT(ic)->key);
+                      findNextUse (ebbs[i], ic->next, IC_RIGHT(ic));
+                    }
                }
            }
 
          if (POINTER_SET(ic) && IS_SYMOP(IC_RESULT(ic)))
            incUsed (ic, IC_RESULT(ic));
 
-         if (IS_ITEMP(IC_RESULT(ic)))
+          if (IS_AUTOSYM(IC_RESULT(ic)))
            {
              if (POINTER_SET(ic))
                {
                  findPrevUse (ebbs[i], ic, IC_RESULT(ic), ebbs, count, emitWarnings);
                }
-             unvisitBlocks(ebbs, count);
-             ic->rlive = bitVectSetBit (ic->rlive, IC_RESULT(ic)->key);
-             findNextUse (ebbs[i], ic->next, IC_RESULT(ic));
+              if (IS_ITEMP(IC_RESULT(ic)))
+                {
+                  unvisitBlocks(ebbs, count);
+                  ic->rlive = bitVectSetBit (ic->rlive, IC_RESULT(ic)->key);
+                  findNextUse (ebbs[i], ic->next, IC_RESULT(ic));
+                }
            }
 
          if (!POINTER_SET(ic) && IC_RESULT(ic))