> Am 26.03.2025 um 08:45 schrieb Jakub Jelinek <ja...@redhat.com>:
> 
> On Tue, Mar 25, 2025 at 04:44:45PM +0100, Jakub Jelinek wrote:
>> On Tue, Mar 25, 2025 at 08:33:41AM -0700, Andi Kleen wrote:
>>>> 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.
>> 
>> I think it shouldn't.
>> gimple_flow_call_edges_add splits basic blocks with calls after those calls
>> and adds the EDGE_FAKE edges to EXIT, so the last stmt at the end of
>> the bb from which the edge goes should be the call.
> 
> In particular
>                  /* Note that the following may create a new basic block
>                     and renumber the existing basic blocks.  */
>                  if (stmt != last_stmt)
>                    {
>                      e = split_block (bb, stmt);
>                      if (e)
>                        blocks_split++;
>                    }
>                  e = make_edge (bb, EXIT_BLOCK_PTR_FOR_FN (cfun), EDGE_FAKE);
> Anyway, the patch has been bootstrapped/regtested on x86_64-linux and
> i686-linux successfully.  Ok for trunk?

Ok

Richard 

>    Jakub
> 

Reply via email to