valgrind fix: Set not_replacable in loop.c

Andreas Jaeger aj@suse.de
Mon Nov 18 22:13:00 GMT 2002


Bootstrapping GCC with valgrind shows these:

stage2/xgcc -Bstage2/ -B/opt/gcc/3.3-devel/i686-pc-linux-gnu/bin/ -c   -DVALGRIND_PATH=\"/opt/valgrind/bin/valgrind\" -g -O2 -DIN_GCC   -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes  -fno-common  -DHAVE_CONFIG_H    -I. -Ijava -I/cvs/gcc/gcc -I/cvs/gcc/gcc/java -I/cvs/gcc/gcc/config -I/cvs/gcc/gcc/../include /cvs/gcc/gcc/java/jvgenmain.c -o java/jvgenmain.o
==23127== Conditional jump or move depends on uninitialised value(s)
==23127==    at 0x83DFF28: loop_givs_check (/cvs/gcc/gcc/loop.c:4599)
==23127==    by 0x83E0D33: strength_reduce (/cvs/gcc/gcc/loop.c:5126)
==23127==    by 0x83CDB9B: scan_loop (/cvs/gcc/gcc/loop.c:1173)
==23127==    by 0x83CD4E3: loop_optimize (/cvs/gcc/gcc/loop.c:472)

The problem is that we do not set not_replacable in all cases.

I'm currently testing the appended patch.  Ok to commit if
bootstrapping succeeds on i686-linux-gnu?

Andreas

2002-11-19  Andreas Jaeger  <aj@suse.de>

	* loop.c (record_giv): Initialize not_replaceable.
	(check_final_value): Likewise.

============================================================
Index: gcc/loop.c
--- gcc/loop.c	4 Nov 2002 20:06:28 -0000	1.431
+++ gcc/loop.c	19 Nov 2002 05:54:40 -0000
@@ -5835,7 +5835,10 @@ record_giv (loop, v, insn, src_reg, dest
     abort ();
 
   if (type == DEST_ADDR)
-    v->replaceable = 1;
+    {
+      v->replaceable = 1;
+      v->not_replaceable = 0;
+    }
   else
     {
       /* The giv can be replaced outright by the reduced register only if all
@@ -5870,6 +5873,7 @@ record_giv (loop, v, insn, src_reg, dest
 	     using this biv anyways.  */
 
 	  v->replaceable = 1;
+	  v->not_replaceable = 0;
 	  for (b = bl->biv; b; b = b->next_iv)
 	    {
 	      if (INSN_UID (b->insn) >= max_uid_for_loop
@@ -5981,6 +5985,7 @@ check_final_value (loop, v)
       rtx last_giv_use;
 
       v->replaceable = 1;
+      v->not_replaceable = 0;
 
       /* When trying to determine whether or not a biv increment occurs
 	 during the lifetime of the giv, we can ignore uses of the variable

-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de
   private aj@arthur.inka.de
    http://www.suse.de/~aj



More information about the Gcc-patches mailing list