OSDN Git Service

PR opt/12275
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 13 Nov 2003 02:07:57 +0000 (02:07 +0000)
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 13 Nov 2003 02:07:57 +0000 (02:07 +0000)
* c-decl.c (finish_decl): Use change_decl_assembler_name.
* c-pragma.c (handle_pragma_redefine_extname): Likewise.
* varasm.c (make_decl_rtl): Likewise.
* cgraph.c (change_decl_assembler_name): New function.
* tree.h (set_decl_assembler_name): Kill dead declaration.
(change_decl_assembler_name): Declare.

* decl.c (make_rtl_for_nonlocal_decl): Use change_decl_assembler_name.
* decl2.c (make_rtl_for_nonlocal_decl): Use change_decl_assembler_name.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@73532 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/c-decl.c
gcc/c-pragma.c
gcc/cgraph.c
gcc/cp/decl.c
gcc/cp/decl2.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/20031112-1.c [new file with mode: 0644]
gcc/tree.h
gcc/varasm.c

index a20beba..c5bfc1f 100644 (file)
@@ -1,3 +1,16 @@
+2003-11-13  Jan Hubicka  <jh@suse.cz>
+
+       PR opt/12275
+       * c-decl.c (finish_decl): Use change_decl_assembler_name.
+       * c-pragma.c (handle_pragma_redefine_extname): Likewise.
+       * varasm.c (make_decl_rtl): Likewise.
+       * cgraph.c (change_decl_assembler_name): New function.
+       * tree.h (set_decl_assembler_name): Kill dead declaration.
+       (change_decl_assembler_name): Declare.
+
+       * decl.c (make_rtl_for_nonlocal_decl): Use change_decl_assembler_name.
+       * decl2.c (make_rtl_for_nonlocal_decl): Use change_decl_assembler_name.
+
 2003-11-12  Kazu Hirata  <kazu@cs.umass.edu>
 
        * config/h8300/lib1funcs.asm (___mulsi3): Don't save/restore
index 96fb4bb..61fcae0 100644 (file)
@@ -2870,7 +2870,7 @@ finish_decl (tree decl, tree init, tree asmspec_tree)
 #endif
        }
       SET_DECL_RTL (decl, NULL_RTX);
-      SET_DECL_ASSEMBLER_NAME (decl, get_identifier (starred));
+      change_decl_assembler_name (decl, get_identifier (starred));
     }
 
   /* If #pragma weak was used, mark the decl weak now.  */
@@ -2920,7 +2920,7 @@ finish_decl (tree decl, tree init, tree asmspec_tree)
                warning ("%Jignoring asm-specifier for non-static local "
                          "variable '%D'", decl, decl);
              else
-               SET_DECL_ASSEMBLER_NAME (decl, get_identifier (asmspec));
+               change_decl_assembler_name (decl, get_identifier (asmspec));
            }
 
          if (TREE_CODE (decl) != FUNCTION_DECL)
index 141b906..e233a5e 100644 (file)
@@ -382,7 +382,7 @@ handle_pragma_redefine_extname (cpp_reader *dummy ATTRIBUTE_UNUSED)
       if (DECL_ASSEMBLER_NAME_SET_P (decl)
          && DECL_ASSEMBLER_NAME (decl) != newname)
         warning ("#pragma redefine_extname conflicts with declaration");
-      SET_DECL_ASSEMBLER_NAME (decl, newname);
+      change_decl_assembler_name (decl, newname);
     }
   else
     add_to_renaming_pragma_list(oldname, newname);
index 51ea93a..fa6ec7d 100644 (file)
@@ -428,8 +428,6 @@ cgraph_varpool_node (tree decl)
   if (!cgraph_varpool_hash)
     cgraph_varpool_hash = htab_create_ggc (10, cgraph_varpool_hash_node,
                                           eq_cgraph_varpool_node, NULL);
-
-
   slot = (struct cgraph_varpool_node **)
     htab_find_slot_with_hash (cgraph_varpool_hash, DECL_ASSEMBLER_NAME (decl),
                              IDENTIFIER_HASH_VALUE (DECL_ASSEMBLER_NAME (decl)),
@@ -444,6 +442,84 @@ cgraph_varpool_node (tree decl)
   return node;
 }
 
+/* Set the DECL_ASSEMBLER_NAME and update cgraph hashtables.  */
+void
+change_decl_assembler_name (tree decl, tree name)
+{
+  struct cgraph_node *node = NULL;
+  struct cgraph_varpool_node *vnode = NULL;
+  void **slot;
+
+  if (!DECL_ASSEMBLER_NAME_SET_P (decl))
+    {
+      SET_DECL_ASSEMBLER_NAME (decl, name);
+      return;
+    }
+  if (name == DECL_ASSEMBLER_NAME (decl))
+    return;
+
+  if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
+    warning ("%D renamed after being referenced in assembly", decl);
+
+  if (TREE_CODE (decl) == FUNCTION_DECL && cgraph_hash)
+    {
+      /* Take a look whether declaration is in the cgraph structure.  */
+      slot = 
+       htab_find_slot_with_hash (cgraph_hash, DECL_ASSEMBLER_NAME (decl),
+                                  IDENTIFIER_HASH_VALUE (DECL_ASSEMBLER_NAME
+                                                         (decl)), NO_INSERT);
+      if (slot)
+       node = *slot;
+
+      /* It is, verify that we are the canonical node for this decl.  */
+      if (node && node->decl == decl)
+       {
+         node = *slot;
+         htab_clear_slot (cgraph_hash, slot);
+        }
+       else
+        node = NULL;
+    }
+  if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl) && cgraph_varpool_hash)
+    {
+      /* Take a look whether declaration is in the cgraph structure.  */
+      slot = 
+       htab_find_slot_with_hash (cgraph_varpool_hash, DECL_ASSEMBLER_NAME (decl),
+                                  IDENTIFIER_HASH_VALUE (DECL_ASSEMBLER_NAME
+                                                         (decl)), NO_INSERT);
+      if (slot)
+       vnode = *slot;
+
+      /* It is, verify that we are the canonical vnode for this decl.  */
+      if (vnode && vnode->decl == decl)
+       {
+         vnode = *slot;
+         htab_clear_slot (cgraph_varpool_hash, slot);
+        }
+       else
+        vnode = NULL;
+    }
+  SET_DECL_ASSEMBLER_NAME (decl, name);
+  if (node)
+    {
+      slot = 
+       htab_find_slot_with_hash (cgraph_hash, name,
+                                 IDENTIFIER_HASH_VALUE (name), INSERT);
+      if (*slot)
+       abort ();
+      *slot = node;
+    }
+  if (vnode)
+    {
+      slot = 
+       htab_find_slot_with_hash (cgraph_varpool_hash, name,
+                                 IDENTIFIER_HASH_VALUE (name), INSERT);
+      if (*slot)
+       abort ();
+      *slot = vnode;
+    }
+}
+
 /* Try to find existing function for identifier ID.  */
 struct cgraph_varpool_node *
 cgraph_varpool_node_for_identifier (tree id)
index 61bea50..93368c5 100644 (file)
@@ -4526,7 +4526,7 @@ make_rtl_for_nonlocal_decl (tree decl, tree init, const char* asmspec)
   /* Set the DECL_ASSEMBLER_NAME for the variable.  */
   if (asmspec)
     {
-      SET_DECL_ASSEMBLER_NAME (decl, get_identifier (asmspec));
+      change_decl_assembler_name (decl, get_identifier (asmspec));
       /* The `register' keyword, when used together with an
         asm-specification, indicates that the variable should be
         placed in a particular register.  */
index 7be1c14..5f1076a 100644 (file)
@@ -1000,7 +1000,7 @@ grokfield (tree declarator, tree declspecs, tree init, tree asmspec_tree,
          /* This must override the asm specifier which was placed
             by grokclassfn.  Lay this out fresh.  */
          SET_DECL_RTL (value, NULL_RTX);
-         SET_DECL_ASSEMBLER_NAME (value, get_identifier (asmspec));
+         change_decl_assembler_name (value, get_identifier (asmspec));
        }
       if (!DECL_FRIEND_P (value))
        grok_special_member_properties (value);
index 0c8673a..51095cb 100644 (file)
@@ -1,3 +1,7 @@
+2003-11-13  Jan Hubicka  <jh@suse.cz>
+
+       * gcc.c-torture/compile/20031112-1.c: New test.
+
 2003-11-12  Mark Mitchell  <mark@codesourcery.com>
 
        * g++.dg/parse/crash10.C: Remove bogus error marker.
diff --git a/gcc/testsuite/gcc.c-torture/compile/20031112-1.c b/gcc/testsuite/gcc.c-torture/compile/20031112-1.c
new file mode 100644 (file)
index 0000000..466b29e
--- /dev/null
@@ -0,0 +1,2 @@
+extern __inline int __finite (double __value) { return 0; }
+extern __typeof (__finite) __finite __asm__ ("" "__GI___finite");
index 03b85df..f94214e 100644 (file)
@@ -2712,7 +2712,7 @@ extern tree get_file_function_name_long (const char *);
 extern tree get_set_constructor_bits (tree, char *, int);
 extern tree get_set_constructor_bytes (tree, unsigned char *, int);
 extern tree get_callee_fndecl (tree);
-extern void set_decl_assembler_name (tree);
+extern void change_decl_assembler_name (tree, tree);
 extern int type_num_arguments (tree);
 extern tree lhd_unsave_expr_now (tree);
 
index 9ee145d..7f5ee56 100644 (file)
@@ -791,7 +791,7 @@ make_decl_rtl (tree decl, const char *asmspec)
       char *starred = alloca (strlen (asmspec) + 2);
       starred[0] = '*';
       strcpy (starred + 1, asmspec);
-      SET_DECL_ASSEMBLER_NAME (decl, get_identifier (starred));
+      change_decl_assembler_name (decl, get_identifier (starred));
     }
 
   name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));