if (ebbs[i]->ech)
{
-
if (ebbs[i]->ech->op != GOTO &&
ebbs[i]->ech->op != RETURN &&
ebbs[i]->ech->op != JUMPTABLE)
addSuccessor (ebbs[i], ebbs[j]); /* add it */
}
+ else
+ {
+ int j=i;
+ while (j--) {
+ if (ebbs[j]->ech && ebbs[j]->ech->op==IFX &&
+ (isSymbolEqual(IC_TRUE(ebbs[j]->ech), ebbs[i]->entryLabel) ||
+ isSymbolEqual(IC_FALSE(ebbs[j]->ech), ebbs[i]->entryLabel))) {
+ ebbs[i]->hasConditionalExit=1;
+ }
+ }
+ }
} /* no instructions in the block */
/* could happen for dummy blocks */
else
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 */
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;
+}