> 2025-03-25  Jakub Jelinek  <ja...@redhat.com>
>           Andi Kleen  <a...@gcc.gnu.org>
> 
>       PR gcov-profile/118442
>       * profile.cc (branch_prob): Ignore EDGE_FAKE edges from musttail calls
>       to EXIT.
> 
>       * c-c++-common/pr118442.c: New test.
> 
> --- gcc/profile.cc.jj 2025-01-02 11:23:16.458517673 +0100
> +++ gcc/profile.cc    2025-03-25 09:57:21.860398601 +0100
> @@ -1340,6 +1340,20 @@ branch_prob (bool thunk)
>         EDGE_INFO (e)->ignore = 1;
>         ignored_edges++;
>       }
> +      /* Ignore fake edges after musttail calls.  */
> +      if ((e->flags & EDGE_FAKE)
> +       && e->dest == EXIT_BLOCK_PTR_FOR_FN (cfun))
> +     {
> +       gimple_stmt_iterator gsi = gsi_last_bb (e->src);

At least the musttail pass allows some statements after the call, like labels
and debug information. Not sure if it matters.

The rest looks good to me.

-Andi

> +       gimple *stmt = gsi_stmt (gsi);
> +       if (stmt
> +           && is_gimple_call (stmt)
> +           && gimple_call_must_tail_p (as_a <const gcall *> (stmt)))
> +         {
> +           EDGE_INFO (e)->ignore = 1;
> +           ignored_edges++;
> +         }
> +     }
>      }

Reply via email to