Fix heisenbug in combine.c

Zack Weinberg zack@codesourcery.com
Wed Jun 30 04:58:00 GMT 2004


This patch introduced a latent heisenbug:

   2004-06-24  Eric Christopher  <echristo@redhat.com>

        * combine.c (distribute_notes): Don't delete sets to
        global register variables.

There was no range check on the access to the global_regs[] array.
Accordingly, whenever we hit this point with a pseudo, combine would
randomly decide not to delete a dead insn.  One of my IMA patches
provoked this into causing bootstrap comparison failures - frankly I'm
surprised no one noticed earlier.

Finding this was an incredible pain, but fixing it is easy.  Will
commit if i686-linux bootstrap succeeds.

zw

        * combine.c (distribute_notes): Don't look at global_regs for
        pseudos.

===================================================================
Index: combine.c
--- combine.c	28 Jun 2004 13:11:44 -0000	1.436
+++ combine.c	30 Jun 2004 01:34:01 -0000
@@ -11839,8 +11839,9 @@ distribute_notes (rtx notes, rtx from_in
 		     TEM is doing.  If so, delete TEM.  Otherwise, make this
 		     into a REG_UNUSED note instead. Don't delete sets to
 		     global register vars.  */
-		  if (reg_set_p (XEXP (note, 0), PATTERN (tem))
-		      && !global_regs [REGNO(XEXP (note, 0))])
+		  if ((REGNO (XEXP (note, 0)) >= FIRST_PSEUDO_REGISTER
+		       || !global_regs[REGNO (XEXP (note, 0))])
+		      && reg_set_p (XEXP (note, 0), PATTERN (tem)))
 		    {
 		      rtx set = single_set (tem);
 		      rtx inner_dest = 0;



More information about the Gcc-patches mailing list