On Mon, Oct 22, 2012 at 9:35 PM, Jakub Jelinek <ja...@redhat.com> wrote:
> Hi!
>
> On the following testcase we have two endless loops before cddce2:
>
> Sender_signal (int Connect)
> {
>   int State;
>   unsigned int occurrence;
>
>   <bb 2>:
>   if (Connect_6(D) != 0)
>     goto <bb 8>;
>   else
>     goto <bb 7>;
>
>   <bb 3>:
>   # occurrence_8 = PHI <0(7), occurrence_12(4)>
>   occurrence_12 = occurrence_8 + 1;
>   __builtin_printf ("Sender_Signal occurrence %u\n", occurrence_12);
>
>   <bb 4>:
>   goto <bb 3>;
>
>   <bb 5>:
>
>   <bb 6>:
>   goto <bb 5>;
>
>   <bb 7>:
>   goto <bb 3>;
>
>   <bb 8>:
>   goto <bb 5>;
>
> }
>
> The problem are the two empty bbs on the path from the conditional
> at the end of bb2 and the endless loops (i.e. bb7 and bb8).
> In presence of infinite loops dominance.c adds fake edges to exit pretty
> arbitrarily (it uses FOR_EACH_BB_REVERSE and for unconnected bbs
> computes post-dominance and adds fake edges to exit), so with the above
> testcases both bb7 and bb8 have exit block as immediate post-dominator,
> so find_control_dependence stops at those bb's when starting from the
> 2->7 resp. 2->8 edges.  bb7/bb8 don't have a control stmt at the end,
> so mark_last_stmt_necessary doesn't mark any stmt as necessary in them
> and thus if (Connect_6(D) != 0) GIMPLE_COND is never marked as necessary
> and the whole endless loop with printfs in it is removed.

I'm not sure I'm following this alright, but AFAICT bb7 and bb8 are
control-dependent on the "if" in bb2. To preserve the infinite-loop
semantics the control parent of the infinite loop must be inherently
preserved (because empty infinite loops can't mark any feeding
statements). So shouldn't the code in find_obviously_necessary_stmts
that handles infinite loops mark the last statement of control parents
necessary?

Ciao!
Steven

Reply via email to