From: sandeep Date: Wed, 14 Jun 2000 17:39:20 +0000 (+0000) Subject: fixed dereferencing bugs X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=9b13f8caf3f9373d0f748398e309d2035af1db19;p=fw%2Fsdcc fixed dereferencing bugs git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@275 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/SDCCcse.c b/src/SDCCcse.c index 4cec0bc5..2af7f3ee 100644 --- a/src/SDCCcse.c +++ b/src/SDCCcse.c @@ -1108,6 +1108,20 @@ DEFSETFUNC(delGetPointerSucc) return applyToSet(ebp->succList,delGetPointerSucc,op,dfnum); } +/*-----------------------------------------------------------------*/ +/* fixUpTypes - KLUGE HACK fixup a lowering problem */ +/*-----------------------------------------------------------------*/ +static void fixUpTypes(iCode *ic) +{ + link *t1 = operandType(IC_LEFT(ic)) ,*t2; + /* for pointer_gets if the types of result & left r the + same then change it type of result to next */ + if (IS_PTR(t1) && + checkType(t2=operandType(IC_RESULT(ic)),t1) == 1) { + setOperandType(IC_RESULT(ic),t2->next); + } +} + /*-----------------------------------------------------------------*/ /* cseBBlock - common subexpression elimination for basic blocks */ /* this is the hackiest kludgiest routine in the whole */ @@ -1229,6 +1243,7 @@ int cseBBlock ( eBBlock *ebb, int computeOnly, /* do some algebraic optimizations if possible */ algebraicOpts (ic); + if (POINTER_GET(ic)) fixUpTypes(ic); while (constFold(ic,cseSet)); /* small klugde */ diff --git a/src/SDCCicode.c b/src/SDCCicode.c index ec5a26c6..287379af 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -2756,13 +2756,16 @@ operand *ast2iCode (ast *tree) (tree->opval.op == '&' && !tree->right) || tree->opval.op == PTR_OP) { lvaluereq++; - if (IS_ARRAY_OP(tree->left) && IS_ARRAY_OP(tree->left->left)) { + if (IS_ARRAY_OP(tree->left) && IS_ARRAY_OP(tree->left->left)) + { lvaluereq--; left = operandFromAst(tree->left); } else { left = operandFromAst(tree->left); lvaluereq--; } + if (IS_DEREF_OP(tree) && IS_DEREF_OP(tree->left)) + left = geniCodeRValue(left,TRUE); } else { left = operandFromAst(tree->left); } diff --git a/src/SDCCopt.c b/src/SDCCopt.c index 642bff15..3e1ff6fb 100644 --- a/src/SDCCopt.c +++ b/src/SDCCopt.c @@ -702,7 +702,7 @@ eBBlock **eBBlockFromiCode (iCode *ic) /* dumpraw if asked for */ if (options.dump_raw) dumpEbbsToFileExt(".dumpcse",ebbs,count); - + /* compute the data flow */ computeDataFlow (ebbs,saveCount);