Fixed problem with fn returning a variable bigger than a char.
[fw/sdcc] / src / SDCCopt.c
index 93668913bfebe1ee4448c2ae94ea30d6001c9bb2..94ee6e187b5d0231dc418575b510578387eb20cd 100644 (file)
@@ -176,7 +176,10 @@ cnvToFcall (iCode * ic, eBBlock * ebp)
   IC_RESULT (newic) = IC_RESULT (ic);
   newic->lineno = lineno;
   newic->parmBytes+=bytesPushed;
-
+  ebp->hasFcall = 1;
+  if (currFunc)
+    FUNC_HASFCALL (currFunc->type) = 1;
+    
   if(TARGET_IS_PIC16) {
        /* normally these functions aren't marked external, so we can use their
         * _extern field to marked as already added to symbol table */
@@ -264,6 +267,9 @@ found:
   newic = newiCode (CALL, operandFromSymbol (func), NULL);
   IC_RESULT (newic) = IC_RESULT (ic);
   newic->parmBytes+=bytesPushed;
+  ebp->hasFcall = 1;
+  if (currFunc)
+    FUNC_HASFCALL (currFunc->type) = 1;
 
   if(TARGET_IS_PIC16) {
        /* normally these functions aren't marked external, so we can use their
@@ -354,6 +360,9 @@ found:
   newic = newiCode (CALL, operandFromSymbol (func), NULL);
   IC_RESULT (newic) = IC_RESULT (ic);
   newic->parmBytes+=bytesPushed;
+  ebp->hasFcall = 1;
+  if (currFunc)
+    FUNC_HASFCALL (currFunc->type) = 1;
 
   if(TARGET_IS_PIC16) {
        /* normally these functions aren't marked external, so we can use their
@@ -517,6 +526,9 @@ found:
   IC_RESULT (newic) = IC_RESULT (ic);
   newic->lineno = lineno;
   newic->parmBytes+=bytesPushed; // to clear the stack after the call
+  ebp->hasFcall = 1;
+  if (currFunc)
+    FUNC_HASFCALL (currFunc->type) = 1;
 
   if(TARGET_IS_PIC16) {
        /* normally these functions aren't marked external, so we can use their
@@ -871,7 +883,8 @@ killDeadCode (eBBlock ** ebbs, int count)
              if (IC_RESULT (ic) && POINTER_SET (ic))
                continue;
               
-              if (POINTER_GET (ic) && IS_VOLATILE (operandType (IC_LEFT (ic))->next))
+              if (POINTER_GET (ic) && IS_VOLATILE (operandType (IC_LEFT (ic))->next)
+                 && !SPIL_LOC (IC_RESULT (ic)))
                 continue;
 
              /* if the result is used in the remainder of the */
@@ -935,6 +948,16 @@ killDeadCode (eBBlock ** ebbs, int count)
                        volRight = FALSE;
                    }
                  
+                 if (POINTER_GET (ic) && IS_VOLATILE (operandType (IC_LEFT (ic))->next))
+                   {
+                     if (SPIL_LOC (IC_RESULT (ic)))
+                       {
+                         IC_RESULT (ic) = newiTempFromOp (IC_RESULT (ic));
+                         SPIL_LOC (IC_RESULT (ic)) = NULL;
+                       }
+                     continue;
+                   }
+                 
                  change = 1;
                  gchange++;