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]

[PATCH][LTO] Fixup FIELD_DECLs in COMPONENT_REFs


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;
  


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