* src/mcs51/ralloc.c (isSpiltOnStack): fixed bug 1565152
authorMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 26 Feb 2008 19:18:32 +0000 (19:18 +0000)
committerMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 26 Feb 2008 19:18:32 +0000 (19:18 +0000)
* support/regression/tests/bug1565152.c: new, added

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

ChangeLog
src/mcs51/ralloc.c
support/regression/tests/bug1565152.c [new file with mode: 0644]

index 706802d6094aa987456ad88db2218ea69548f24d..dc338bb890ea54be5e34d5df296c5e9afe8fe820 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-02-25 Maarten Brock <sourceforge.brock AT dse.nl>
+
+       * src/mcs51/ralloc.c (isSpiltOnStack): fixed bug 1565152
+       * support/regression/tests/bug1565152.c: new, added
+
 2008-02-26 Borut Razem <borut.razem AT siol.net>
 
        * src/SDCCast.c, doc/adccman.lyx: fixed RFE #1901171: inerger promotion
index d4d3ad42160229eccca7d57a03a6a7e27a63adb7..7ce56c40ef12f5b00a537322d9a74c453ff9e2d6 100644 (file)
@@ -578,6 +578,7 @@ createStackSpil (symbol * sym)
 
 /*-----------------------------------------------------------------*/
 /* isSpiltOnStack - returns true if the spil location is on stack  */
+/*                  or otherwise needs a pointer register          */
 /*-----------------------------------------------------------------*/
 static bool
 isSpiltOnStack (symbol * sym)
@@ -596,6 +597,9 @@ isSpiltOnStack (symbol * sym)
   if (!sym->usl.spillLoc)
     return FALSE;
 
+  if (sym->usl.spillLoc->onStack || sym->usl.spillLoc->iaccess)
+    return TRUE;
+
   etype = getSpec (sym->usl.spillLoc->type);
   if (IN_STACK (etype))
     return TRUE;
@@ -664,7 +668,7 @@ selectSpil (iCode * ic, eBBlock * ebp, symbol * forSym)
       selectS = liveRangesWith (lrcs, bitType, ebp, ic);
       
       for (sym = setFirstItem (selectS); sym; sym = setNextItem (selectS))
-    {
+        {
           bitVectUnSetBit (lrcs, sym->key);
         }
     }
diff --git a/support/regression/tests/bug1565152.c b/support/regression/tests/bug1565152.c
new file mode 100644 (file)
index 0000000..b8b42d9
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+    bug 1565152.c
+*/
+
+#include <testfwk.h>
+
+// no need to call this, it generates compiler error for xstack-auto
+//   error 9: FATAL Compiler Internal Error
+
+#if defined(SDCC_mcs51)
+#include <8051.h>
+
+unsigned int foo(void)
+{
+       unsigned int i,j;
+       unsigned long l=0;
+
+       for (i=0;i<10;i++)
+       {
+               j=SP; // any SFR would do to generate crash
+               l+=j; 
+       } 
+       return 1; // <- it gives error on this line
+}
+#endif
+
+void
+testBug(void)
+{
+       ASSERT(1);
+}