* src/SDCCloop.c (assignmentsToSym, loopInduction): cast argument of setToNull()...
authorbernhardheld <bernhardheld@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 5 Oct 2003 19:18:14 +0000 (19:18 +0000)
committerbernhardheld <bernhardheld@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 5 Oct 2003 19:18:14 +0000 (19:18 +0000)
Old LR behaviour is again default; Klaus' LR can be choosen by defining the environment variable LRKLAUS
* src/SDCCBBlock.h
* src/SDCCloop.c
* src/SDCCloop.h
* src/SDCClrange.c
* src/ds390/ralloc.c (spillThis): applied Klaus' patch

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

ChangeLog
src/SDCCBBlock.h
src/SDCCloop.c
src/SDCClrange.c
src/ds390/ralloc.c

index ed814cb34eac5c2c13cfb6de6836733f99d5b69e..b8968b16bccd0ee9c1e69aee22e45275d012f0b8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2003-10-05 Bernhard Held <bernhard@bernhardheld.de>
+
+       * src/SDCCloop.c (assignmentsToSym, loopInduction): cast argument of
+       setToNull() to (void *) to avoid gcc3.x's warning: "dereferencing
+       type-punned pointer will break strict-aliasing rules"
+       Old LR behaviour is again default; Klaus' LR can be choosen by
+       defining the environment variable LRKLAUS
+       * src/SDCCBBlock.h
+       * src/SDCCloop.c
+       * src/SDCCloop.h
+       * src/SDCClrange.c
+       * src/ds390/ralloc.c (spillThis): applied Klaus' patch
+
 2003-10-05  Borut Razem <borut.razem@siol.net>
 
        * src/SDCC.lex, support/Util/SDCCerr.c, sdcc/support/Util/SDCCerr.h:
@@ -7,8 +20,8 @@
 2003-10-04  Frieder Ferlemann <Frieder.Ferlemann@web.de>
 
        * doc/sdccman.lyx: various additions and updates (interrupts, inline
-         assembly, critical functions, atomic, nojtbound) 
-        
+         assembly, critical functions, atomic, nojtbound)
+
 2003-10-04 Bernhard Held <bernhard@bernhardheld.de>
 
        Applied liferange patch from Klaus Flittner <klaus_flittner@gmx.de>
index 6ccd0a7c7fa8d7ab97923ad4b966b1768c6c6b8e..995f0a8aad44cf75745a9f882391eb7a651e3d6b 100644 (file)
@@ -45,7 +45,8 @@ typedef struct eBBlock
     iCode *ech;                        /* pointer to last of code chain  */
 
     struct eBBlock *preHeader; /* preheader if this is a loop entry */
-    set *partOfLoop;   /* set of loop regions this block is part of */
+    set *KpartOfLoop;          /* set of loop regions this block is part of */
+    struct region *partOfLoop; /* pointer to the loop region this block is part of */
 
     /* control flow analysis */
     set *succList;             /* list eBBlocks which are successors  */
index 6e6b26a6af37db57247cf217246bcd0b015d0cf7..10c17fc60fc4a799cacc842fc79beea80153f5c0 100644 (file)
@@ -235,9 +235,19 @@ DEFSETFUNC (addToExitsMarkDepth)
   if (ebp->depth<depth)
     ebp->depth = depth;
 
-  /* put the loop region info in the block */
-  if (!isinSet (ebp->partOfLoop, lr))
-    addSetHead (&ebp->partOfLoop, lr);
+  if (getenv ("LRKLAUS"))
+    {
+      /* put the loop region info in the block */
+      if (!isinSet (ebp->KpartOfLoop, lr))
+        addSetHead (&ebp->KpartOfLoop, lr);
+    }
+  else
+    {
+      /* NOTE: here we will update only the inner most loop
+         that it is a part of */
+      if (!ebp->partOfLoop)
+        ebp->partOfLoop = lr;
+    }
 
   /* if any of the successors go out of the loop then */
   /* we add this one to the exits */
@@ -327,7 +337,7 @@ assignmentsToSym (set * sset, operand * sym)
          in this block */
       bitVect *defs = bitVectIntersect (ebp->ldefs, OP_DEFS (sym));
       assigns += bitVectnBitsOn (defs);
-      setToNull ((void **) &defs);
+      setToNull ((void *) &defs);
 
     }
 
@@ -1055,7 +1065,7 @@ loopInduction (region * loopReg, eBBlock ** ebbs, int count)
       lastBlock->linds = bitVectUnion(lastBlock->linds,indVect);
     }
 
-  setToNull ((void **) &indVars);
+  setToNull ((void *) &indVars);
   return change;
 }
 
@@ -1229,13 +1239,13 @@ addLoopBlocks (eBBlock ** ebbs, int count)
 
   for (i = 0; i < count; i++)
     {
-      if (!ebbs[i]->partOfLoop)
+      if (!ebbs[i]->KpartOfLoop)
         continue;
 
       /* for all loops this block belongs to */
       /* add inner block not already marked as part of this loop */
-      aloop = setFirstItem (ebbs[i]->partOfLoop);
-      for (; aloop; aloop = setNextItem (ebbs[i]->partOfLoop))
+      aloop = setFirstItem (ebbs[i]->KpartOfLoop);
+      for (; aloop; aloop = setNextItem (ebbs[i]->KpartOfLoop))
         {
 
           if (aloop->visited)
@@ -1261,8 +1271,8 @@ addLoopBlocks (eBBlock ** ebbs, int count)
               if (ebbs[j]->fSeq > seqMin && ebbs[j]->lSeq < seqMax &&
                   !isinSet (aloop->regBlocks, ebbs[j]))
                {
-                  if (!isinSet (ebbs[i]->partOfLoop, aloop))
-                   addSetHead (&ebbs[j]->partOfLoop, aloop);
+                  if (!isinSet (ebbs[j]->KpartOfLoop, aloop))
+                   addSetHead (&ebbs[j]->KpartOfLoop, aloop);
                }
            }
        }
index b34565bcd5fa3618b0fead1894ea29b73558b2f1..3a86ced93309c75d4e8607d191bb75da67062120 100644 (file)
@@ -124,13 +124,24 @@ isLastUse (operand * op, eBBlock * ebp, iCode * ic,
   if (usedInRemaining (op, ic))
     return 0;
 
-  /* if not then check any of the following blocks use it */
-  for (i = 0; i < count; i++)
+  if (getenv ("LRKLAUS"))
     {
-      if (ebbs[i]->fSeq <= ebp->fSeq)
-       continue;
-      if (usedInRemaining (op, ebbs[i]->sch))
-       return 0;
+      /* if not then check any of the following blocks use it */
+      for (i = 0; i < count; i++)
+        {
+          if (ebbs[i]->fSeq <= ebp->fSeq)
+           continue;
+          if (usedInRemaining (op, ebbs[i]->sch))
+           return 0;
+        }
+    }
+  else
+    {
+      /* if not then check any of the successor blocks use it */
+      for (i = 0; i < count;)
+        ebbs[i++]->visited = 0;
+      if (applyToSet (ebp->succList, isOpAlive, op, ebp, ic))
+        return 0;
     }
 
   /* this is the last use */
@@ -310,31 +321,42 @@ operandLUse (operand * op, eBBlock ** ebbs,
       int torange = ic->seq;
 
       /* if this is a SEND then the toRange should be extended
-        to the call */
+         to the call */
       if (ic->op == SEND)
         {
-         iCode *lic ;
-         for (lic = ic->next ; lic ; lic = lic->next)
-           {
-             if (lic->op == CALL || lic->op == PCALL)
-               break;
-           }
-         /* found it : mark */
-         if (lic)
-           torange = lic->prev->seq;
+          iCode *lic ;
+          for (lic = ic->next ; lic ; lic = lic->next)
+            {
+              if (lic->op == CALL || lic->op == PCALL)
+                break;
+            }
+          /* found it : mark */
+          if (lic)
+            torange = lic->prev->seq;
         }
       /* if this is the last use then if this block belongs
          to a  loop &  some definition  comes into the loop
          then extend the live range to  the end of the loop */
-      if (ebp->partOfLoop)
+      if (getenv ("LRKLAUS"))
         {
-         region *aloop;
-
-         aloop = setFirstItem (ebp->partOfLoop);
-         for (; aloop; aloop = setNextItem (ebp->partOfLoop))
+         if (ebp->KpartOfLoop)
+            {
+              region *aloop;
+
+              aloop = setFirstItem (ebp->KpartOfLoop);
+              for (; aloop; aloop = setNextItem (ebp->KpartOfLoop))
+                {
+                  if (hasIncomingDefs (aloop, op))
+                    torange = findLoopEndSeq (aloop);
+                }
+            }
+       }
+      else
+        {
+          if (ebp->partOfLoop
+             && hasIncomingDefs (ebp->partOfLoop, op))
            {
-             if (hasIncomingDefs (aloop, op))
-               torange = findLoopEndSeq (aloop);
+             torange = findLoopEndSeq (ebp->partOfLoop);
            }
        }
 
@@ -712,7 +734,7 @@ notUsedInBlock (symbol * sym, eBBlock * ebp, iCode *ic)
 /*-----------------------------------------------------------------*/
 /* computeLiveRanges - computes the live ranges for variables      */
 /*-----------------------------------------------------------------*/
-void 
+void
 computeLiveRanges (eBBlock ** ebbs, int count)
 {
   int i = 0;
@@ -726,8 +748,11 @@ computeLiveRanges (eBBlock ** ebbs, int count)
   iCodeSeqhTab = newHashTable (iCodeKey);
   sequenceiCode (ebbs, count);
 
-  /* add blocks between loop blocks as part of that loop */
-  addLoopBlocks (ebbs, count);
+  if (getenv ("LRKLAUS"))
+    {
+      /* add blocks between loop blocks as part of that loop */
+      addLoopBlocks (ebbs, count);
+    }
 
   /* call routine to mark the from & to live ranges for
      variables used */
index 5da9df45e9afb1788e6ec99aad1f85646349231b..982021d8d1c1c7b5dd0dbae8c7144e491a09bd0c 100644 (file)
@@ -605,12 +605,12 @@ spillThis (symbol * sym)
        sym->regs[i] = NULL;
       }
 
-  /* if spilt on stack then free up r0 & r1 
+  /* if spilt on stack then free up r0 & r1
      if they could have been assigned to some
      LIVE ranges */
-  if (!ds390_ptrRegReq && isSpiltOnStack (sym))
+  if (!ds390_ptrRegReq && isSpiltOnStack (sym) && !options.stack10bit)
     {
-      ds390_ptrRegReq += !options.stack10bit;
+      ds390_ptrRegReq ++;
       spillLRWithPtrReg (sym);
     }