public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Ignore TYPE_DECLs for canonical type compute in LTO
@ 2011-05-25 12:41 Richard Guenther
  0 siblings, 0 replies; only message in thread
From: Richard Guenther @ 2011-05-25 12:41 UTC (permalink / raw)
  To: gcc-patches


Just figured that we'd get TYPE_DECLs and FUNCTION_DECLs in aggregate
types.  But we should treat layout-compatible structs as same,
regardless of the above.

LTO profile-bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

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

	* gimple.c (iterative_hash_canonical_type): Skip non-FIELD_DECLs.
	(gimple_canonical_types_compatible_p): Likewise.

Index: gcc/gimple.c
===================================================================
--- gcc/gimple.c	(revision 174118)
+++ gcc/gimple.c	(working copy)
@@ -4376,10 +4382,11 @@ iterative_hash_canonical_type (tree type
       tree f;
 
       for (f = TYPE_FIELDS (type), nf = 0; f; f = TREE_CHAIN (f))
-	{
-	  v = iterative_hash_canonical_type (TREE_TYPE (f), v);
-	  nf++;
-	}
+	if (TREE_CODE (f) == FIELD_DECL)
+	  {
+	    v = iterative_hash_canonical_type (TREE_TYPE (f), v);
+	    nf++;
+	  }
 
       v = iterative_hash_hashval_t (nf, v);
     }
@@ -4688,6 +4695,13 @@ gimple_canonical_types_compatible_p (tre
 	     f1 && f2;
 	     f1 = TREE_CHAIN (f1), f2 = TREE_CHAIN (f2))
 	  {
+	    /* Skip non-fields.  */
+	    while (f1 && TREE_CODE (f1) != FIELD_DECL)
+	      f1 = TREE_CHAIN (f1);
+	    while (f2 && TREE_CODE (f2) != FIELD_DECL)
+	      f2 = TREE_CHAIN (f2);
+	    if (!f1 || !f2)
+	      break;
 	    /* The fields must have the same name, offset and type.  */
 	    if (DECL_NONADDRESSABLE_P (f1) != DECL_NONADDRESSABLE_P (f2)
 		|| !gimple_compare_field_offset (f1, f2)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-05-25 10:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-25 12:41 [PATCH] Ignore TYPE_DECLs for canonical type compute in LTO 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).