X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2FSDCCcflow.c;h=e3befba85b65249664df21bdf03121b9aa48e650;hb=909e288720dc2362fdce0ef27f6780dff3e49c81;hp=2dc5313511da4c1957ea4329bcaff58817075de8;hpb=29779804200986ce903b5086441b49265a122dc5;p=fw%2Fsdcc diff --git a/src/SDCCcflow.c b/src/SDCCcflow.c index 2dc53135..e3befba8 100644 --- a/src/SDCCcflow.c +++ b/src/SDCCcflow.c @@ -120,7 +120,6 @@ eBBSuccessors (eBBlock ** ebbs, int count) if (ebbs[i]->ech) { - if (ebbs[i]->ech->op != GOTO && ebbs[i]->ech->op != RETURN && ebbs[i]->ech->op != JUMPTABLE) @@ -132,6 +131,12 @@ eBBSuccessors (eBBlock ** ebbs, int count) addSuccessor (ebbs[i], ebbs[j]); /* add it */ } + else + { + if (i && ebbs[i-1]->ech && ebbs[i-1]->ech->op==IFX) { + ebbs[i]->isConditionalExitFrom=ebbs[i-1]; + } + } } /* no instructions in the block */ /* could happen for dummy blocks */ else @@ -161,7 +166,7 @@ eBBSuccessors (eBBlock ** ebbs, int count) switch (ic->op) { case GOTO: /* goto has edge to label */ - succ = eBBWithEntryLabel (ebbs, ic->argLabel.label, count); + succ = eBBWithEntryLabel (ebbs, ic->label, count); break; case IFX: /* conditional jump */ @@ -425,3 +430,35 @@ computeControlFlow (eBBlock ** ebbs, int count, int reSort) qsort (ebbs, saveCount, sizeof (eBBlock *), dfNumCompare); } + +/*-----------------------------------------------------------------*/ +/* returnAtEnd - returns 1 if Basic Block has a return at the end */ +/* of it */ +/*-----------------------------------------------------------------*/ +int returnAtEnd (eBBlock *ebp) +{ + /* case 1. + This basic block ends in a return statment + */ + if (ebp->ech && ebp->ech->op == RETURN) return 1; + + /* case 2. + This basic block has only one successor and that + successor has only one return statement + */ + if (elementsInSet(ebp->succList) == 1) { + eBBlock *succ = setFirstItem(ebp->succList); + /* could happen for dummy blocks */ + if (!succ->sch || !succ->ech) return 0; + + /* first iCode is a return */ + if (succ->sch->op == RETURN) return 2; + + /* or first iCode is a label & the next & + last icode is a return */ + if (succ->sch->op == LABEL && succ->sch->next == succ->ech && + succ->ech->op == RETURN ) return 2; + } + + return 0; +}