[lto] Re-implement pass_ipa_free_lang_specifics [3/3]

Diego Novillo dnovillo@google.com
Tue Jan 20 16:31:00 GMT 2009


The final patch simply changes the types_compatible_p langhook to
use GIMPLE's version.  This makes LTO and non-LTO builds use the
same definition during optimization.


Diego.

	* tree.c (free_lang_data): Set lang_hooks.types_compatible_p
	to gimple_types_compatible_p.
	* gimple.c (gimple_types_compatible_p): Moved from
	lto/lto-lang.c.  Renamed from lto_types_compatible_p.
	* gimple.h (gimple_types_compatible_p): Declare.

lto/ChangeLog:

	* lto-lang.c (lto_types_compatible_p): Move to gimple.c
	and rename into gimple_types_compatible_p.

Index: tree.c
===================================================================
--- tree.c	(revision 143495)
+++ tree.c	(working copy)
@@ -4170,10 +4359,11 @@ free_lang_specifics (void)
      a variant copy of ptr_type_node for front-end purposes.  */
   fileptr_type_node = ptr_type_node;
 
-  /* Reset some langhooks. */
+  /* Reset some langhooks.  */
   lang_hooks.callgraph.analyze_expr = NULL;
+  lang_hooks.types_compatible_p = gimple_types_compatible_p;
 
-  /* FIXME lto: We have to compute these names early. */
+  /* FIXME lto: We have to compute these names early.  */
   lang_hooks.dwarf_name = lhd_dwarf_name;
   lang_hooks.decl_printable_name = lhd_decl_printable_name;
 
Index: lto/lto-lang.c
===================================================================
--- lto/lto-lang.c	(revision 143495)
+++ lto/lto-lang.c	(working copy)
@@ -906,30 +906,6 @@ lto_builtin_function (tree decl)
   return decl;
 }
 
-static int
-lto_types_compatible_p (tree type1, tree type2)
-{
-  if (TREE_CODE (type1) == RECORD_TYPE
-      && TREE_CODE (type2) == RECORD_TYPE)
-    {
-      /* Check structural equality.  */
-      tree f1, f2;
-
-      for (f1 = TYPE_FIELDS (type1), f2 = TYPE_FIELDS (type2);
-	   f1 && f2;
-	   f1 = TREE_CHAIN (f1), f2 = TREE_CHAIN (f2))
-	{
-	  if (TREE_CODE (f1) != TREE_CODE (f2)
-	      || DECL_NAME (f1) != DECL_NAME (f2))
-	    break;
-	}
-
-      return f1 && f2 ? 0 : 1;
-    }
-
-  return TYPE_MAIN_VARIANT (type1) == TYPE_MAIN_VARIANT (type2);
-}
-
 static void
 lto_register_builtin_type (tree type, const char *name)
 {
@@ -1074,7 +1050,7 @@ static void lto_init_ts (void)
 #undef LANG_HOOKS_REDUCE_BIT_FIELD_OPERATIONS
 #define LANG_HOOKS_REDUCE_BIT_FIELD_OPERATIONS true
 #undef LANG_HOOKS_TYPES_COMPATIBLE_P
-#define LANG_HOOKS_TYPES_COMPATIBLE_P lto_types_compatible_p
+#define LANG_HOOKS_TYPES_COMPATIBLE_P gimple_types_compatible_p
 
 /* Attribute hooks.  */
 #undef LANG_HOOKS_COMMON_ATTRIBUTE_TABLE
Index: gimple.c
===================================================================
--- gimple.c	(revision 143495)
+++ gimple.c	(working copy)
@@ -3192,4 +3192,31 @@ gimple_call_copy_skip_args (gimple stmt,
   return new_stmt;
 }
 
+
+/* Return 1 if TYPE1 and TYPE2 are structurally compatible and/or they
+   have the same main variant.  */
+
+int
+gimple_types_compatible_p (tree type1, tree type2)
+{
+  if (TREE_CODE (type1) == RECORD_TYPE
+      && TREE_CODE (type2) == RECORD_TYPE)
+    {
+      /* Check structural equality.  */
+      tree f1, f2;
+
+      for (f1 = TYPE_FIELDS (type1), f2 = TYPE_FIELDS (type2);
+	   f1 && f2;
+	   f1 = TREE_CHAIN (f1), f2 = TREE_CHAIN (f2))
+	{
+	  if (TREE_CODE (f1) != TREE_CODE (f2)
+	      || DECL_NAME (f1) != DECL_NAME (f2))
+	    break;
+	}
+
+      return f1 && f2 ? 0 : 1;
+    }
+
+  return TYPE_MAIN_VARIANT (type1) == TYPE_MAIN_VARIANT (type2);
+}
 #include "gt-gimple.h"
Index: gimple.h
===================================================================
--- gimple.h	(revision 143495)
+++ gimple.h	(working copy)
@@ -913,6 +913,7 @@ extern bool is_gimple_call_addr (tree);
 extern tree get_call_expr_in (tree t);
 
 extern void recalculate_side_effects (tree);
+extern int gimple_types_compatible_p (tree, tree);
 
 /* In gimplify.c  */
 extern tree create_tmp_var_raw (tree, const char *);



More information about the Gcc-patches mailing list