]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
sparseset.c (sparseset_alloc): Use non-clearing allocation.
authorSteven Bosscher <steven@gcc.gnu.org>
Sat, 18 Aug 2012 13:44:00 +0000 (13:44 +0000)
committerSteven Bosscher <steven@gcc.gnu.org>
Sat, 18 Aug 2012 13:44:00 +0000 (13:44 +0000)
* sparseset.c (sparseset_alloc): Use non-clearing allocation.  Tell
valgrind not to worry about reading from unitialized memory.

From-SVN: r190503

gcc/ChangeLog
gcc/sparseset.c

index 9dd5e9c54f3a3eda18a527488646055b44777ac0..2282536c1ab64d3f9890826ccb01371f060fcea7 100644 (file)
@@ -1,3 +1,8 @@
+2012-08-18  Steven Bosscher  <steven@gcc.gnu.org>
+
+       * sparseset.c (sparseset_alloc): Use non-clearing allocation.  Tell
+       valgrind not to worry about reading from unitialized memory.
+
 2012-08-18  Steven Bosscher  <steven@gcc.gnu.org>
 
        PR middle-end/54313
index 823919a886e49fd62f48bdd362dd6b1554a13a3f..35a2c3e1a3495a7e38641f6ede8aa8d0679858b8 100644 (file)
@@ -30,12 +30,14 @@ sparseset_alloc (SPARSESET_ELT_TYPE n_elms)
   unsigned int n_bytes = sizeof (struct sparseset_def)
                         + ((n_elms - 1) * 2 * sizeof (SPARSESET_ELT_TYPE));
 
-  /* We use xcalloc rather than xmalloc to silence some valgrind uninitialized
+  sparseset set = XNEWVAR(struct sparseset_def, n_bytes);
+
+  /* Mark the sparseset as defined 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);
+     harmless.  */
+  VALGRIND_DISCARD (VALGRIND_MAKE_MEM_DEFINED (set, n_bytes));
+
   set->dense = &(set->elms[0]);
   set->sparse = &(set->elms[n_elms]);
   set->size = n_elms;