Cope with empty sblocks when producing dot graphs.

This commit is contained in:
Bill Currie 2012-11-21 12:23:15 +09:00
parent 2c09464e80
commit c759b73b24

View file

@ -94,15 +94,22 @@ flow_sblock (dstring_t *dstr, sblock_t *sblock, int blockno)
dasprintf (dstr, " <td></td>\n");
dasprintf (dstr, " </tr>\n");
dasprintf (dstr, " </table>>];\n");
if (sblock->next && !flow_is_goto ((statement_t *) sblock->tail)
&& !flow_is_jumpb ((statement_t *) sblock->tail)
&& !flow_is_return ((statement_t *) sblock->tail))
dasprintf (dstr, " sb_%p:e -> sb_%p:s;\n", sblock, sblock->next);
if ((target_list = flow_get_targetlist ((statement_t *) sblock->tail))) {
for (target = target_list; *target; target++)
dasprintf (dstr, " sb_%p:e -> sb_%p:s [label=\"%s\"];\n", sblock,
*target, ((statement_t *) sblock->tail)->opcode);
free (target_list);
if (sblock->statements) {
statement_t *st = (statement_t *) sblock->tail;
if (sblock->next
&& !flow_is_goto (st)
&& !flow_is_jumpb (st)
&& !flow_is_return (st))
dasprintf (dstr, " sb_%p:e -> sb_%p:s;\n", sblock, sblock->next);
if ((target_list = flow_get_targetlist (st))) {
for (target = target_list; *target; target++)
dasprintf (dstr, " sb_%p:e -> sb_%p:s [label=\"%s\"];\n",
sblock, *target, st->opcode);
free (target_list);
}
} else {
if (sblock->next)
dasprintf (dstr, " sb_%p:e -> sb_%p:s;\n", sblock, sblock->next);
}
dasprintf (dstr, "\n");
}