[PATCH] Fix lots of uninitialized memory uses in sched_analyze_reg

Jakub Jelinek jakub@redhat.com
Mon Mar 4 21:18:00 GMT 2013


Something that again hits lots of testcases during valgrind checking
bootstrap.  init_alias_analysis apparently does
  vec_safe_grow_cleared (reg_known_value, maxreg - FIRST_PSEUDO_REGISTER);
  reg_known_equiv_p = sbitmap_alloc (maxreg - FIRST_PSEUDO_REGISTER);
but doesn't bitmap_clear (reg_known_equiv_p), perhaps as an optimization?
If set_reg_known_value is called (and not to the reg itself),
set_reg_known_equiv_p is called too though.
Right now get_reg_known_equiv_p is only called in one place, and we are only
interested in MEM_P known values there, so the following works fine.
Though perhaps if in the future we use the reg_known_equiv_p bitmap more,
we should bitmap_clear (reg_known_equiv_p) it instead.
Bootstrapped/regtested on x86_64-linux and i686-linux.

Ok for trunk (or do you prefer to slow down init_alias_analysis and just
clear the bitmap)?

2013-03-04  Jakub Jelinek  <jakub@redhat.com>

	* sched-deps.c (sched_analyze_reg): Only call get_reg_known_equiv_p
	if get_reg_known_value returned non-NULL.

--- gcc/sched-deps.c.jj	2013-03-04 12:21:09.000000000 +0100
+++ gcc/sched-deps.c	2013-03-04 17:29:03.478944157 +0100
@@ -2351,10 +2351,10 @@ sched_analyze_reg (struct deps_desc *dep
       /* Pseudos that are REG_EQUIV to something may be replaced
 	 by that during reloading.  We need only add dependencies for
 	the address in the REG_EQUIV note.  */
-      if (!reload_completed && get_reg_known_equiv_p (regno))
+      if (!reload_completed)
 	  rtx t = get_reg_known_value (regno);
-	  if (MEM_P (t))
+	  if (t && MEM_P (t) && get_reg_known_equiv_p (regno))
 	    sched_analyze_2 (deps, XEXP (t, 0), insn);


More information about the Gcc-patches mailing list