* device/lib/mcs51/crtcall.asm: new, added for indirect calls
[fw/sdcc] / src / pic / pcoderegs.c
index fd37229cd35623cae10e2c0946d24a1347e02907..5c1b8d18896aeef2869e084d918af53d736b10d5 100644 (file)
@@ -192,6 +192,7 @@ void pCodeRegMapLiveRangesInFlow(pCodeFlow *pcfl)
                                addSetIfnotP(& (reg->reglives.assignedpFlows), pcfl);
                        
                        addSetIfnotP(& (reg->reglives.usedpCodes), pc);
+                       reg->wasUsed = 1;
                }
                
                
@@ -732,11 +733,23 @@ void OptimizeRegUsage(set *fregs, int optimize_multi_uses, int optimize_level)
                fprintf(stderr,"Reg: %s\n",reg->name);
                */
                
+               /* Catch inconsistently set-up live ranges
+                * (see tracker items #1469504 + #1474602)
+                * FIXME: Actually we should rather fix the
+                * computation of the liveranges instead...
+                */
+               if (!reg || !reg->reglives.usedpFlows
+                       || !reg->reglives.assignedpFlows)
+               {
+                 //fprintf( stderr, "skipping reg w/o liveranges: %s\n", reg ? reg->name : "(unknown)");
+                 continue;
+               }
+
                if(reg->type == REG_SFR || reg->type == REG_STK || reg->isPublic || reg->isExtern|| reg->isFixed) {
                        //fprintf(stderr,"skipping SFR: %s\n",reg->name);
                        continue;
                }
-               
+
                pcfl_used = setFirstItem(reg->reglives.usedpFlows);
                pcfl_assigned = setFirstItem(reg->reglives.assignedpFlows);
                
@@ -1275,7 +1288,7 @@ static int pCodeRemove (pCode *pc, const char *comment)
        else
        {
                fprintf (stderr, "Cannot move a label...\n");
-               exit(-1);
+               exit(EXIT_FAILURE);
        }
        
        if (comment)
@@ -1672,7 +1685,7 @@ void pCodeRegOptimizeRegUsage(int level)
 
 #if 0
        /* This is currently broken (need rewrite to correctly
-        * hamdle arbitrary pCodeOps instead of registers only). */
+        * handle arbitrary pCodeOps instead of registers only). */
        if (!pic14_options.disable_df)
                optimizeDataflow ();
 #endif