This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Duplicating immediate predecessor of EXIT_BLOCK
mcrosier@ncsu.edu writes:
> > mcrosier@ncsu.edu writes:
> >
> >> I'm interested in duplicating the immediate predecessor basic block of
> >> the
> >> EXIT_BLOCK, but this makes the EXIT_BLOCK have 2 predecessors which
> >> isn't
> >> allowed. Can someone give me some guidances as to how I can insert a
> >> bogus block between the two to allow the duplication?
> >
> > Why can't EXIT_BLOCK have two predecessors?
> >
> > Ian
> >
>
> From can_duplicate_block_p():
> /* Duplicating fallthru block to exit would require adding a jump and
> splitting the real last BB. */
> e = find_edge (bb, EXIT_BLOCK_PTR);
> if ( e && (e->flags & EDGE_FALLTHRU))
> return false;
I don't know why that is there. I see that it has been there since
the function was written. There may well be a good reason for it. Or
not. I don't know.
Still, it doesn't follow that EXIT_BLOCK can't have more than one
predecessor. Even that code just prevents it from having more than
one EDGE_FALLTHRU predecessor.
Anyhow, to answer your original question, you should be able to call
split_edge to introduce a new basic block between your block and
EXIT_BLOCK.
Ian