public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jan Hubicka <jh@suse.cz>
To: Mark Mitchell <mark@codesourcery.com>
Cc: Jason Merrill <jason_merrill@redhat.com>,
	Jan Hubicka <jh@suse.cz>,
	Richard Kenner <kenner@vlsi1.ultra.nyu.edu>,
	"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: spec2000 regression
Date: Thu, 16 Aug 2001 05:58:00 -0000	[thread overview]
Message-ID: <20010816145745.J14857@atrey.karlin.mff.cuni.cz> (raw)
In-Reply-To: <26940000.997887761@warlock.codesourcery.com>

> 
> 
> --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.

  reply	other threads:[~2001-08-16  5:58 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-15  5:57 Richard Kenner
2001-08-15  6:03 ` Jan Hubicka
2001-08-15  6:36   ` Jason Merrill
2001-08-15  6:52     ` Jan Hubicka
2001-08-15  7:11       ` Jason Merrill
2001-08-15  7:13         ` Jan Hubicka
2001-08-15  7:36         ` Jan Hubicka
2001-08-15  8:04         ` Mark Mitchell
2001-08-16  5:58           ` Jan Hubicka [this message]
2001-08-16  6:09             ` Jason Merrill
2001-08-16  7:40               ` Jan Hubicka
2001-08-16  7:46                 ` Jason Merrill
  -- strict thread matches above, loose matches on Subject: below --
2001-08-15 11:28 Richard Kenner
2001-08-16  6:09 ` Jason Merrill
2001-08-22  7:53   ` Jason Merrill
2001-08-15  7:08 Richard Kenner
2001-08-15  7:10 ` Jan Hubicka
     [not found] <20010815123730.P19872@atrey.karlin.mff.cuni.cz>
     [not found] ` <m366bpsi91.fsf@prospero.cambridge.redhat.com>
2001-08-15  5:41   ` Jan Hubicka
2001-08-15  6:18     ` Jason Merrill
2001-08-15  6:40     ` Joseph S. Myers
2001-08-15  7:36       ` Jan Hubicka
2001-08-15  7:44         ` Joseph S. Myers
2001-08-15 11:04           ` Andreas Jaeger
2001-08-15  7:56     ` Mark Mitchell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010816145745.J14857@atrey.karlin.mff.cuni.cz \
    --to=jh@suse.cz \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason_merrill@redhat.com \
    --cc=kenner@vlsi1.ultra.nyu.edu \
    --cc=mark@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).