Ontop of the previous LTO type merging cleanup the following patch
should fix PR48849 by making sure that TYPE_CANONICAL computation
of pointer types at LTO streaming time matches that of the middle-end
(and thus later passes that create new pointer types).

LTO bootstrapped and tested on x86_64-unknown-linux-gnu, SPEC 2k6
build tested (and the two cases I ran into in the past are fixed)
and kernel WPA tested.

Richard.

2011-05-20  Richard Guenther  <rguent...@suse.de>

        PR middle-end/48849
        * gimple.c (gimple_register_canonical_type): Compute TYPE_CANONICAL
        of pointer types the same way the middle-end does.

Index: gcc/gimple.c
===================================================================
--- gcc/gimple.c        (revision 173905)
+++ gcc/gimple.c        (working copy)
@@ -4896,6 +4850,25 @@ gimple_register_canonical_type (tree t)
   if (TYPE_CANONICAL (t))
     return TYPE_CANONICAL (t);
 
+  /* For pointer and reference types do as the middle-end does - the
+     canonical type is a pointer to the canonical pointed-to type.  */
+  if (TREE_CODE (t) == POINTER_TYPE)
+    {
+      TYPE_CANONICAL (t)
+         = build_pointer_type_for_mode
+         (gimple_register_canonical_type (TREE_TYPE (t)),
+          TYPE_MODE (t), TYPE_REF_CAN_ALIAS_ALL (t));
+      return TYPE_CANONICAL (t);
+    }
+  else if (TREE_CODE (t) == REFERENCE_TYPE)
+    {
+      TYPE_CANONICAL (t)
+         = build_reference_type_for_mode
+         (gimple_register_canonical_type (TREE_TYPE (t)),
+          TYPE_MODE (t), TYPE_REF_CAN_ALIAS_ALL (t));
+      return TYPE_CANONICAL (t);
+    }
+
   if (gimple_canonical_types == NULL)
     gimple_canonical_types = htab_create_ggc (16381, 
gimple_canonical_type_hash,
                                              gimple_canonical_type_eq, 0);

Reply via email to