This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR rtl-optimization/33796: valgrind error with -O2 for linux kernel code
- From: Kenneth Zadeck <zadeck at naturalbridge dot com>
- To: Peter Bergner <bergner at vnet dot ibm dot com>
- Cc: gcc-patches at gcc dot gnu dot org, Janis Johnson <janis187 at us dot ibm dot com>
- Date: Wed, 16 Jan 2008 17:57:07 -0500
- Subject: Re: [PATCH] Fix PR rtl-optimization/33796: valgrind error with -O2 for linux kernel code
- References: <20080116225555.GA6413@vervain.rchland.ibm.com>
Peter Bergner wrote:
> I'm testing the following patch from Janis along with a comment about
> why we're changing from xmalloc to xcalloc. Ok for mainline if it
> passes bootstrap and regression testing?
>
> Peter
>
> PR rtl-optimization/33796
> * sparseset.c (sparseset_alloc): Use xcalloc rather than xmalloc.
>
> Index: sparseset.c
> ===================================================================
> --- sparseset.c (revision 131578)
> +++ sparseset.c (working copy)
> @@ -30,7 +30,12 @@
> unsigned int n_bytes = sizeof (struct sparseset_def)
> + ((n_elms - 1) * 2 * sizeof (SPARSESET_ELT_TYPE));
>
> - sparseset set = (sparseset) xmalloc (n_bytes);
> + /* We use xcalloc rather than xmalloc to silence some valgrind uninitialized
> + read errors when accessing set->sparse[n] when "n" is not, and never has
> + been, in the set. These uninitialized reads are expected, by design and
> + harmless. If this turns into a performance problem due to some future
> + additional users of sparseset, we can revisit this decision. */
> + sparseset set = (sparseset) xcalloc (1, n_bytes);
> set->dense = &(set->elms[0]);
> set->sparse = &(set->elms[n_elms]);
> set->size = n_elms;
>
approved,
thanks
kenny