re PR lto/46525 (Failed to bootstrap-lto)
authorRichard Guenther <rguenther@suse.de>
Thu, 18 Nov 2010 13:10:40 +0000 (13:10 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 18 Nov 2010 13:10:40 +0000 (13:10 +0000)
2010-11-18  Richard Guenther  <rguenther@suse.de>

PR lto/46525
* gimple.c (gimple_register_type): Update TYPE_MAIN_VARIANT of
type leaders.
(gimple_register_canonical_type): Also cache the canoncial type
for non type leaders.

From-SVN: r166902

gcc/ChangeLog
gcc/gimple.c

index 216978069ac09dfd114a4968915d3c727f239226..3e589d2ac3cc6b9470ccbdc2c314166b090ba6a1 100644 (file)
@@ -1,3 +1,11 @@
+2010-11-18  Richard Guenther  <rguenther@suse.de>
+
+       PR lto/46525
+       * gimple.c (gimple_register_type): Update TYPE_MAIN_VARIANT of
+       type leaders.
+       (gimple_register_canonical_type): Also cache the canoncial type
+       for non type leaders.
+
 2010-11-18  Richard Guenther  <rguenther@suse.de>
 
        * lto-wrapper.c (run_gcc): Fix -flto=N parsing.
index 5f6b8d41c48570b8fafa3dc187f332b3ae80ede4..851e30ffbda07e4e0ee3c975c66830b98ee02bf7 100644 (file)
@@ -4283,6 +4283,7 @@ gimple_register_type (tree t)
 {
   void **slot;
   gimple_type_leader_entry *leader;
+  tree mv_leader = NULL_TREE;
 
   gcc_assert (TYPE_P (t));
 
@@ -4298,7 +4299,7 @@ gimple_register_type (tree t)
      pick up the non-typedef variants as canonical, otherwise we'll end
      up taking typedef ids for structure tags during comparison.  */
   if (TYPE_MAIN_VARIANT (t) != t)
-    gimple_register_type (TYPE_MAIN_VARIANT (t));
+    mv_leader = gimple_register_type (TYPE_MAIN_VARIANT (t));
 
   if (gimple_types == NULL)
     gimple_types = htab_create_ggc (16381, gimple_type_hash, gimple_type_eq, 0);
@@ -4365,6 +4366,22 @@ gimple_register_type (tree t)
     {
       leader->type = t;
       leader->leader = t;
+      /* We're the type leader.  Make our TYPE_MAIN_VARIANT valid.  */
+      if (TYPE_MAIN_VARIANT (t) != t
+         && TYPE_MAIN_VARIANT (t) != mv_leader)
+       {
+         /* Remove us from our main variant list as we are not the variant
+            leader and the variant leader will change.  */
+         tree tem = TYPE_MAIN_VARIANT (t);
+         while (tem && TYPE_NEXT_VARIANT (tem) != t)
+           tem = TYPE_NEXT_VARIANT (tem);
+         if (tem)
+           TYPE_NEXT_VARIANT (tem) = TYPE_NEXT_VARIANT (t);
+         TYPE_NEXT_VARIANT (t) = NULL_TREE;
+         /* Adjust our main variant.  Linking us into its variant list
+            will happen at fixup time.  */
+         TYPE_MAIN_VARIANT (t) = mv_leader;
+       }
       *slot = (void *) t;
     }
 
@@ -4392,6 +4409,7 @@ tree
 gimple_register_canonical_type (tree t)
 {
   void **slot;
+  tree orig_t = t;
 
   gcc_assert (TYPE_P (t));
 
@@ -4427,6 +4445,9 @@ gimple_register_canonical_type (tree t)
       *slot = (void *) t;
     }
 
+  /* Also cache the canonical type in the non-leaders.  */
+  TYPE_CANONICAL (orig_t) = t;
+
   return t;
 }