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

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