This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [GOOGLE] Represent the callsite with lineno only for AutoFDO


Ok (please add a short comment on the decl_lineno which encodes
discriminator in it).

David

On Wed, Oct 9, 2013 at 4:57 PM, Dehao Chen <dehao@google.com> wrote:
> In legacy AutoFDO, callsite is represented as a (lineno, callee_name)
> pair because there could be multiple calls in one line. However, as we
> enhanced the debug info by assigning discriminators for each function
> call in the same line, callee_name is not needed when indexing the
> callsite.
>
> This patch will improve AutoFDO performance because some functions
> have alias (e.g. constructors/destructors), which could make the
> function name matching fail.
>
> Bootstrapped and passed regression test.
>
> OK for google-4_8 branch.
> Dehao
>
> Index: gcc/auto-profile.c
> ===================================================================
> --- gcc/auto-profile.c (revision 203331)
> +++ gcc/auto-profile.c (working copy)
> @@ -174,10 +174,8 @@ class function_instance {
>    const function_instance *get_function_instance_by_decl (unsigned lineno,
>    tree decl) const;
>
> -  /* Callsite, represented as (decl_lineno, callee_function_name_index).  */
> -  typedef std::pair<unsigned, unsigned> callsite;
> -  /* Map from callsite to callee function_instance.  */
> -  typedef std::map<callsite, const function_instance *> callsite_map;
> +  /* Map from callsite decl_lineno to callee function_instance.  */
> +  typedef std::map<unsigned, const function_instance *> callsite_map;
>    /* Map from source location (decl_lineno) to profile (count_info).  */
>    typedef std::map<unsigned, count_info> position_count_map;
>
> @@ -430,8 +428,7 @@ const function_instance *function_instance::get_fu
>    int func_name_idx = afdo_function_name_map->get_index_by_decl (decl);
>    if (func_name_idx != -1)
>      {
> -      callsite_map::const_iterator ret = callsites.find (
> -  std::make_pair (lineno, func_name_idx));
> +      callsite_map::const_iterator ret = callsites.find (lineno);
>        if (ret != callsites.end ())
>   return ret->second;
>      }
> @@ -439,8 +436,7 @@ const function_instance *function_instance::get_fu
>        lang_hooks.dwarf_name (decl, 0));
>    if (func_name_idx != -1)
>      {
> -      callsite_map::const_iterator ret = callsites.find (
> -  std::make_pair (lineno, func_name_idx));
> +      callsite_map::const_iterator ret = callsites.find (lineno);
>        if (ret != callsites.end ())
>   return ret->second;
>      }
> @@ -500,10 +496,7 @@ const function_instance *function_instance::read_f
>      }
>    for (unsigned i = 0; i < num_callsites; i++) {
>      unsigned offset = gcov_read_unsigned ();
> -    const function_instance *callee_function_instance =
> - read_function_instance (stack, 0);
> -    s->callsites[std::make_pair (offset, callee_function_instance->name ())] =
> - callee_function_instance;
> +    s->callsites[offset] = read_function_instance (stack, 0);
>    }
>    stack->pop_back();
>    return s;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]