cgraph.c (cgraph_mark_needed_node): Call notice_global_symbol.
authorJan Hubicka <jh@suse.cz>
Tue, 19 Aug 2003 07:37:07 +0000 (09:37 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Tue, 19 Aug 2003 07:37:07 +0000 (07:37 +0000)
* cgraph.c (cgraph_mark_needed_node): Call notice_global_symbol.
(cgraph_varpool_mark_needed_node): Likewise.
* cgraph.h (notice_global_symbol): Declare
* varasm.c (notice_global_symbol): Break out from ...
(assemble_start_function): ... here; update for variables.
(assemble_variable): Use notice_global_symbol.

From-SVN: r70559

gcc/ChangeLog
gcc/cgraph.c
gcc/tree.h
gcc/varasm.c

index 4e82dbad3a4b62fb555841b441c592cd0cb7b3e9..0d685771e532269323a0dcd2dd40a29097a1dcbd 100644 (file)
@@ -1,3 +1,12 @@
+2003-08-19  Jan Hubicka  <jh@suse.cz>
+
+       * cgraph.c (cgraph_mark_needed_node): Call notice_global_symbol.
+       (cgraph_varpool_mark_needed_node): Likewise.
+       * cgraph.h (notice_global_symbol): Declare
+       * varasm.c (notice_global_symbol): Break out from ...
+       (assemble_start_function): ... here; update for variables.
+       (assemble_variable): Use notice_global_symbol.
+
 2003-08-19  Richard Sandiford  <rsandifo@redhat.com>
 
        * config/mips/mips.c (mips_va_arg): If EABI_FLOAT_VARARGS_P,
index 9aa12a6102df81691ed2575e48dec287175a2495..bd83f6a194636dba39b3bd84cb5853df75d22672 100644 (file)
@@ -248,6 +248,7 @@ cgraph_mark_needed_node (struct cgraph_node *node, int needed)
 
       node->next_needed = cgraph_nodes_queue;
       cgraph_nodes_queue = node;
+      notice_global_symbol (node->decl);
 
       /* At the moment frontend automatically emits all nested functions.  */
       if (node->nested)
@@ -465,6 +466,7 @@ cgraph_varpool_mark_needed_node (struct cgraph_varpool_node *node)
     {
       node->next_needed = cgraph_varpool_nodes_queue;
       cgraph_varpool_nodes_queue = node;
+      notice_global_symbol (node->decl);
     }
   node->needed = 1;
 }
index 69e75e1af36d2cd59bc1ab5823403ad30eb4d363..dbf8c8f86f29fb2ef6afe192017ddffc0ff070b9 100644 (file)
@@ -2944,6 +2944,7 @@ enum tls_model decl_tls_model (tree);
 enum symbol_visibility decl_visibility (tree);
 extern void resolve_unique_section (tree, int, int);
 extern void mark_referenced (tree);
+extern void notice_global_symbol (tree);
 
 /* In stmt.c */
 extern void emit_nop (void);
index 512bc33ba89ec8f610128d73fe56854436933143..ac535212056b69415ade6aace4efbfc264b1eb86 100644 (file)
@@ -1040,6 +1040,34 @@ default_ctor_section_asm_out_constructor (rtx symbol,
 #define CONSTANT_POOL_BEFORE_FUNCTION 1
 #endif
 
+/* DECL is an object (either VAR_DECL or FUNCTION_DECL) which is going
+   to be output to assembler.
+   Set first_global_object_name and weak_global_object_name as appropriate.  */
+
+void
+notice_global_symbol (tree decl)
+{
+  if ((!first_global_object_name || !weak_global_object_name)
+      && TREE_PUBLIC (decl)
+      && (TREE_CODE (decl) == FUNCTION_DECL
+         || ! (DECL_COMMON (decl)
+               && (DECL_INITIAL (decl) == 0
+                   || DECL_INITIAL (decl) == error_mark_node))))
+    {
+      const char *p;
+      char *name;
+      rtx decl_rtl = DECL_RTL (decl);
+
+      p = (* targetm.strip_name_encoding) (XSTR (XEXP (decl_rtl, 0), 0));
+      name = xstrdup (p);
+
+      if (! DECL_WEAK (decl) && ! DECL_ONE_ONLY (decl))
+       first_global_object_name = name;
+      else
+       weak_global_object_name = name;
+    }
+}
+
 /* Output assembler code for the constant pool of a function and associated
    with defining the name of the function.  DECL describes the function.
    NAME is the function's name.  For the constant pool, we use the current
@@ -1093,19 +1121,7 @@ assemble_start_function (tree decl, const char *fnname)
 
   if (TREE_PUBLIC (decl))
     {
-      if (! first_global_object_name)
-       {
-         const char *p;
-         char *name;
-
-         p = (* targetm.strip_name_encoding) (fnname);
-         name = xstrdup (p);
-
-         if (! DECL_WEAK (decl) && ! DECL_ONE_ONLY (decl))
-           first_global_object_name = name;
-         else
-           weak_global_object_name = name;
-       }
+      notice_global_symbol (decl);
 
       globalize_decl (decl);
 
@@ -1400,20 +1416,8 @@ assemble_variable (tree decl, int top_level ATTRIBUTE_UNUSED,
     }
 
   name = XSTR (XEXP (decl_rtl, 0), 0);
-  if (TREE_PUBLIC (decl) && DECL_NAME (decl)
-      && ! first_global_object_name
-      && ! (DECL_COMMON (decl) && (DECL_INITIAL (decl) == 0
-                                  || DECL_INITIAL (decl) == error_mark_node))
-      && ! DECL_WEAK (decl)
-      && ! DECL_ONE_ONLY (decl))
-    {
-      const char *p;
-      char *xname;
-
-      p = (* targetm.strip_name_encoding) (name);
-      xname = xstrdup (p);
-      first_global_object_name = xname;
-    }
+  if (TREE_PUBLIC (decl) && DECL_NAME (decl))
+    notice_global_symbol (decl);
 
   /* Compute the alignment of this data.  */