This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 2/6] Convert asan.c to inchash
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Andi Kleen <andi at firstfloor dot org>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Andi Kleen <ak at linux dot intel dot com>
- Date: Mon, 28 Jul 2014 10:05:22 +0200
- Subject: Re: [PATCH 2/6] Convert asan.c to inchash
- Authentication-results: sourceware.org; auth=none
- References: <1406489825-9561-1-git-send-email-andi at firstfloor dot org> <1406489825-9561-2-git-send-email-andi at firstfloor dot org> <1406489825-9561-3-git-send-email-andi at firstfloor dot org>
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
>