* src/SDCCmain.c (linkEdit): Added runtime path detection to the mcs51 port.
[fw/sdcc] / src / SDCClrange.c
index c3922ce0f763564a06ebc829fc6daf56dfdeaf1a..75242d192e6a1ca0b0c54a5cb09d65509ec7b6f3 100644 (file)
@@ -303,8 +303,8 @@ operandLUse (operand * op, eBBlock ** ebbs,
       /* 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 &&
-         hasIncomingDefs (ebp->partOfLoop, op))
+      if (ebp->partOfLoop 
+         && hasIncomingDefs (ebp->partOfLoop, op))
        {
          torange = findLoopEndSeq (ebp->partOfLoop);
        }
@@ -545,35 +545,42 @@ markLiveRanges (eBBlock * ebp, eBBlock ** ebbs, int count)
 void 
 rlivePoint (eBBlock ** ebbs, int count)
 {
-  int i;
-
-  /* for all blocks do */
-  for (i = 0; i < count; i++)
-    {
-      iCode *ic;
-
-      /* for all instruction in the block do */
-      for (ic = ebbs[i]->sch; ic; ic = ic->next)
-       {
-         symbol *lrange;
-         int k;
-
-         ic->rlive = newBitVect (operandKey);
-         /* for all symbols in the liverange table */
-         for (lrange = hTabFirstItem (liveRanges, &k); lrange;
-              lrange = hTabNextItem (liveRanges, &k))
-           {
-
-             /* if it is live then add the lrange to ic->rlive */
-             if (lrange->liveFrom <= ic->seq &&
-                 lrange->liveTo >= ic->seq)
-               {
-                 lrange->isLiveFcall |= (ic->op == CALL || ic->op == PCALL || ic->op == SEND);
-                 ic->rlive = bitVectSetBit (ic->rlive, lrange->key);
+       int i;
+
+       /* for all blocks do */
+       for (i = 0; i < count; i++) {
+               iCode *ic;
+
+               /* for all instruction in the block do */
+               for (ic = ebbs[i]->sch; ic; ic = ic->next) {
+                       symbol *lrange;
+                       int k;
+
+                       ic->rlive = newBitVect (operandKey);
+                       /* for all symbols in the liverange table */
+                       for (lrange = hTabFirstItem (liveRanges, &k); lrange;
+                            lrange = hTabNextItem (liveRanges, &k)) {
+
+                               /* if it is live then add the lrange to ic->rlive */
+                               if (lrange->liveFrom <= ic->seq &&
+                                   lrange->liveTo >= ic->seq) {
+                                       lrange->isLiveFcall |= (ic->op == CALL || ic->op == PCALL || ic->op == SEND);
+                                       ic->rlive = bitVectSetBit (ic->rlive, lrange->key);
+                               }
+                       }
+                       /* overlapping live ranges should be eliminated */
+                       if (ASSIGN_ITEMP_TO_ITEMP (ic)) {
+
+                               if (SPIL_LOC(IC_RIGHT(ic)) == SPIL_LOC(IC_RESULT(ic))   && /* left & right share the same spil location */
+                                   OP_SYMBOL(IC_RESULT(ic))->isreqv                    && /* left of assign is a register requivalent */
+                                   !OP_SYMBOL(IC_RIGHT(ic))->isreqv                    && /* right side is not */
+                                   OP_SYMBOL(IC_RIGHT(ic))->liveTo > ic->key           && /* right side live beyond this point */
+                                   bitVectnBitsOn(OP_DEFS(IC_RESULT(ic))) > 1 )        {  /* left has multiple definitions */
+                                       SPIL_LOC(IC_RIGHT(ic)) = NULL; /* then cannot share */
+                               }
+                       }
                }
-           }
        }
-    }
 }