[LTO] [PATCH] Avoid middle/back-end use of set_decl_assembler_name and tree_size lang hooks

Robert Kennedy jimbob@google.com
Mon Mar 26 23:04:00 GMT 2007


> If you're referring to the code in init_one_libfunc, I think the fix is
> simple, like so:
> 
>   tree decl_name = get_identifier (name);
>   tree decl = build_decl (FUNCTION_DECL, decl_name, ...);
>   SET_DECL_ASSEMBLER_NAME (decl, decl_name);
>   ...
> 
> As you say, that must be right, since that's equivalent to what the C
> front end does.

D'oh! Thanks for the gorgeous simplification that I should have seen
for myself.

Here is a trimmed-down patch that doesn't contain the MBE_* ugliness.

OK for the LTO branch?

	-- Robert

----------------------------------------
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 120246)
+++ ChangeLog	(working copy)
@@ -1,3 +1,12 @@
+2007-03-14 Robert Kennedy  <jimbob@google.com>
+
+	Eliminate use of lang_hooks.set_decl_assembler_name from LTO
+	* optabs.c (init_one_libfunc) Don't rely on DECL_RTL to
+	SET_DECL_ASSEMBLER_NAME.
+	* lto/lto.c (lto_read_subroutine_type_subprogram_DIE) Get DECL
+	assembler name from DWARF.
+	* lto/lto-lang.c (lto_set_decl_assembler_name) New function.
+	
 2006-05-22  Gerald Pfeifer  <gerald@pfeifer.com>
 
 	* doc/install.texi (Configuration): Remove reference to CrossGCC
Index: optabs.c
===================================================================
--- optabs.c	(revision 120246)
+++ optabs.c	(working copy)
@@ -5122,13 +5122,17 @@
      targetm.encode_section_info.  */
   /* ??? We don't have any type information except for this is
      a function.  Pretend this is "int foo()".  */
-  tree decl = build_decl (FUNCTION_DECL, get_identifier (name),
+
+  tree decl_name = get_identifier (name);
+  tree decl = build_decl (FUNCTION_DECL, decl_name,
 			  build_function_type (integer_type_node, NULL_TREE));
+  SET_DECL_ASSEMBLER_NAME (decl, decl_name);
   DECL_ARTIFICIAL (decl) = 1;
   DECL_EXTERNAL (decl) = 1;
   TREE_PUBLIC (decl) = 1;
 
   symbol = XEXP (DECL_RTL (decl), 0);
+  gcc_assert (DECL_ASSEMBLER_NAME (decl));
 
   /* Zap the nonsensical SYMBOL_REF_DECL for this.  What we're left with
      are the flags assigned by targetm.encode_section_info.  */
Index: lto/lto.c
===================================================================
--- lto/lto.c	(revision 120246)
+++ lto/lto.c	(working copy)
@@ -2236,6 +2236,7 @@
   tree arg_types;
   tree type;
   tree name;
+  tree asm_name = NULL_TREE;
   bool external;
   VEC(tree,heap) *parms;
   unsigned n_parms;
@@ -2308,7 +2309,12 @@
 	case DW_AT_inline:
 	  inlined = attribute_value_as_int (&attr_data);
 	  break;
-	  
+
+        case DW_AT_MIPS_linkage_name:
+          /* Set the DECL_ASSEMBLER_NAME so we don't have to remangle
+             names in LTO.  */
+          asm_name = lto_get_identifier (&attr_data);
+          break;
 	}
       LTO_END_READ_ATTRS ();
     }
@@ -2386,6 +2392,10 @@
 	  || inlined == DW_INL_declared_not_inlined)
 	DECL_DECLARED_INLINE_P (result) = 1;
 
+      /* Set the DECL_ASSEMBLER_NAME for the function from the
+         information in the DIE.  */
+      SET_DECL_ASSEMBLER_NAME (result, asm_name ? asm_name : name);
+
       /* If the function has already been declared, merge the
 	 declarations.  */
       result = lto_symtab_merge_fn (result);
Index: lto/lto-lang.c
===================================================================
--- lto/lto-lang.c	(revision 120246)
+++ lto/lto-lang.c	(working copy)
@@ -105,6 +105,12 @@
   gcc_unreachable ();
 }
 
+static void
+lto_set_decl_assembler_name (tree decl ATTRIBUTE_UNUSED)
+{
+  gcc_unreachable ();
+}
+
 static tree
 lto_pushdecl (tree t ATTRIBUTE_UNUSED)
 {
@@ -172,6 +178,8 @@
 #define LANG_HOOKS_UNSIGNED_TYPE lto_unsigned_type
 #define LANG_HOOKS_SIGNED_TYPE lto_signed_type
 #define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE lto_signed_or_unsigned_type
+#undef LANG_HOOKS_SET_DECL_ASSEMBLER_NAME
+#define LANG_HOOKS_SET_DECL_ASSEMBLER_NAME lto_set_decl_assembler_name
 #undef LANG_HOOKS_GLOBAL_BINDINGS_P
 #define LANG_HOOKS_GLOBAL_BINDINGS_P lto_global_bindings_p
 #undef LANG_HOOKS_INSERT_BLOCK



More information about the Gcc-patches mailing list