* src/avr/ralloc.c (serialRegAssign),
[fw/sdcc] / src / mcs51 / ralloc.c
index 8d7f6556abbf2b2751692400d97f1a6c67851840..ffa28c056bd95fc117ada6db7644503977f0b476 100644 (file)
@@ -1237,6 +1237,16 @@ serialRegAssign (eBBlock ** ebbs, int count)
                    spillThis (sym);
                    continue;                 
                }
+               
+               /* If the live range preceeds the point of definition 
+                  then ideally we must take into account registers that 
+                  have been allocated after sym->liveFrom but freed
+                  before ic->seq. This is complicated, so spill this
+                  symbol instead and let fillGaps handle the allocation. */
+               if (sym->liveFrom < ic->seq) {
+                   spillThis (sym);
+                   continue;                 
+               }
 
                /* if it has a spillocation & is used less than
                   all other live ranges then spill this */