Fixed a bug major in FillGaps , have to check uses for positioning also.
authorsandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 21 Dec 2001 05:08:22 +0000 (05:08 +0000)
committersandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 21 Dec 2001 05:08:22 +0000 (05:08 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1720 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/ds390/ralloc.c
src/mcs51/ralloc.c
src/z80/ralloc.c

index 527ffeb81fe9271031efea44ec6dc4b906d862d8..14b254dbd880a3993bbc552bb4e374f931f81356 100644 (file)
@@ -1365,7 +1365,7 @@ static void fillGaps()
                sym->regs[i] = getRegGprNoSpil ();                
        }
 
-       /* for all its definitions check if the registers
+       /* for all its definitions & uses check if the registers
           allocated needs positioning NOTE: we can position
           only ONCE if more than One positioning required 
           then give up */
@@ -1388,10 +1388,25 @@ static void fillGaps()
                if (pdone > 1) break;
            }
        }
+               for (i = 0 ; i < sym->uses->size ; i++ ) {
+           if (bitVectBitValue(sym->uses,i)) {
+               iCode *ic;
+               if (!(ic = hTabItemWithKey(iCodehTab,i))) continue ;
+               if (SKIP_IC(ic)) continue;
+               if (!IS_ASSIGN_ICODE(ic)) continue ;
+
+               /* if result is assigned to registers */
+               if (IS_SYMOP(IC_RESULT(ic)) && 
+                   bitVectBitValue(_G.totRegAssigned,OP_SYMBOL(IC_RESULT(ic))->key)) {
+                   pdone += positionRegs(sym,OP_SYMBOL(IC_RESULT(ic)));
+               }
+               if (pdone > 1) break;
+           }
+       }
        /* had to position more than once GIVE UP */
        if (pdone > 1) {
            /* UNDO all the changes we made to try this */
-           sym->isspilt = 0;
+           sym->isspilt = 1;
            for (i=0; i < sym->nRegs ; i++ ) {
                sym->regs[i] = NULL;
            }
index 1578ae1dafbad175a9f4141712c5465058682568..fcc86572c2252c7a52e09a6139a71bacc0692305 100644 (file)
@@ -1316,6 +1316,9 @@ static void fillGaps()
 
        /* THERE IS HOPE !!!! */
        for (i=0; i < sym->nRegs ; i++ ) {
+           if (sym->regType == REG_PTR)
+               sym->regs[i] = getRegPtrNoSpil ();
+           else
                sym->regs[i] = getRegGprNoSpil ();                
        }
 
@@ -1342,15 +1345,27 @@ static void fillGaps()
                if (pdone > 1) break;
            }
        }
+       for (i = 0 ; i < sym->uses->size ; i++ ) {
+           if (bitVectBitValue(sym->uses,i)) {
+               iCode *ic;
+               if (!(ic = hTabItemWithKey(iCodehTab,i))) continue ;
+               if (SKIP_IC(ic)) continue;
+               if (!IS_ASSIGN_ICODE(ic)) continue ;
+
+               /* if result is assigned to registers */
+               if (IS_SYMOP(IC_RESULT(ic)) && 
+                   bitVectBitValue(_G.totRegAssigned,OP_SYMBOL(IC_RESULT(ic))->key)) {
+                   pdone += positionRegs(sym,OP_SYMBOL(IC_RESULT(ic)));
+               }
+               if (pdone > 1) break;
+           }
+       }
        /* had to position more than once GIVE UP */
        if (pdone > 1) {
            /* UNDO all the changes we made to try this */
-           sym->isspilt = 0;
+           sym->isspilt = 1;
            for (i=0; i < sym->nRegs ; i++ ) {
-               if (sym->regType == REG_PTR)
-                   sym->regs[i] = getRegPtrNoSpil ();
-               else
-                   sym->regs[i] = getRegGprNoSpil ();
+                   sym->regs[i] = NULL;
            }
            freeAllRegs();
            D(printf ("Fill Gap gave up due to positioning for %s in function %s\n",sym->name, currFunc ? currFunc->name : "UNKNOWN"));
index b23b4b221e41543f502ba3d71f37643eaa8d7238..d73acaa0cd4286f85f442266ddc76aafefc68d8a 100644 (file)
@@ -1308,10 +1308,25 @@ static void fillGaps()
                if (pdone > 1) break;
            }
        }
+       for (i = 0 ; i < sym->uses->size ; i++ ) {
+           if (bitVectBitValue(sym->uses,i)) {
+               iCode *ic;
+               if (!(ic = hTabItemWithKey(iCodehTab,i))) continue ;
+               if (SKIP_IC(ic)) continue;
+               if (!IS_ASSIGN_ICODE(ic)) continue ;
+
+               /* if result is assigned to registers */
+               if (IS_SYMOP(IC_RESULT(ic)) && 
+                   bitVectBitValue(_G.totRegAssigned,OP_SYMBOL(IC_RESULT(ic))->key)) {
+                   pdone += positionRegs(sym,OP_SYMBOL(IC_RESULT(ic)));
+               }
+               if (pdone > 1) break;
+           }
+       }
        /* had to position more than once GIVE UP */
        if (pdone > 1) {
            /* UNDO all the changes we made to try this */
-           sym->isspilt = 0;
+           sym->isspilt = 1;
            for (i=0; i < sym->nRegs ; i++ ) {
                sym->regs[i] = NULL;
            }