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
Subject: [PATCH][?/n] Cleanup LTO type merging
Date: Mon, 16 May 2011 15:46:00 -0000	[thread overview]
Message-ID: <alpine.LNX.2.00.1105161615480.810@zhemvz.fhfr.qr> (raw)


The following patch improves hashing types by re-instantiating the
patch that makes us visit aggregate target types of pointers and
function return and argument types.  This halves the collision
rate on the type hash table for a linux-kernel build and improves
WPA compile-time from 3mins to 1mins and reduces memory usage by
1GB for that testcase.

Bootstrapped and tested on x86_64-unknown-linux-gnu, SPEC2k6
build-tested.

Richard.

(patch is reversed)

2011-05-16  Richard Guenther  <rguenther@suse.de>

	* gimple.c (iterative_hash_gimple_type): Re-instantiate
	change to always visit pointer target and function result
	and argument types.

Index: gcc/gimple.c
===================================================================
--- gcc/gimple.c	(revision 173725)
+++ gcc/gimple.c	(working copy)
@@ -4110,10 +4110,20 @@ iterative_hash_gimple_type (tree type, h
     }
 
   /* For pointer and reference types, fold in information about the type
-     pointed to.  */
+     pointed to but do not recurse into possibly incomplete types to
+     avoid hash differences for complete vs. incomplete types.  */
   if (POINTER_TYPE_P (type))
-    v = visit (TREE_TYPE (type), state, v,
-	       sccstack, sccstate, sccstate_obstack);
+    {
+      if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (type)))
+	{
+	  v = iterative_hash_hashval_t (TREE_CODE (TREE_TYPE (type)), v);
+	  v = iterative_hash_name
+		(TYPE_NAME (TYPE_MAIN_VARIANT (TREE_TYPE (type))), v);
+	}
+      else
+	v = visit (TREE_TYPE (type), state, v,
+		   sccstack, sccstate, sccstate_obstack);
+    }
 
   /* For integer types hash the types min/max values and the string flag.  */
   if (TREE_CODE (type) == INTEGER_TYPE)
@@ -4154,13 +4164,29 @@ iterative_hash_gimple_type (tree type, h
 	v = visit (TYPE_METHOD_BASETYPE (type), state, v,
 		   sccstack, sccstate, sccstate_obstack);
 
-      /* Check result and argument types.  */
-      v = visit (TREE_TYPE (type), state, v,
-		 sccstack, sccstate, sccstate_obstack);
+      /* For result types allow mismatch in completeness.  */
+      if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (type)))
+	{
+	  v = iterative_hash_hashval_t (TREE_CODE (TREE_TYPE (type)), v);
+	  v = iterative_hash_name
+		(TYPE_NAME (TYPE_MAIN_VARIANT (TREE_TYPE (type))), v);
+	}
+      else
+	v = visit (TREE_TYPE (type), state, v,
+		   sccstack, sccstate, sccstate_obstack);
+
       for (p = TYPE_ARG_TYPES (type), na = 0; p; p = TREE_CHAIN (p))
 	{
-	  v = visit (TREE_VALUE (p), state, v,
-		     sccstack, sccstate, sccstate_obstack);
+	  /* For argument types allow mismatch in completeness.  */
+	  if (RECORD_OR_UNION_TYPE_P (TREE_VALUE (p)))
+	    {
+	      v = iterative_hash_hashval_t (TREE_CODE (TREE_VALUE (p)), v);
+	      v = iterative_hash_name
+		    (TYPE_NAME (TYPE_MAIN_VARIANT (TREE_VALUE (p))), v);
+	    }
+	  else
+	    v = visit (TREE_VALUE (p), state, v,
+		       sccstack, sccstate, sccstate_obstack);
 	  na++;
 	}
 

             reply	other threads:[~2011-05-16 14:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-16 15:46 Richard Guenther [this message]
2011-05-17  3:13 ` H.J. Lu
2011-05-17 13:03   ` Richard Guenther
2011-05-17 15:32     ` H.J. Lu
2011-05-17 15:33       ` H.J. Lu
2011-05-17 15:52         ` Richard Guenther
2011-05-17 16:04           ` H.J. Lu
  -- strict thread matches above, loose matches on Subject: below --
2011-05-19 14:39 Richard Guenther
2011-05-16 17:09 Richard Guenther
2011-05-16 20:51 ` Jan Hubicka
2011-05-16 22:39   ` H.J. Lu
2011-05-17 11:41   ` Richard Guenther
2011-05-17 13:54     ` Jan Hubicka
2011-05-16 15:36 Richard Guenther
2011-05-13 15:00 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.1105161615480.810@zhemvz.fhfr.qr \
    --to=rguenther@suse.de \
    --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).