On Sun, 22 Jun 2025, Jan Hubicka wrote:

> Hi,
> auto-fdo is currently confused by a fact that all inlined functions get
> locators with 0 discriminator, so it is not bale to distinguish multiple
> inlined calls from single line.
> 
> Discriminator is lost by calling LOCATION_LOCUS before copying it from
> former call statement.  I believe this is only intended to drop block
> annotations.
> 
> Bootstrapped/regtested x86_64-linux, OK?
> 
> gcc/ChangeLog:
> 
>       * tree-inline.cc (expand_call_inline): Preserve discriminator.
> 
> diff --git a/gcc/tree-inline.cc b/gcc/tree-inline.cc
> index dee2dfc2620..fa2641780a5 100644
> --- a/gcc/tree-inline.cc
> +++ b/gcc/tree-inline.cc
> @@ -5014,6 +5014,9 @@ expand_call_inline (basic_block bb, gimple *stmt, 
> copy_body_data *id,
>        /* We do want to assign a not UNKNOWN_LOCATION BLOCK_SOURCE_LOCATION
>           to make inlined_function_outer_scope_p return true on this BLOCK.  
> */
>        location_t loc = LOCATION_LOCUS (gimple_location (stmt));
> +      if (loc != UNKNOWN_LOCATION)
> +     loc = location_with_discriminator
> +             (loc, get_discriminator_from_loc (gimple_location (stmt)));

So this doesn't preserve the discriminator on UNKNOWN_LOCATION?  Don't
you maybe want

  if (has_discriminator (gimple_location (stmt)))
    loc = location_with_discriminator (loc, get_disc....

?  Also ...

>        if (loc == UNKNOWN_LOCATION)
>       loc = LOCATION_LOCUS (DECL_SOURCE_LOCATION (fn));
>        if (loc == UNKNOWN_LOCATION)

... these no longer trigger when there's a discriminator, but we do
want a != UNKNOWN_LOCATION LOCATION_LOCUS as the comment says.  So
better apply the discriminator last?

Thanks,
Richard.


-- 
Richard Biener <rguent...@suse.de>
SUSE Software Solutions Germany GmbH,
Frankenstrasse 146, 90461 Nuernberg, Germany;
GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)

Reply via email to