This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Delay outputing ia64 external symbol reference


We should delay outputing ia64 external symbol referenc at the end
since the symbol name may change.


H.J.
----
2004-11-28  H.J. Lu  <hongjiu.lu@intel.com>

	PR middle-end/17982
	* config/ia64/hpux.h (TARGET_ASM_FILE_END): Removed.

	* config/ia64/ia64.c (ia64_hpux_add_extern_decl): Renamed to ...
	(ia64_add_extern_decl): This.
	(ia64_hpux_file_end): Renamed to ...
	(ia64_file_end): This. Handle non-function symbols.
	(TARGET_ASM_FILE_END): Defined.
	(ia64_asm_output_external): Don't ouput external symbols. Call
	ia64_add_extern_decl on external symbols.
	(extern_func_list): Renamed to ...
	(extern_symbol_list): This.
	(extern_func_head): Renamed to ...
	(extern_symbol_head): This.

--- gcc/config/ia64/hpux.h.global	2004-06-30 12:53:25.000000000 -0700
+++ gcc/config/ia64/hpux.h	2004-11-28 16:18:07.945853178 -0800
@@ -153,10 +153,6 @@ do {								\
    definitions, so do not use them in gthr-posix.h.  */
 #define GTHREAD_USE_WEAK 0
 
-/* Put out the needed function declarations at the end.  */
-
-#define TARGET_ASM_FILE_END ia64_hpux_file_end
-
 #undef CTORS_SECTION_ASM_OP
 #define CTORS_SECTION_ASM_OP  "\t.section\t.init_array,\t\"aw\",\"init_array\""
 
--- gcc/config/ia64/ia64.c.global	2004-11-25 13:16:18.000000000 -0800
+++ gcc/config/ia64/ia64.c	2004-11-28 16:35:10.331121362 -0800
@@ -279,6 +279,8 @@ static void bundling (FILE *, int, rtx, 
 static void ia64_output_mi_thunk (FILE *, tree, HOST_WIDE_INT,
 				  HOST_WIDE_INT, tree);
 static void ia64_file_start (void);
+static void ia64_add_extern_decl (tree decl);
+static void ia64_file_end (void);
 
 static void ia64_select_rtx_section (enum machine_mode, rtx,
 				     unsigned HOST_WIDE_INT);
@@ -292,10 +294,6 @@ static void ia64_rwreloc_select_rtx_sect
 static unsigned int ia64_rwreloc_section_type_flags (tree, const char *, int)
      ATTRIBUTE_UNUSED;
 
-static void ia64_hpux_add_extern_decl (tree decl)
-     ATTRIBUTE_UNUSED;
-static void ia64_hpux_file_end (void)
-     ATTRIBUTE_UNUSED;
 static void ia64_init_libfuncs (void)
      ATTRIBUTE_UNUSED;
 static void ia64_hpux_init_libfuncs (void)
@@ -404,6 +402,9 @@ static const struct attribute_spec ia64_
 #undef TARGET_ASM_FILE_START
 #define TARGET_ASM_FILE_START ia64_file_start
 
+#undef TARGET_ASM_FILE_END
+#define TARGET_ASM_FILE_END ia64_file_end
+
 #undef TARGET_RTX_COSTS
 #define TARGET_RTX_COSTS ia64_rtx_costs
 #undef TARGET_ADDRESS_COST
@@ -4092,10 +4093,9 @@ ia64_secondary_reload_class (enum reg_cl
    the Intel assembler does not support undefined externals.  */
 
 void
-ia64_asm_output_external (FILE *file, tree decl, const char *name)
+ia64_asm_output_external (FILE *file ATTRIBUTE_UNUSED, tree decl,
+			  const char *name)
 {
-  int save_referenced;
-
   /* GNU as does not need anything here, but the HP linker does need
      something for external functions.  */
 
@@ -4117,18 +4117,7 @@ ia64_asm_output_external (FILE *file, tr
       || ! strcmp (name, "__builtin_args_info"))
     return;
 
-  if (TARGET_HPUX_LD)
-    ia64_hpux_add_extern_decl (decl);
-  else
-    {
-      /* assemble_name will set TREE_SYMBOL_REFERENCED, so we must save and
-         restore it.  */
-      save_referenced = TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl));
-      if (TREE_CODE (decl) == FUNCTION_DECL)
-        ASM_OUTPUT_TYPE_DIRECTIVE (file, name, "function");
-      (*targetm.asm_out.globalize_label) (file, name);
-      TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)) = save_referenced;
-    }
+  ia64_add_extern_decl (decl);
 }
 
 /* Parse the -mfixed-range= option string.  */
@@ -9964,32 +9953,32 @@ ia64_hpux_function_arg_padding (enum mac
    We output the name if and only if TREE_SYMBOL_REFERENCED is set in
    order to avoid putting out names that are never really used.  */
 
-struct extern_func_list GTY(())
+struct extern_symbol_list GTY(())
 {
-  struct extern_func_list *next;
+  struct extern_symbol_list *next;
   tree decl;
 };
 
-static GTY(()) struct extern_func_list *extern_func_head;
+static GTY(()) struct extern_symbol_list *extern_symbol_head;
 
 static void
-ia64_hpux_add_extern_decl (tree decl)
+ia64_add_extern_decl (tree decl)
 {
-  struct extern_func_list *p = ggc_alloc (sizeof (struct extern_func_list));
+  struct extern_symbol_list *p = ggc_alloc (sizeof (struct extern_symbol_list));
 
   p->decl = decl;
-  p->next = extern_func_head;
-  extern_func_head = p;
+  p->next = extern_symbol_head;
+  extern_symbol_head = p;
 }
 
 /* Print out the list of used global functions.  */
 
 static void
-ia64_hpux_file_end (void)
+ia64_file_end (void)
 {
-  struct extern_func_list *p;
+  struct extern_symbol_list *p;
 
-  for (p = extern_func_head; p; p = p->next)
+  for (p = extern_symbol_head; p; p = p->next)
     {
       tree decl = p->decl;
       tree id = DECL_ASSEMBLER_NAME (decl);
@@ -10002,14 +9991,13 @@ ia64_hpux_file_end (void)
 	  const char *name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
 
 	  TREE_ASM_WRITTEN (decl) = 1;
+	  if (TREE_CODE (decl) == FUNCTION_DECL)
+	    ASM_OUTPUT_TYPE_DIRECTIVE (asm_out_file, name, "function");
 	  (*targetm.asm_out.globalize_label) (asm_out_file, name);
-	  fputs (TYPE_ASM_OP, asm_out_file);
-	  assemble_name (asm_out_file, name);
-	  fprintf (asm_out_file, "," TYPE_OPERAND_FMT "\n", "function");
         }
     }
 
-  extern_func_head = 0;
+  extern_symbol_head = 0;
 }
 
 /* Set SImode div/mod functions, init_integral_libfuncs only initializes


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]