public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][LTO] Fixup FIELD_DECLs in COMPONENT_REFs
@ 2009-10-14 16:18 Richard Guenther
  2009-10-14 17:02 ` Diego Novillo
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Guenther @ 2009-10-14 16:18 UTC (permalink / raw)
  To: gcc-patches; +Cc: Diego Novillo


The following replaces FIELD_DECLs with one from the canonical
type in COMPONENT_REFs.  FIELD_DECLs are the most prominent thing
that we can't get rid of after type-merging because they are
still referenced from the IL (curiously it's also one example
for why we can't collect garbage after type-merging before streaming
in all IL we ever want to stream in).

This allows me to finish lto1 for 483.xalancbmk on a machine with
3GB ram where it previously failed running out of memory.

Wasting memory with yet-another hashtable for doing the replacement
would increase peak memory usage even further so I decided to do
stupid list walks.  IL streaming after this patch is only taking
about 5% of the time we spend in fixing up decls and types before.

Bootstrapped and tested on x86_64-unknown-linux-gnu, a full SPEC 2006
is running.  Ok if that passes?

Thanks,
Richard.

2009-10-14  Richard Guenther  <rguenther@suse.de>

	* tree.c (free_lang_data_in_decl): Free DECL_FCONTEXT.
	* lto-streamer-in.c (input_gimple_stmt): Fixup FIELD_DECL
	operands in COMPONENT_REFs.

Index: gcc/tree.c
===================================================================
*** gcc/tree.c	(revision 152768)
--- gcc/tree.c	(working copy)
*************** free_lang_data_in_decl (tree decl)
*** 4402,4407 ****
--- 4402,4411 ----
  	  && DECL_FIELD_OFFSET (decl)
  	  && TREE_CODE (DECL_FIELD_OFFSET (decl)) != INTEGER_CST)
  	DECL_FIELD_OFFSET (decl) = NULL_TREE;
+ 
+       /* DECL_FCONTEXT is only used for debug info generation.  */
+       if (TREE_CODE (decl) == FIELD_DECL)
+ 	DECL_FCONTEXT (decl) = NULL_TREE;
      }
    else if (TREE_CODE (decl) == FUNCTION_DECL)
      {
Index: gcc/lto-streamer-in.c
===================================================================
*** gcc/lto-streamer-in.c	(revision 152768)
--- gcc/lto-streamer-in.c	(working copy)
*************** input_gimple_stmt (struct lto_input_bloc
*** 948,953 ****
--- 948,979 ----
  	{
  	  tree op = lto_input_tree (ib, data_in);
  	  gimple_set_op (stmt, i, op);
+ 
+ 	  /* Fixup FIELD_DECLs.  */
+ 	  while (op && handled_component_p (op))
+ 	    {
+ 	      if (TREE_CODE (op) == COMPONENT_REF)
+ 		{
+ 		  tree field, type, tem;
+ 		  field = TREE_OPERAND (op, 1);
+ 		  type = DECL_CONTEXT (field);
+ 		  for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
+ 		    {
+ 		      if (tem == field
+ 			  || ((DECL_FIELD_OFFSET (tem)
+ 			       == DECL_FIELD_OFFSET (field))
+ 			      && (DECL_FIELD_BIT_OFFSET (tem)
+ 				  == DECL_FIELD_BIT_OFFSET (field))
+ 			      && (DECL_OFFSET_ALIGN (tem)
+ 				  == DECL_OFFSET_ALIGN (field))))
+ 			break;
+ 		    }
+ 		  gcc_assert (tem != NULL_TREE);
+ 		  TREE_OPERAND (op, 1) = tem;
+ 		}
+ 
+ 	      op = TREE_OPERAND (op, 0);
+ 	    }
  	}
        break;
  

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH][LTO] Fixup FIELD_DECLs in COMPONENT_REFs
  2009-10-14 16:18 [PATCH][LTO] Fixup FIELD_DECLs in COMPONENT_REFs Richard Guenther
@ 2009-10-14 17:02 ` Diego Novillo
  2009-10-15  9:40   ` Richard Guenther
  0 siblings, 1 reply; 4+ messages in thread
From: Diego Novillo @ 2009-10-14 17:02 UTC (permalink / raw)
  To: Richard Guenther; +Cc: gcc-patches

On Wed, Oct 14, 2009 at 11:55, Richard Guenther <rguenther@suse.de> wrote:

> 2009-10-14  Richard Guenther  <rguenther@suse.de>
>
>        * tree.c (free_lang_data_in_decl): Free DECL_FCONTEXT.
>        * lto-streamer-in.c (input_gimple_stmt): Fixup FIELD_DECL
>        operands in COMPONENT_REFs.

OK.


Diego.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH][LTO] Fixup FIELD_DECLs in COMPONENT_REFs
  2009-10-14 17:02 ` Diego Novillo
@ 2009-10-15  9:40   ` Richard Guenther
  2009-10-17 11:39     ` Richard Guenther
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Guenther @ 2009-10-15  9:40 UTC (permalink / raw)
  To: Diego Novillo; +Cc: gcc-patches

[-- Attachment #1: Type: TEXT/PLAIN, Size: 541 bytes --]

On Wed, 14 Oct 2009, Diego Novillo wrote:

> On Wed, Oct 14, 2009 at 11:55, Richard Guenther <rguenther@suse.de> wrote:
> 
> > 2009-10-14  Richard Guenther  <rguenther@suse.de>
> >
> >        * tree.c (free_lang_data_in_decl): Free DECL_FCONTEXT.
> >        * lto-streamer-in.c (input_gimple_stmt): Fixup FIELD_DECL
> >        operands in COMPONENT_REFs.
> 
> OK.

Hm.  The patch causes two SPEC 2006 benchmarks to miscompare (which
I find odd).  I only checked in the tree.c part for now.

Richard.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH][LTO] Fixup FIELD_DECLs in COMPONENT_REFs
  2009-10-15  9:40   ` Richard Guenther
@ 2009-10-17 11:39     ` Richard Guenther
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Guenther @ 2009-10-17 11:39 UTC (permalink / raw)
  To: Diego Novillo; +Cc: gcc-patches

[-- Attachment #1: Type: TEXT/PLAIN, Size: 2205 bytes --]

On Thu, 15 Oct 2009, Richard Guenther wrote:

> On Wed, 14 Oct 2009, Diego Novillo wrote:
> 
> > On Wed, Oct 14, 2009 at 11:55, Richard Guenther <rguenther@suse.de> wrote:
> > 
> > > 2009-10-14  Richard Guenther  <rguenther@suse.de>
> > >
> > >        * tree.c (free_lang_data_in_decl): Free DECL_FCONTEXT.
> > >        * lto-streamer-in.c (input_gimple_stmt): Fixup FIELD_DECL
> > >        operands in COMPONENT_REFs.
> > 
> > OK.
> 
> Hm.  The patch causes two SPEC 2006 benchmarks to miscompare (which
> I find odd).  I only checked in the tree.c part for now.

I have checked in the rest now, it fixes two miscompares now.

Re-bootstrapped and tested on x86_64-unknown-linux-gnu.

Richard.

2009-10-14  Richard Guenther  <rguenther@suse.de>

	* lto-streamer-in.c (input_gimple_stmt): Fixup FIELD_DECL
	operands in COMPONENT_REFs.

Index: gcc/lto-streamer-in.c
===================================================================
*** gcc/lto-streamer-in.c	(revision 152775)
--- gcc/lto-streamer-in.c	(working copy)
*************** input_gimple_stmt (struct lto_input_bloc
*** 948,953 ****
--- 948,983 ----
  	{
  	  tree op = lto_input_tree (ib, data_in);
  	  gimple_set_op (stmt, i, op);
+ 
+ 	  /* Fixup FIELD_DECLs.  */
+ 	  while (op && handled_component_p (op))
+ 	    {
+ 	      if (TREE_CODE (op) == COMPONENT_REF)
+ 		{
+ 		  tree field, type, tem;
+ 		  field = TREE_OPERAND (op, 1);
+ 		  type = DECL_CONTEXT (field);
+ 		  for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
+ 		    {
+ 		      if (tem == field
+ 			  || (TREE_TYPE (tem) == TREE_TYPE (field)
+ 			      && (DECL_FIELD_OFFSET (tem)
+ 				  == DECL_FIELD_OFFSET (field))
+ 			      && (DECL_FIELD_BIT_OFFSET (tem)
+ 				  == DECL_FIELD_BIT_OFFSET (field))
+ 			      && (DECL_OFFSET_ALIGN (tem)
+ 				  == DECL_OFFSET_ALIGN (field))))
+ 			break;
+ 		    }
+ 		  /* In case of type mismatches across units we can fail
+ 		     to unify some types and thus not find a proper
+ 		     field-decl here.  Just do nothing in this case.  */
+ 		  if (tem != NULL_TREE)
+ 		    TREE_OPERAND (op, 1) = tem;
+ 		}
+ 
+ 	      op = TREE_OPERAND (op, 0);
+ 	    }
  	}
        break;
  

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-10-17 11:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-14 16:18 [PATCH][LTO] Fixup FIELD_DECLs in COMPONENT_REFs Richard Guenther
2009-10-14 17:02 ` Diego Novillo
2009-10-15  9:40   ` Richard Guenther
2009-10-17 11:39     ` Richard Guenther

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