Hi,
I added a santy check that after fixup all types that lost in the merging are
really dead.  And it turns out we have some zombies around.

INTEGER_CST needs special care because it is special cased by the streamer.  We 
also
do not want to do inplace modificaitons on it because that would corrupt the 
hashtable
used by tree.c's sharing code

Bootstrapped/regtested x86_64-linux, OK?


        PR lto/54839
        * lto/lto.c (remember_with_vars): Also fixup INTEGER_CST.
        (fixup_integer_cst): New functoin.
        (lto_ft_type): Fixup BASETYPE of methods and offsets.
Index: lto/lto.c
===================================================================
--- lto/lto.c   (revision 192164)
+++ lto/lto.c   (working copy)
@@ -1408,11 +1408,36 @@ remember_with_vars (tree t)
            (tt) = GIMPLE_REGISTER_TYPE (tt); \
          if (VAR_OR_FUNCTION_DECL_P (tt) && TREE_PUBLIC (tt)) \
            remember_with_vars (t); \
+         if (TREE_CODE (tt) == INTEGER_CST) \
+           (tt) = fixup_integer_cst (tt); \
        } \
     } while (0)
 
 static void lto_fixup_types (tree);
 
+/* Return integer_cst T with updated type.  */
+
+static tree
+fixup_integer_cst (tree t)
+{
+  tree type = GIMPLE_REGISTER_TYPE (TREE_TYPE (t));
+
+  if (type == TREE_TYPE (t))
+    return t;
+
+  /* If overflow was set, streamer_read_integer_cst
+     produced local copy of T. */
+  if (TREE_OVERFLOW (t))
+    {
+      TREE_TYPE (t) = type;
+      return t;
+    }
+  else
+  /* Otherwise produce new shared node for the new type.  */
+    return build_int_cst_wide (type, TREE_INT_CST_LOW (t),
+                              TREE_INT_CST_HIGH (t));
+}
+
 /* Fix up fields of a tree_typed T.  */
 
 static void
@@ -1526,6 +1549,11 @@ lto_ft_type (tree t)
   LTO_FIXUP_TREE (t->type_non_common.binfo);
 
   LTO_FIXUP_TREE (TYPE_CONTEXT (t));
+
+  if (TREE_CODE (t) == METHOD_TYPE)
+    TYPE_METHOD_BASETYPE (t);
+  if (TREE_CODE (t) == OFFSET_TYPE)
+    TYPE_OFFSET_BASETYPE (t);
 }
 
 /* Fix up fields of a BINFO T.  */

Reply via email to