public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Guenther <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Cc: Diego Novillo <dnovillo@google.com>
Subject: [PATCH][LTO] Fixup FIELD_DECLs in COMPONENT_REFs
Date: Wed, 14 Oct 2009 16:18:00 -0000	[thread overview]
Message-ID: <alpine.LNX.2.00.0910141749120.4520@zhemvz.fhfr.qr> (raw)


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;
  

             reply	other threads:[~2009-10-14 15:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-14 16:18 Richard Guenther [this message]
2009-10-14 17:02 ` Diego Novillo
2009-10-15  9:40   ` Richard Guenther
2009-10-17 11:39     ` Richard Guenther

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=alpine.LNX.2.00.0910141749120.4520@zhemvz.fhfr.qr \
    --to=rguenther@suse.de \
    --cc=dnovillo@google.com \
    --cc=gcc-patches@gcc.gnu.org \
    /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).