From b59e5e4e1c772b197e15e9f82f42507d18bcb546 Mon Sep 17 00:00:00 2001 From: epetrich Date: Mon, 9 Feb 2004 07:06:19 +0000 Subject: [PATCH] * src/SDCCsymt.h, * src/SDCCicode.c (operandFromSymbol), * src/mcs51/ralloc.c (verifyRegsAssigned, serialRegAssign), * src/ds390/ralloc.c (verifyRegsAssigned, serialRegAssign), * src/z80/ralloc.c (verifyRegsAssigned, serialRegAssign), * src/hc08/ralloc.c (verifyRegsAssigned, serialRegAssign), * src/pic/ralloc.c (verifyRegsAssigned, serialRegAssign), * src/pic16/ralloc.c (verifyRegsAssigned, serialRegAssign): fixed bug #892038 * src/SDCCast.c (createIvalStruct, createIvalArray, gatherAutoInit), * src/SDCCglue.c (emitRegularMap, printIvalStruct, printIvalArray, printIvalCharPtr, printIvalPtr, printIval, emitStaticSeg, emitOverlay) * src/SDCCsymt.c (newSymbol), * src/SDCC.y (struct_or_union_specifier, enum_specifier, enumerator_list), * src/SDCCval.h, * src/SDCCval.c (newiList): fixed bug #885705 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3183 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 20 +++++++++++++++ src/SDCC.y | 10 ++++---- src/SDCCast.c | 8 +++--- src/SDCCglue.c | 30 +++++++++++------------ src/SDCCicode.c | 1 + src/SDCCsymt.c | 1 + src/SDCCsymt.h | 2 ++ src/SDCCval.c | 1 + src/SDCCval.h | 1 + src/ds390/ralloc.c | 59 ++++++++++++++++++++++++++++++++++++++++++++ src/hc08/ralloc.c | 60 +++++++++++++++++++++++++++++++++++++++++++++ src/mcs51/ralloc.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++ src/pic/ralloc.c | 59 ++++++++++++++++++++++++++++++++++++++++++++ src/pic16/ralloc.c | 59 ++++++++++++++++++++++++++++++++++++++++++++ src/z80/ralloc.c | 59 ++++++++++++++++++++++++++++++++++++++++++++ 15 files changed, 408 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index cdf42439..c16339d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2004-02-09 Erik Petrich + + * src/SDCCsymt.h, + * src/SDCCicode.c (operandFromSymbol), + * src/mcs51/ralloc.c (verifyRegsAssigned, serialRegAssign), + * src/ds390/ralloc.c (verifyRegsAssigned, serialRegAssign), + * src/z80/ralloc.c (verifyRegsAssigned, serialRegAssign), + * src/hc08/ralloc.c (verifyRegsAssigned, serialRegAssign), + * src/pic/ralloc.c (verifyRegsAssigned, serialRegAssign), + * src/pic16/ralloc.c (verifyRegsAssigned, serialRegAssign): fixed + bug #892038 + * src/SDCCast.c (createIvalStruct, createIvalArray, gatherAutoInit), + * src/SDCCglue.c (emitRegularMap, printIvalStruct, printIvalArray, + printIvalCharPtr, printIvalPtr, printIval, emitStaticSeg, emitOverlay) + * src/SDCCsymt.c (newSymbol), + * src/SDCC.y (struct_or_union_specifier, enum_specifier, + enumerator_list), + * src/SDCCval.h, + * src/SDCCval.c (newiList): fixed bug #885705 + 2004-02-08 Jesus Calvino-Fraga * doc/sdccman.lyx: added section 3.1.4: sdcclib. diff --git a/src/SDCC.y b/src/SDCC.y index 801fad44..71f238c0 100644 --- a/src/SDCC.y +++ b/src/SDCC.y @@ -748,17 +748,17 @@ struct_or_union_specifier // check for errors in structure members for (sym=$5; sym; sym=sym->next) { if (IS_ABSOLUTE(sym->etype)) { - werrorfl(filename, sym->lineDef, E_NOT_ALLOWED, "'at'"); + werrorfl(sym->fileDef, sym->lineDef, E_NOT_ALLOWED, "'at'"); SPEC_ABSA(sym->etype) = 0; } if (IS_SPEC(sym->etype) && SPEC_SCLS(sym->etype)) { - werrorfl(filename, sym->lineDef, E_NOT_ALLOWED, "storage class"); + werrorfl(sym->fileDef, sym->lineDef, E_NOT_ALLOWED, "storage class"); printTypeChainRaw (sym->type,NULL); SPEC_SCLS(sym->etype) = 0; } for (dsym=sym->next; dsym; dsym=dsym->next) { if (strcmp(sym->name, dsym->name)==0) { - werrorfl(filename, sym->lineDef, E_DUPLICATE_MEMBER, + werrorfl(sym->fileDef, sym->lineDef, E_DUPLICATE_MEMBER, $1==STRUCT ? "struct" : "union", sym->name); } } @@ -909,7 +909,7 @@ enum_specifier csym=findSym(enumTab,$2,$2->name); if ((csym && csym->level == $2->level)) - werrorfl(filename, $2->lineDef, E_DUPLICATE_TYPEDEF,csym->name); + werrorfl($2->fileDef, $2->lineDef, E_DUPLICATE_TYPEDEF,csym->name); enumtype = newEnumType ($4); //copyLinkChain(cenum->type); SPEC_SCLS(getSpec(enumtype)) = 0; @@ -944,7 +944,7 @@ enumerator_list for (dsym=$1; dsym; dsym=dsym->next) { if (strcmp($3->name, dsym->name)==0) - werrorfl(filename, $3->lineDef, E_DUPLICATE_MEMBER, "enum", $3->name); + werrorfl($3->fileDef, $3->lineDef, E_DUPLICATE_MEMBER, "enum", $3->name); } $3->next = $1 ; diff --git a/src/SDCCast.c b/src/SDCCast.c index 2c9e1490..62efaa6d 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -871,7 +871,7 @@ createIvalStruct (ast * sym, sym_link * type, initList * ilist) } if (iloop) { - werrorfl (filename, sym->opval.val->sym->lineDef, + werrorfl (sym->opval.val->sym->fileDef, sym->opval.val->sym->lineDef, W_EXCESS_INITIALIZERS, "struct", sym->opval.val->sym->name); } @@ -932,6 +932,7 @@ createIvalArray (ast * sym, sym_link * type, initList * ilist) // Array size was specified, and we have more initializers than needed. char *name=sym->opval.val->sym->name; int lineno=sym->opval.val->sym->lineDef; + char *filename=sym->opval.val->sym->fileDef; werrorfl (filename, lineno, W_EXCESS_INITIALIZERS, "array", name); } @@ -958,6 +959,7 @@ createIvalArray (ast * sym, sym_link * type, initList * ilist) // there has to be a better way char *name=sym->opval.val->sym->name; int lineno=sym->opval.val->sym->lineDef; + char *filename=sym->opval.val->sym->fileDef; werrorfl (filename, lineno, W_EXCESS_INITIALIZERS, "array", name); break; @@ -1132,7 +1134,7 @@ gatherAutoInit (symbol * autoChain) work = initAggregates (sym, sym->ival, NULL); } else { if (getNelements(sym->type, sym->ival)>1) { - werrorfl (filename, sym->lineDef, + werrorfl (sym->fileDef, sym->lineDef, W_EXCESS_INITIALIZERS, "scalar", sym->name); } @@ -1168,7 +1170,7 @@ gatherAutoInit (symbol * autoChain) work = initAggregates (sym, sym->ival, NULL); } else { if (getNelements(sym->type, sym->ival)>1) { - werrorfl (filename, sym->lineDef, + werrorfl (sym->fileDef, sym->lineDef, W_EXCESS_INITIALIZERS, "scalar", sym->name); } diff --git a/src/SDCCglue.c b/src/SDCCglue.c index 1a491376..222b11d2 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -304,7 +304,7 @@ emitRegularMap (memmap * map, bool addPublics, bool arFlag) ival = initAggregates (sym, sym->ival, NULL); } else { if (getNelements(sym->type, sym->ival)>1) { - werrorfl (filename, sym->lineDef, W_EXCESS_INITIALIZERS, "scalar", + werrorfl (sym->fileDef, sym->lineDef, W_EXCESS_INITIALIZERS, "scalar", sym->name); } ival = newNode ('=', newAst_VALUE (symbolVal (sym)), @@ -351,7 +351,7 @@ emitRegularMap (memmap * map, bool addPublics, bool arFlag) else { int size = getSize (sym->type); if (size==0) { - werrorfl (filename, sym->lineDef, E_UNKNOWN_SIZE, sym->name); + werrorfl (sym->fileDef, sym->lineDef, E_UNKNOWN_SIZE, sym->name); } /* allocate space */ if (options.debug) { @@ -746,7 +746,7 @@ printIvalStruct (symbol * sym, sym_link * type, sflds = SPEC_STRUCT (type)->fields; if (ilist->type != INIT_DEEP) { - werrorfl (filename, sym->lineDef, E_INIT_STRUCT, sym->name); + werrorfl (sym->fileDef, sym->lineDef, E_INIT_STRUCT, sym->name); return; } @@ -760,7 +760,7 @@ printIvalStruct (symbol * sym, sym_link * type, } } if (iloop) { - werrorfl (filename, sym->lineDef, W_EXCESS_INITIALIZERS, "struct", sym->name); + werrorfl (sym->fileDef, sym->lineDef, W_EXCESS_INITIALIZERS, "struct", sym->name); } return; } @@ -810,7 +810,7 @@ printIvalArray (symbol * sym, sym_link * type, initList * ilist, /* by a string */ if (IS_CHAR (type->next)) { if (!IS_LITERAL(list2val(ilist)->etype)) { - werrorfl (filename, ilist->lineno, E_CONST_EXPECTED); + werrorfl (ilist->filename, ilist->lineno, E_CONST_EXPECTED); return; } if (printIvalChar (type, @@ -821,7 +821,7 @@ printIvalArray (symbol * sym, sym_link * type, initList * ilist, /* not the special case */ if (ilist->type != INIT_DEEP) { - werrorfl (filename, ilist->lineno, E_INIT_STRUCT, sym->name); + werrorfl (ilist->filename, ilist->lineno, E_INIT_STRUCT, sym->name); return; } @@ -830,7 +830,7 @@ printIvalArray (symbol * sym, sym_link * type, initList * ilist, printIval (sym, type->next, iloop, oFile); if (++size > DCL_ELEM(type)) { - werrorfl (filename, sym->lineDef, W_EXCESS_INITIALIZERS, "array", sym->name); + werrorfl (sym->fileDef, sym->lineDef, W_EXCESS_INITIALIZERS, "array", sym->name); break; } } @@ -869,7 +869,7 @@ printIvalFuncPtr (sym_link * type, initList * ilist, FILE * oFile) if (IS_LITERAL(val->etype)) { if (compareType(type,val->etype)==0) { - werrorfl (filename, ilist->lineno, E_INCOMPAT_TYPES); + werrorfl (ilist->filename, ilist->lineno, E_INCOMPAT_TYPES); printFromToType (val->type, type); } printIvalCharPtr (NULL, type, val, oFile); @@ -980,7 +980,7 @@ printIvalCharPtr (symbol * sym, sym_link * type, value * val, FILE * oFile) case 3: if (IS_GENPTR(type) && floatFromVal(val)!=0) { // non-zero mcs51 generic pointer - werrorfl (filename, sym->lineDef, E_LITERAL_GENERIC); + werrorfl (sym->fileDef, sym->lineDef, E_LITERAL_GENERIC); } if (port->little_endian) { fprintf (oFile, "\t.byte %s,%s,%s\n", @@ -997,7 +997,7 @@ printIvalCharPtr (symbol * sym, sym_link * type, value * val, FILE * oFile) case 4: if (IS_GENPTR(type) && floatFromVal(val)!=0) { // non-zero ds390 generic pointer - werrorfl (filename, sym->lineDef, E_LITERAL_GENERIC); + werrorfl (sym->fileDef, sym->lineDef, E_LITERAL_GENERIC); } if (port->little_endian) { fprintf (oFile, "\t.byte %s,%s,%s,%s\n", @@ -1055,7 +1055,7 @@ printIvalPtr (symbol * sym, sym_link * type, initList * ilist, FILE * oFile) /* check the type */ if (compareType (type, val->type) == 0) { - werrorfl (filename, ilist->lineno, W_INIT_WRONG); + werrorfl (ilist->filename, ilist->lineno, W_INIT_WRONG); printFromToType (val->type, type); } @@ -1143,7 +1143,7 @@ printIval (symbol * sym, sym_link * type, initList * ilist, FILE * oFile) if (ilist->type!=INIT_NODE) { // or a 1-element list if (ilist->init.deep->next) { - werrorfl (filename, sym->lineDef, W_EXCESS_INITIALIZERS, "scalar", + werrorfl (sym->fileDef, sym->lineDef, W_EXCESS_INITIALIZERS, "scalar", sym->name); } else { ilist=ilist->init.deep; @@ -1160,7 +1160,7 @@ printIval (symbol * sym, sym_link * type, initList * ilist, FILE * oFile) IS_PTR(type) && DCL_TYPE(type)==CPOINTER) { // no sweat } else { - werrorfl (filename, ilist->lineno, E_TYPE_MISMATCH, "assignment", " "); + werrorfl (ilist->filename, ilist->lineno, E_TYPE_MISMATCH, "assignment", " "); printFromToType(itype, type); } } @@ -1259,7 +1259,7 @@ emitStaticSeg (memmap * map, FILE * out) int size = getSize (sym->type); if (size==0) { - werrorfl (filename, sym->lineDef, E_UNKNOWN_SIZE,sym->name); + werrorfl (sym->fileDef, sym->lineDef, E_UNKNOWN_SIZE,sym->name); } fprintf (out, "%s:\n", sym->rname); /* special case for character strings */ @@ -1515,7 +1515,7 @@ emitOverlay (FILE * afile) int size = getSize(sym->type); if (size==0) { - werrorfl (filename, sym->lineDef, E_UNKNOWN_SIZE); + werrorfl (sym->fileDef, sym->lineDef, E_UNKNOWN_SIZE); } if (options.debug) fprintf (afile, "==.\n"); diff --git a/src/SDCCicode.c b/src/SDCCicode.c index 34d54375..381a2bcb 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -1533,6 +1533,7 @@ operandFromSymbol (symbol * sym) and before liveRange calculation */ sym->reqv = newiTempOperand (sym->type, 0); sym->reqv->key = sym->key; + OP_SYMBOL (sym->reqv)->prereqv = sym; OP_SYMBOL (sym->reqv)->key = sym->key; OP_SYMBOL (sym->reqv)->isreqv = 1; OP_SYMBOL (sym->reqv)->islocal = 1; diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index d3bfee79..88df7feb 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -293,6 +293,7 @@ newSymbol (char *name, int scope) sym->level = scope; /* set the level */ sym->block = currBlockno; sym->lineDef = mylineno; /* set the line number */ + sym->fileDef = currFname; return sym; } diff --git a/src/SDCCsymt.h b/src/SDCCsymt.h index 9a4860b8..0ac55f77 100644 --- a/src/SDCCsymt.h +++ b/src/SDCCsymt.h @@ -297,6 +297,7 @@ typedef struct symbol struct iCode *fuse; /* furthest use */ struct iCode *rematiCode; /* rematerialse with which instruction */ struct operand *reqv; /* register equivalent of a local variable */ + struct symbol *prereqv; /* symbol before register equiv. substituion */ union { struct symbol *spillLoc; /* register spil location */ @@ -307,6 +308,7 @@ typedef struct symbol unsigned offset; /* offset from top if struct */ int lineDef; /* defined line number */ + char *fileDef; /* defined filename */ int lastLine; /* for functions the last line */ struct sym_link *type; /* 1st link to declator chain */ struct sym_link *etype; /* last link to declarator chn */ diff --git a/src/SDCCval.c b/src/SDCCval.c index a0d5e15c..e72baee3 100644 --- a/src/SDCCval.c +++ b/src/SDCCval.c @@ -57,6 +57,7 @@ newiList (int type, void *ilist) nilist->type = type; nilist->lineno = mylineno; + nilist->filename = currFname; switch (type) { diff --git a/src/SDCCval.h b/src/SDCCval.h index 92e622fb..d49495a8 100644 --- a/src/SDCCval.h +++ b/src/SDCCval.h @@ -57,6 +57,7 @@ typedef struct initList { int type; int lineno; + char *filename; union { struct ast *node; diff --git a/src/ds390/ralloc.c b/src/ds390/ralloc.c index 42de2a96..8760bd7b 100644 --- a/src/ds390/ralloc.c +++ b/src/ds390/ralloc.c @@ -1210,6 +1210,31 @@ void reassignUnusedLRs (bitVect *unused) } } +/*------------------------------------------------------------------*/ +/* verifyRegsAssigned - make sure an iTemp is properly initialized; */ +/* it should either have registers or have beed spilled. Otherwise, */ +/* there was an uninitialized variable, so just spill this to get */ +/* the operand in a valid state. */ +/*------------------------------------------------------------------*/ +static void +verifyRegsAssigned (operand *op, iCode * ic) +{ + symbol * sym; + + if (!op) return; + if (!IS_ITEMP (op)) return; + + sym = OP_SYMBOL (op); + if (sym->isspilt) return; + if (!sym->nRegs) return; + if (sym->regs[0]) return; + + werrorfl (ic->filename, ic->lineno, W_LOCAL_NOINIT, + sym->prereqv ? sym->prereqv->name : sym->name); + spillThis (sym); +} + + /*-----------------------------------------------------------------*/ /* serialRegAssign - serially allocate registers to the variables */ /*-----------------------------------------------------------------*/ @@ -1379,6 +1404,40 @@ serialRegAssign (eBBlock ** ebbs, int count) } reassignUnusedLRs(unusedLRs); } + + /* Check for and fix any problems with uninitialized operands */ + for (i = 0; i < count; i++) + { + iCode *ic; + + if (ebbs[i]->noPath && + (ebbs[i]->entryLabel != entryLabel && + ebbs[i]->entryLabel != returnLabel)) + continue; + + for (ic = ebbs[i]->sch; ic; ic = ic->next) + { + if (SKIP_IC2 (ic)) + continue; + + if (ic->op == IFX) + { + verifyRegsAssigned (IC_COND (ic), ic); + continue; + } + + if (ic->op == JUMPTABLE) + { + verifyRegsAssigned (IC_JTCOND (ic), ic); + continue; + } + + verifyRegsAssigned (IC_RESULT (ic), ic); + verifyRegsAssigned (IC_LEFT (ic), ic); + verifyRegsAssigned (IC_RIGHT (ic), ic); + } + } + } /*-----------------------------------------------------------------*/ diff --git a/src/hc08/ralloc.c b/src/hc08/ralloc.c index be4a1c97..ee599f19 100644 --- a/src/hc08/ralloc.c +++ b/src/hc08/ralloc.c @@ -1169,6 +1169,32 @@ xchgPositions: return change; } +/*------------------------------------------------------------------*/ +/* verifyRegsAssigned - make sure an iTemp is properly initialized; */ +/* it should either have registers or have beed spilled. Otherwise, */ +/* there was an uninitialized variable, so just spill this to get */ +/* the operand in a valid state. */ +/*------------------------------------------------------------------*/ +static void +verifyRegsAssigned (operand *op, iCode * ic) +{ + symbol * sym; + + if (!op) return; + if (!IS_ITEMP (op)) return; + + sym = OP_SYMBOL (op); + if (sym->isspilt) return; + if (!sym->nRegs) return; + if (sym->regs[0]) return; + + werrorfl (ic->filename, ic->lineno, W_LOCAL_NOINIT, + sym->prereqv ? sym->prereqv->name : sym->name); + spillThis (sym); +} + + + /*-----------------------------------------------------------------*/ /* serialRegAssign - serially allocate registers to the variables */ /*-----------------------------------------------------------------*/ @@ -1329,6 +1355,40 @@ serialRegAssign (eBBlock ** ebbs, int count) } } } + + /* Check for and fix any problems with uninitialized operands */ + for (i = 0; i < count; i++) + { + iCode *ic; + + if (ebbs[i]->noPath && + (ebbs[i]->entryLabel != entryLabel && + ebbs[i]->entryLabel != returnLabel)) + continue; + + for (ic = ebbs[i]->sch; ic; ic = ic->next) + { + if (SKIP_IC2 (ic)) + continue; + + if (ic->op == IFX) + { + verifyRegsAssigned (IC_COND (ic), ic); + continue; + } + + if (ic->op == JUMPTABLE) + { + verifyRegsAssigned (IC_JTCOND (ic), ic); + continue; + } + + verifyRegsAssigned (IC_RESULT (ic), ic); + verifyRegsAssigned (IC_LEFT (ic), ic); + verifyRegsAssigned (IC_RIGHT (ic), ic); + } + } + } /*-----------------------------------------------------------------*/ diff --git a/src/mcs51/ralloc.c b/src/mcs51/ralloc.c index e45b233c..a8273950 100644 --- a/src/mcs51/ralloc.c +++ b/src/mcs51/ralloc.c @@ -1099,6 +1099,33 @@ xchgPositions: return change; } + +/*------------------------------------------------------------------*/ +/* verifyRegsAssigned - make sure an iTemp is properly initialized; */ +/* it should either have registers or have beed spilled. Otherwise, */ +/* there was an uninitialized variable, so just spill this to get */ +/* the operand in a valid state. */ +/*------------------------------------------------------------------*/ +static void +verifyRegsAssigned (operand *op, iCode * ic) +{ + symbol * sym; + + if (!op) return; + if (!IS_ITEMP (op)) return; + + sym = OP_SYMBOL (op); + if (sym->isspilt) return; + if (!sym->nRegs) return; + if (sym->regs[0]) return; + + werrorfl (ic->filename, ic->lineno, W_LOCAL_NOINIT, + sym->prereqv ? sym->prereqv->name : sym->name); + spillThis (sym); +} + + + /*-----------------------------------------------------------------*/ /* serialRegAssign - serially allocate registers to the variables */ /*-----------------------------------------------------------------*/ @@ -1272,6 +1299,39 @@ serialRegAssign (eBBlock ** ebbs, int count) } } } + + /* Check for and fix any problems with uninitialized operands */ + for (i = 0; i < count; i++) + { + iCode *ic; + + if (ebbs[i]->noPath && + (ebbs[i]->entryLabel != entryLabel && + ebbs[i]->entryLabel != returnLabel)) + continue; + + for (ic = ebbs[i]->sch; ic; ic = ic->next) + { + if (SKIP_IC2 (ic)) + continue; + + if (ic->op == IFX) + { + verifyRegsAssigned (IC_COND (ic), ic); + continue; + } + + if (ic->op == JUMPTABLE) + { + verifyRegsAssigned (IC_JTCOND (ic), ic); + continue; + } + + verifyRegsAssigned (IC_RESULT (ic), ic); + verifyRegsAssigned (IC_LEFT (ic), ic); + verifyRegsAssigned (IC_RIGHT (ic), ic); + } + } } /*-----------------------------------------------------------------*/ @@ -1445,6 +1505,7 @@ mcs51_rUmaskForOp (operand * op) for (j = 0; j < sym->nRegs; j++) { + if (sym->regs[j]) /* EEP - debug */ rumask = bitVectSetBit (rumask, sym->regs[j]->rIdx); } diff --git a/src/pic/ralloc.c b/src/pic/ralloc.c index 6c67f75c..7266470d 100644 --- a/src/pic/ralloc.c +++ b/src/pic/ralloc.c @@ -2204,6 +2204,31 @@ xchgPositions: } } +/*------------------------------------------------------------------*/ +/* verifyRegsAssigned - make sure an iTemp is properly initialized; */ +/* it should either have registers or have beed spilled. Otherwise, */ +/* there was an uninitialized variable, so just spill this to get */ +/* the operand in a valid state. */ +/*------------------------------------------------------------------*/ +static void +verifyRegsAssigned (operand *op, iCode * ic) +{ + symbol * sym; + + if (!op) return; + if (!IS_ITEMP (op)) return; + + sym = OP_SYMBOL (op); + if (sym->isspilt) return; + if (!sym->nRegs) return; + if (sym->regs[0]) return; + + werrorfl (ic->filename, ic->lineno, W_LOCAL_NOINIT, + sym->prereqv ? sym->prereqv->name : sym->name); + spillThis (sym); +} + + /*-----------------------------------------------------------------*/ /* serialRegAssign - serially allocate registers to the variables */ /*-----------------------------------------------------------------*/ @@ -2372,6 +2397,40 @@ serialRegAssign (eBBlock ** ebbs, int count) } } } + + /* Check for and fix any problems with uninitialized operands */ + for (i = 0; i < count; i++) + { + iCode *ic; + + if (ebbs[i]->noPath && + (ebbs[i]->entryLabel != entryLabel && + ebbs[i]->entryLabel != returnLabel)) + continue; + + for (ic = ebbs[i]->sch; ic; ic = ic->next) + { + if (SKIP_IC2 (ic)) + continue; + + if (ic->op == IFX) + { + verifyRegsAssigned (IC_COND (ic), ic); + continue; + } + + if (ic->op == JUMPTABLE) + { + verifyRegsAssigned (IC_JTCOND (ic), ic); + continue; + } + + verifyRegsAssigned (IC_RESULT (ic), ic); + verifyRegsAssigned (IC_LEFT (ic), ic); + verifyRegsAssigned (IC_RIGHT (ic), ic); + } + } + } /*-----------------------------------------------------------------*/ diff --git a/src/pic16/ralloc.c b/src/pic16/ralloc.c index 2f21d221..58b8906b 100644 --- a/src/pic16/ralloc.c +++ b/src/pic16/ralloc.c @@ -2013,6 +2013,31 @@ xchgPositions: } } +/*------------------------------------------------------------------*/ +/* verifyRegsAssigned - make sure an iTemp is properly initialized; */ +/* it should either have registers or have beed spilled. Otherwise, */ +/* there was an uninitialized variable, so just spill this to get */ +/* the operand in a valid state. */ +/*------------------------------------------------------------------*/ +static void +verifyRegsAssigned (operand *op, iCode * ic) +{ + symbol * sym; + + if (!op) return; + if (!IS_ITEMP (op)) return; + + sym = OP_SYMBOL (op); + if (sym->isspilt) return; + if (!sym->nRegs) return; + if (sym->regs[0]) return; + + werrorfl (ic->filename, ic->lineno, W_LOCAL_NOINIT, + sym->prereqv ? sym->prereqv->name : sym->name); + spillThis (sym); +} + + /*-----------------------------------------------------------------*/ /* serialRegAssign - serially allocate registers to the variables */ /*-----------------------------------------------------------------*/ @@ -2182,6 +2207,40 @@ serialRegAssign (eBBlock ** ebbs, int count) } } } + + /* Check for and fix any problems with uninitialized operands */ + for (i = 0; i < count; i++) + { + iCode *ic; + + if (ebbs[i]->noPath && + (ebbs[i]->entryLabel != entryLabel && + ebbs[i]->entryLabel != returnLabel)) + continue; + + for (ic = ebbs[i]->sch; ic; ic = ic->next) + { + if (SKIP_IC2 (ic)) + continue; + + if (ic->op == IFX) + { + verifyRegsAssigned (IC_COND (ic), ic); + continue; + } + + if (ic->op == JUMPTABLE) + { + verifyRegsAssigned (IC_JTCOND (ic), ic); + continue; + } + + verifyRegsAssigned (IC_RESULT (ic), ic); + verifyRegsAssigned (IC_LEFT (ic), ic); + verifyRegsAssigned (IC_RIGHT (ic), ic); + } + } + } /*-----------------------------------------------------------------*/ diff --git a/src/z80/ralloc.c b/src/z80/ralloc.c index 17d3b806..ed6868c8 100644 --- a/src/z80/ralloc.c +++ b/src/z80/ralloc.c @@ -1046,6 +1046,31 @@ tryAllocatingRegPair (symbol * sym) return FALSE; } +/*------------------------------------------------------------------*/ +/* verifyRegsAssigned - make sure an iTemp is properly initialized; */ +/* it should either have registers or have beed spilled. Otherwise, */ +/* there was an uninitialized variable, so just spill this to get */ +/* the operand in a valid state. */ +/*------------------------------------------------------------------*/ +static void +verifyRegsAssigned (operand *op, iCode * ic) +{ + symbol * sym; + + if (!op) return; + if (!IS_ITEMP (op)) return; + + sym = OP_SYMBOL (op); + if (sym->isspilt) return; + if (!sym->nRegs) return; + if (sym->regs[0]) return; + + werrorfl (ic->filename, ic->lineno, W_LOCAL_NOINIT, + sym->prereqv ? sym->prereqv->name : sym->name); + spillThis (sym); +} + + /** Serially allocate registers to the variables. This is the main register allocation function. It is called after packing. @@ -1206,6 +1231,40 @@ serialRegAssign (eBBlock ** ebbs, int count) } } } + + /* Check for and fix any problems with uninitialized operands */ + for (i = 0; i < count; i++) + { + iCode *ic; + + if (ebbs[i]->noPath && + (ebbs[i]->entryLabel != entryLabel && + ebbs[i]->entryLabel != returnLabel)) + continue; + + for (ic = ebbs[i]->sch; ic; ic = ic->next) + { + if (SKIP_IC2 (ic)) + continue; + + if (ic->op == IFX) + { + verifyRegsAssigned (IC_COND (ic), ic); + continue; + } + + if (ic->op == JUMPTABLE) + { + verifyRegsAssigned (IC_JTCOND (ic), ic); + continue; + } + + verifyRegsAssigned (IC_RESULT (ic), ic); + verifyRegsAssigned (IC_LEFT (ic), ic); + verifyRegsAssigned (IC_RIGHT (ic), ic); + } + } + } /*-----------------------------------------------------------------*/ -- 2.30.2