This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PR rtl-optimization/15248 -- semi-latent reload bug


Jeffrey A Law wrote:
No further concerns from me.  Once it's in the mainline for a little
while we should seriously consider backporting it to 4.0 and maybe
even the 3.x series.

Ok, retested (i686-linux, no Ada) and committed. Mark, your call if you want to have this in 4.0 - this fixes a problem where we could produce stores to a memory location even though the source program only reads from it, leading to crashes if that memory location happens to be readonly.



Bernd
	* reload1.c (reload): Undo 2005-04-20 change.  Make sure we detect
	the correct set of init_insns that need deletion.

Index: reload1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/reload1.c,v
retrieving revision 1.472
diff -c -p -r1.472 reload1.c
*** reload1.c	1 Jun 2005 11:38:50 -0000	1.472
--- reload1.c	2 Jun 2005 08:35:54 -0000
*************** reload (rtx first, int global)
*** 752,758 ****
  		     for equivalences.  This is overly conservative as
  		     we could find all sets of the destination pseudo
  		     and remove them as they should be redundant.  */
! 		  if (memory_operand (x, VOIDmode) && ! MEM_READONLY_P (x))
  		    {
  		      /* Always unshare the equivalence, so we can
  			 substitute into this insn without touching the
--- 752,758 ----
  		     for equivalences.  This is overly conservative as
  		     we could find all sets of the destination pseudo
  		     and remove them as they should be redundant.  */
! 		  if (memory_operand (x, VOIDmode))
  		    {
  		      /* Always unshare the equivalence, so we can
  			 substitute into this insn without touching the
*************** reload (rtx first, int global)
*** 787,800 ****
  		  else
  		    continue;
  
! 		  /* If this register is being made equivalent to a MEM
! 		     and the MEM is not SET_SRC, the equivalencing insn
! 		     is one with the MEM as a SET_DEST and it occurs later.
! 		     So don't mark this insn now.  */
! 		  if (!MEM_P (x)
! 		      || rtx_equal_p (SET_SRC (set), x))
! 		    reg_equiv_init[i]
! 		      = gen_rtx_INSN_LIST (VOIDmode, insn, reg_equiv_init[i]);
  		}
  	    }
  	}
--- 787,794 ----
  		  else
  		    continue;
  
! 		  reg_equiv_init[i]
! 		    = gen_rtx_INSN_LIST (VOIDmode, insn, reg_equiv_init[i]);
  		}
  	    }
  	}
*************** reload (rtx first, int global)
*** 806,814 ****
  	       && reg_equiv_memory_loc[REGNO (SET_SRC (set))]
  	       && rtx_equal_p (SET_DEST (set),
  			       reg_equiv_memory_loc[REGNO (SET_SRC (set))]))
  	reg_equiv_init[REGNO (SET_SRC (set))]
! 	  = gen_rtx_INSN_LIST (VOIDmode, insn,
! 			       reg_equiv_init[REGNO (SET_SRC (set))]);
  
        if (INSN_P (insn))
  	scan_paradoxical_subregs (PATTERN (insn));
--- 800,811 ----
  	       && reg_equiv_memory_loc[REGNO (SET_SRC (set))]
  	       && rtx_equal_p (SET_DEST (set),
  			       reg_equiv_memory_loc[REGNO (SET_SRC (set))]))
+ 	/* Equivalences made this way only have one initializing insn.
+ 	   Previously, we may have set reg_equiv_init when encountering a
+ 	   SET of this pseudo; discard that insn since it does not set up
+ 	   an equivalence.  */
  	reg_equiv_init[REGNO (SET_SRC (set))]
! 	  = gen_rtx_INSN_LIST (VOIDmode, insn, NULL_RTX);
  
        if (INSN_P (insn))
  	scan_paradoxical_subregs (PATTERN (insn));

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]