aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJanis Johnson <janis187@us.ibm.com>2008-01-17 03:21:36 +0000
committerPeter Bergner <bergner@gcc.gnu.org>2008-01-16 21:21:36 -0600
commit37b87a3a8a76b5a00a8cd24f62b03ef3ba2c274a (patch)
tree966e88afff3c3966960437c877988df8a77b722d /gcc
parent6595ec51c4a4aee6a369bebe575e08cb41068e66 (diff)
downloadgcc-37b87a3a8a76b5a00a8cd24f62b03ef3ba2c274a.zip
gcc-37b87a3a8a76b5a00a8cd24f62b03ef3ba2c274a.tar.gz
gcc-37b87a3a8a76b5a00a8cd24f62b03ef3ba2c274a.tar.bz2
re PR rtl-optimization/33796 (valgrind error with -O2 for linux kernel code)
PR rtl-optimization/33796 * sparseset.c (sparseset_alloc): Use xcalloc rather than xmalloc. Co-Authored-By: Peter Bergner <bergner@vnet.ibm.com> From-SVN: r131589
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/sparseset.c7
2 files changed, 12 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e22f508..e1e6f10 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2007-01-16 Janis Johnson <janis187@us.ibm.com>
+ Peter Bergner <bergner@vnet.ibm.com>
+
+ PR rtl-optimization/33796
+ * sparseset.c (sparseset_alloc): Use xcalloc rather than xmalloc.
+
2008-01-16 John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
PR libgfortran/34699
diff --git a/gcc/sparseset.c b/gcc/sparseset.c
index f556c4d..c8a9a30 100644
--- a/gcc/sparseset.c
+++ b/gcc/sparseset.c
@@ -30,7 +30,12 @@ sparseset_alloc (SPARSESET_ELT_TYPE n_elms)
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;