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: [PATCH 2/6] Convert asan.c to inchash


On Sun, Jul 27, 2014 at 9:37 PM, Andi Kleen <andi@firstfloor.org> wrote:
> From: Andi Kleen <ak@linux.intel.com>
>
> gcc/:
>
> 2014-07-25  Andi Kleen  <ak@linux.intel.com>
>
>         * asan.c (asan_mem_ref_hasher::hash): Convert to inchash.
> ---
>  gcc/asan.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/gcc/asan.c b/gcc/asan.c
> index 475dd82..f7fa55f 100644
> --- a/gcc/asan.c
> +++ b/gcc/asan.c
> @@ -348,9 +348,10 @@ struct asan_mem_ref_hasher
>  inline hashval_t
>  asan_mem_ref_hasher::hash (const asan_mem_ref *mem_ref)
>  {
> -  hashval_t h = iterative_hash_expr (mem_ref->start, 0);
> -  h = iterative_hash_host_wide_int (mem_ref->access_size, h);
> -  return h;
> +  inchash hstate;
> +  iterative_hstate_expr (mem_ref->start, hstate);

Btw, this is what I mentioned with using a namespace instead of a class.
With a namespace you could have extended it with an API like

inchash::add_expr (hstate, mem_ref->start);

which would look the same API-wise as

> +  hstate.add_wide_int (mem_ref->access_size);

inchash::add_wide_int (hstate, mem_ref->access_size);

It would of course mean not using member functions but at least
it would have had a consistent API.

Richard.

> +  return hstate.end ();
>  }
>
>  /* Compare two memory references.  We accept the length of either
> --
> 2.0.1
>


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