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]

Re: spec2000 regression


> 
> 
> --On Wednesday, August 15, 2001 03:10:40 PM +0100 Jason Merrill 
> <jason_merrill@redhat.com> wrote:
> 
> > This should avoid such problems.
> >
> > 2001-08-15  Jason Merrill  <jason_merrill@redhat.com>
> >
> > 	* explow.c (set_mem_attributes): Avoid returning a bogus alias set
> > 	from a new MEM.
> 
> Hmm.  That changes the semantics somewhat, in the abstract; i.e.,
> it takes advantage of how get_alias_set handles decls by looking at
> their types.  If we did something smarter (putting things in subsets
> based on information about the scope they were in, say), then the
> two calls might start meaning different things.
> 
> So, I don't know whether the safety you're introducing is better, or
> not.
As suggested by Richard, it probably makes sense to do this trick only
as sanity checking, so following patch fixes all callers a first step.

I've regtested and bootstrapped following patch together with
modified set_mem_attributes patch to abort in incorrect cases.

Except for simple grep it has caught problem in function.c that does
replace REG by memory in place. The fix is rather ugly, but I can't
come with something better.

The patch above should be probably updated to abort in first case if
testing succeds.

OK to install?

Honza

Thu Aug 16 14:50:50 CEST 2001  Jan Hubicka  <jh@suse.cz>

	* function.c (put_var_into_stack): Temporarily clear DECL_RTL.
	(assign_params): Avoid setting DECL_RTL to unfinished RTX.
	(expand_function_start): Likewise.
	* stmt.c (expand_decl): Likewise.
	* varasm.c (make_decl_rtx): Likewise.

Index: function.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/function.c,v
retrieving revision 1.295
diff -c -3 -p -r1.295 function.c
*** function.c	2001/08/13 15:52:18	1.295
--- function.c	2001/08/16 12:50:02
*************** put_var_into_stack (decl)
*** 1420,1426 ****
--- 1420,1433 ----
  
        /* Change the CONCAT into a combined MEM for both parts.  */
        PUT_CODE (reg, MEM);
+ 
+       /* set_mem_attributes uses DECL_RTL to avoid re-generating of
+          already computed alias sets.  Here we want to re-generate.  */
+       if (TREE_CODE (decl) != SAVE_EXPR)
+ 	SET_DECL_RTL (decl, NULL);
        set_mem_attributes (reg, decl, 1);
+       if (TREE_CODE (decl) != SAVE_EXPR)
+ 	SET_DECL_RTL (decl, reg);
  
        /* The two parts are in memory order already.
  	 Use the lower parts address as ours.  */
*************** assign_parms (fndecl)
*** 4688,4697 ****
  	     appropriately.  */
  	  if (passed_pointer)
  	    {
! 	      SET_DECL_RTL (parm,
! 			    gen_rtx_MEM (TYPE_MODE (TREE_TYPE (passed_type)), 
! 					 parmreg));
! 	      set_mem_attributes (DECL_RTL (parm), parm, 1);
  	    }
  	  else
  	    {
--- 4695,4704 ----
  	     appropriately.  */
  	  if (passed_pointer)
  	    {
! 	      rtx x = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (passed_type)),
! 			     	   parmreg);
! 	      set_mem_attributes (x, parm, 1);
! 	      SET_DECL_RTL (parm, x);
  	    }
  	  else
  	    {
*************** assign_parms (fndecl)
*** 5030,5040 ****
        if (parm == function_result_decl)
  	{
  	  tree result = DECL_RESULT (fndecl);
! 
! 	  SET_DECL_RTL (result,
! 			gen_rtx_MEM (DECL_MODE (result), DECL_RTL (parm)));
  
! 	  set_mem_attributes (DECL_RTL (result), result, 1);
  	}
      }
  
--- 5037,5046 ----
        if (parm == function_result_decl)
  	{
  	  tree result = DECL_RESULT (fndecl);
! 	  rtx x = gen_rtx_MEM (DECL_MODE (result), DECL_RTL (parm));
  
! 	  set_mem_attributes (x, result, 1);
! 	  SET_DECL_RTL (result, x);
  	}
      }
  
*************** expand_function_start (subr, parms_have_
*** 6451,6461 ****
  	}
        if (value_address)
  	{
! 	  SET_DECL_RTL (DECL_RESULT (subr),
! 			gen_rtx_MEM (DECL_MODE (DECL_RESULT (subr)), 
! 				     value_address));
! 	  set_mem_attributes (DECL_RTL (DECL_RESULT (subr)),
! 			      DECL_RESULT (subr), 1);
  	}
      }
    else if (DECL_MODE (DECL_RESULT (subr)) == VOIDmode)
--- 6457,6465 ----
  	}
        if (value_address)
  	{
! 	  rtx x = gen_rtx_MEM (DECL_MODE (DECL_RESULT (subr)), value_address);
! 	  set_mem_attributes (x, DECL_RESULT (subr), 1);
! 	  SET_DECL_RTL (DECL_RESULT (subr), x);
  	}
      }
    else if (DECL_MODE (DECL_RESULT (subr)) == VOIDmode)
Index: stmt.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/stmt.c,v
retrieving revision 1.208
diff -c -3 -p -r1.208 stmt.c
*** stmt.c	2001/08/13 15:52:22	1.208
--- stmt.c	2001/08/16 12:50:07
*************** expand_decl (decl)
*** 3810,3824 ****
    else if (DECL_SIZE (decl) == 0)
      /* Variable with incomplete type.  */
      {
        if (DECL_INITIAL (decl) == 0)
  	/* Error message was already done; now avoid a crash.  */
! 	SET_DECL_RTL (decl, gen_rtx_MEM (BLKmode, const0_rtx));
        else
  	/* An initializer is going to decide the size of this array.
  	   Until we know the size, represent its address with a reg.  */
! 	SET_DECL_RTL (decl, gen_rtx_MEM (BLKmode, gen_reg_rtx (Pmode)));
  
!       set_mem_attributes (DECL_RTL (decl), decl, 1);
      }
    else if (DECL_MODE (decl) != BLKmode
  	   /* If -ffloat-store, don't put explicit float vars
--- 3810,3826 ----
    else if (DECL_SIZE (decl) == 0)
      /* Variable with incomplete type.  */
      {
+       rtx x;
        if (DECL_INITIAL (decl) == 0)
  	/* Error message was already done; now avoid a crash.  */
! 	x = gen_rtx_MEM (BLKmode, const0_rtx);
        else
  	/* An initializer is going to decide the size of this array.
  	   Until we know the size, represent its address with a reg.  */
! 	x = gen_rtx_MEM (BLKmode, gen_reg_rtx (Pmode));
  
!       set_mem_attributes (x, decl, 1);
!       SET_DECL_RTL (decl, x);
      }
    else if (DECL_MODE (decl) != BLKmode
  	   /* If -ffloat-store, don't put explicit float vars
*************** expand_decl (decl)
*** 3888,3894 ****
    else
      /* Dynamic-size object: must push space on the stack.  */
      {
!       rtx address, size;
  
        /* Record the stack pointer on entry to block, if have
  	 not already done so.  */
--- 3890,3896 ----
    else
      /* Dynamic-size object: must push space on the stack.  */
      {
!       rtx address, size, x;
  
        /* Record the stack pointer on entry to block, if have
  	 not already done so.  */
*************** expand_decl (decl)
*** 3913,3921 ****
  					      TYPE_ALIGN (TREE_TYPE (decl)));
  
        /* Reference the variable indirect through that rtx.  */
!       SET_DECL_RTL (decl, gen_rtx_MEM (DECL_MODE (decl), address));
  
-       set_mem_attributes (DECL_RTL (decl), decl, 1);
  
        /* Indicate the alignment we actually gave this variable.  */
  #ifdef STACK_BOUNDARY
--- 3915,3924 ----
  					      TYPE_ALIGN (TREE_TYPE (decl)));
  
        /* Reference the variable indirect through that rtx.  */
!       x = gen_rtx_MEM (DECL_MODE (decl), address);
!       set_mem_attributes (x, decl, 1);
!       SET_DECL_RTL (decl, x);
  
  
        /* Indicate the alignment we actually gave this variable.  */
  #ifdef STACK_BOUNDARY
Index: varasm.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/varasm.c,v
retrieving revision 1.193
diff -c -3 -p -r1.193 varasm.c
*** varasm.c	2001/08/13 15:14:52	1.193
--- varasm.c	2001/08/16 12:50:09
*************** make_decl_rtl (decl, asmspec)
*** 591,596 ****
--- 591,597 ----
    const char *name = 0;
    const char *new_name = 0;
    int reg_number;
+   rtx x;
  
    /* Check that we are not being given an automatic variable.  */
    /* A weak alias has TREE_PUBLIC set but not the other bits.  */
*************** make_decl_rtl (decl, asmspec)
*** 758,768 ****
  	   && (TREE_PUBLIC (decl) || TREE_STATIC (decl)))))
      TREE_SIDE_EFFECTS (decl) = 1;
  
!   SET_DECL_RTL (decl, gen_rtx_MEM (DECL_MODE (decl),
! 				   gen_rtx_SYMBOL_REF (Pmode, name)));
!   SYMBOL_REF_WEAK (XEXP (DECL_RTL (decl), 0)) = DECL_WEAK (decl);
    if (TREE_CODE (decl) != FUNCTION_DECL)
!     set_mem_attributes (DECL_RTL (decl), decl, 1);
  
    /* Optionally set flags or add text to the name to record information
       such as that it is a function name.
--- 759,769 ----
  	   && (TREE_PUBLIC (decl) || TREE_STATIC (decl)))))
      TREE_SIDE_EFFECTS (decl) = 1;
  
!   x = gen_rtx_MEM (DECL_MODE (decl), gen_rtx_SYMBOL_REF (Pmode, name));
!   SYMBOL_REF_WEAK (XEXP (x, 0)) = DECL_WEAK (decl);
    if (TREE_CODE (decl) != FUNCTION_DECL)
!     set_mem_attributes (x, decl, 1);
!   SET_DECL_RTL (decl, x);
  
    /* Optionally set flags or add text to the name to record information
       such as that it is a function name.


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