1) cse.c don't replace when not symop
authorsandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 4 Mar 2000 18:30:09 +0000 (18:30 +0000)
committersandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 4 Mar 2000 18:30:09 +0000 (18:30 +0000)
2) icode.c fixed the &array[n] problem
3) lrange.c fixed name for used before def

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

src/SDCCcse.c
src/SDCCicode.c
src/SDCClrange.c

index 00cda0b8521905d298220c27e98f27810eaa43c9..d84c007d02a1a715ea8a4eddf04ce1091301e4cd 100644 (file)
@@ -103,7 +103,8 @@ void replaceAllSymBySym (iCode *ic, operand *from , operand *to)
            IC_RESULT(lic)->isaddr = siaddr ;
        }
 
-       if (IC_RIGHT(lic) && IC_RIGHT(lic)->key == from->key ) {
+       if (IS_SYMOP(to) &&
+           IC_RIGHT(lic) && IC_RIGHT(lic)->key == from->key ) {
            bitVectUnSetBit (OP_USES(from),lic->key);
            OP_USES(to) = bitVectSetBit(OP_USES(to),lic->key);
            siaddr = IC_RIGHT(lic)->isaddr ;
@@ -111,7 +112,8 @@ void replaceAllSymBySym (iCode *ic, operand *from , operand *to)
            IC_RIGHT(lic)->isaddr = siaddr ;
        }
 
-       if (IC_LEFT(lic) && IC_LEFT(lic)->key == from->key ) {
+       if (IS_SYMOP(to) &&
+           IC_LEFT(lic) && IC_LEFT(lic)->key == from->key ) {
            bitVectUnSetBit (OP_USES(from),lic->key);
            OP_USES(to) = bitVectSetBit(OP_USES(to),lic->key);
            siaddr = IC_LEFT(lic)->isaddr ;
index 69de4a7b0372162944ad180b3a842bfeb0075645..9a0c4345be87f1b95762bba7cf14666786237aae 100644 (file)
@@ -2078,7 +2078,7 @@ operand *geniCodeDerefPtr (operand *op)
     if (IS_PTR(optype)) 
        setOClass(optype,retype);    
         
-    #if 1
+    #if 0
     /* This block moved here from its original location
      * ten lines later by KV, 2/27/2000.
      * 
@@ -2101,7 +2101,7 @@ operand *geniCodeDerefPtr (operand *op)
                  IS_CHAR(rtype)   ||
                  IS_FLOAT(rtype) );
 
-    #if 0
+    #if 1
     /* Moved upwards */
     if (!lvaluereq)
        op = geniCodeRValue(op,TRUE);
@@ -2797,6 +2797,7 @@ operand *ast2iCode (ast *tree)
         tree->opval.op != INLINEASM ) {
        if (IS_ASSIGN_OP(tree->opval.op) || 
            IS_DEREF_OP(tree)            || 
+           (tree->opval.op == '&' && !tree->right) ||
            tree->opval.op == PTR_OP) {
            lvaluereq++;
            left = operandFromAst(tree->left);
@@ -2804,7 +2805,8 @@ operand *ast2iCode (ast *tree)
        } else {
            left =  operandFromAst(tree->left);
        }
-       if (tree->opval.op == INC_OP || tree->opval.op == DEC_OP) {
+       if (tree->opval.op == INC_OP || 
+           tree->opval.op == DEC_OP) {
            lvaluereq++;
            right= operandFromAst(tree->right);
            lvaluereq--;
index 73b636b1dacfa5108bfa82b5dab971433bcb0cf1..eea9a0751f7958277bc042ed43411a5be17ccc35 100644 (file)
@@ -225,24 +225,22 @@ operand *operandLUse (operand *op, eBBlock **ebbs,
            ic->op != ADDRESS_OF      &&
            !IS_STATIC(etype)         ) {
            
-/*         if (OP_SYMBOL(op)->isreqv && !OP_SYMBOL(op)->_isparm){ */
-               
-/*             if (SPIL_LOC(op) &&  */
-/*                 bitVectIsZero(SPIL_LOC(op)->defs)) { */
-/*                 OP_SYMBOL(op)->isspilt = 1; */
-/*                 werror(W_LOCAL_NOINIT,                          */
-/*                        SPIL_LOC(op)->name,                     */
-/*                        ic->filename,ic->lineno);  */
-/*             } */
-/*         } else { */
-               
-           if (bitVectIsZero(op->usesDefs)) {
+           if (bitVectIsZero(op->usesDefs)) {          
                OP_SYMBOL(op)->isspilt = 1;
-               werror(W_LOCAL_NOINIT,                     
-                      OP_SYMBOL(op)->name,                       
-                      ic->filename,ic->lineno); 
-           }
-/*         } */
+               
+               if (OP_SYMBOL(op)->isreqv && 
+                   !OP_SYMBOL(op)->_isparm && SPIL_LOC(op) ) {
+
+                   werror(W_LOCAL_NOINIT,                          
+                          SPIL_LOC(op)->name,                     
+                          ic->filename,ic->lineno);
+               } else {
+
+                   werror(W_LOCAL_NOINIT,                         
+                          OP_SYMBOL(op)->name,                   
+                          ic->filename,ic->lineno); 
+               }
+           } 
        }
     }
     return op;