Commit a9c283a5 by Steven Bosscher

sparseset.c (sparseset_alloc): Use non-clearing allocation.

	* sparseset.c (sparseset_alloc): Use non-clearing allocation.  Tell
	valgrind not to worry about reading from unitialized memory.

From-SVN: r190503
parent e0de76d8
2012-08-18 Steven Bosscher <steven@gcc.gnu.org> 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 PR middle-end/54313
* dse.c (dse_step7): Don't free kill_on_calls bitmap, it is * dse.c (dse_step7): Don't free kill_on_calls bitmap, it is
freed when its obstack is release. freed when its obstack is release.
......
...@@ -30,12 +30,14 @@ sparseset_alloc (SPARSESET_ELT_TYPE n_elms) ...@@ -30,12 +30,14 @@ sparseset_alloc (SPARSESET_ELT_TYPE n_elms)
unsigned int n_bytes = sizeof (struct sparseset_def) unsigned int n_bytes = sizeof (struct sparseset_def)
+ ((n_elms - 1) * 2 * sizeof (SPARSESET_ELT_TYPE)); + ((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 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 been, in the set. These uninitialized reads are expected, by design and
harmless. If this turns into a performance problem due to some future harmless. */
additional users of sparseset, we can revisit this decision. */ VALGRIND_DISCARD (VALGRIND_MAKE_MEM_DEFINED (set, n_bytes));
sparseset set = (sparseset) xcalloc (1, n_bytes);
set->dense = &(set->elms[0]); set->dense = &(set->elms[0]);
set->sparse = &(set->elms[n_elms]); set->sparse = &(set->elms[n_elms]);
set->size = n_elms; set->size = n_elms;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment