This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Allow cgraph nodes to change name
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 18 Aug 2003 10:15:58 +0200
- Subject: Allow cgraph nodes to change name
Hi,
in hammer branch we run into testcase where function name changes in the
middle of process totally messing up the cgraph hashtables. The
testcase does not reproduce on mainline as the function is no longer
localized, but I guess the problem remains. The attached patch fixes
it. OK?
Mon Aug 18 10:12:57 CEST 2003 Jan Hubicka <jh@suse.cz>
* cgraph.c (cgraph_set_decl_assembler_name): New function.
* cgraph.h (cgraph_set_decl_assembler_name): Declare.
* varasm.c (make_decl_rtl): Use it.
Index: cgraph.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cgraph.c,v
retrieving revision 1.20.2.2
diff -c -3 -p -r1.20.2.2 cgraph.c
*** cgraph.c 31 Jul 2003 16:53:07 -0000 1.20.2.2
--- cgraph.c 18 Aug 2003 08:12:27 -0000
*************** cgraph_varpool_assemble_pending_decls ()
*** 520,524 ****
--- 520,577 ----
return changed;
}
+ /* Set the DECL_ASSEMBLER_NAME and update cgraph hashtables. */
+ void
+ cgraph_set_decl_assembler_name (tree decl, tree name)
+ {
+ struct cgraph_node *node = NULL;
+ struct cgraph_varpool_node *vnode = NULL;
+ void **slot;
+
+ if (TREE_CODE (decl) == FUNCTION_DECL && cgraph_hash)
+ {
+ slot =
+ htab_find_slot_with_hash (cgraph_hash, DECL_ASSEMBLER_NAME (decl),
+ IDENTIFIER_HASH_VALUE (DECL_ASSEMBLER_NAME
+ (decl)), 0);
+ if (slot)
+ {
+ node = *slot;
+ htab_clear_slot (cgraph_hash, slot);
+ }
+ }
+ if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl) && cgraph_varpool_hash)
+ {
+ slot =
+ htab_find_slot_with_hash (cgraph_varpool_hash,
+ DECL_ASSEMBLER_NAME (decl),
+ IDENTIFIER_HASH_VALUE (DECL_ASSEMBLER_NAME
+ (decl)), 0);
+ if (slot)
+ {
+ vnode = *slot;
+ htab_clear_slot (cgraph_varpool_hash, slot);
+ }
+ }
+ SET_DECL_ASSEMBLER_NAME (decl, name);
+ if (node)
+ {
+ slot =
+ htab_find_slot_with_hash (cgraph_hash, name,
+ IDENTIFIER_HASH_VALUE (name), 1);
+ if (*slot)
+ abort ();
+ *slot = node;
+ }
+ if (vnode)
+ {
+ slot =
+ htab_find_slot_with_hash (cgraph_varpool_hash, name,
+ IDENTIFIER_HASH_VALUE (name), 1);
+ if (*slot)
+ abort ();
+ *slot = node;
+ }
+ }
#include "gt-cgraph.h"
Index: cgraph.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cgraph.h,v
retrieving revision 1.14.2.1
diff -c -3 -p -r1.14.2.1 cgraph.h
*** cgraph.h 12 Jul 2003 23:08:16 -0000 1.14.2.1
--- cgraph.h 18 Aug 2003 08:12:27 -0000
*************** struct cgraph_varpool_node *cgraph_varpo
*** 170,175 ****
--- 170,176 ----
void cgraph_varpool_mark_needed_node (struct cgraph_varpool_node *);
void cgraph_varpool_finalize_decl (tree);
bool cgraph_varpool_assemble_pending_decls (void);
+ void cgraph_set_decl_assembler_name (tree decl, tree name);
/* In cgraphunit.c */
void cgraph_finalize_function PARAMS ((tree, tree));
Index: varasm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/varasm.c,v
retrieving revision 1.318.2.12
diff -c -3 -p -r1.318.2.12 varasm.c
*** varasm.c 14 Aug 2003 13:20:17 -0000 1.318.2.12
--- varasm.c 18 Aug 2003 08:12:28 -0000
*************** make_decl_rtl (decl, asmspec)
*** 925,931 ****
if (name != new_name)
{
! SET_DECL_ASSEMBLER_NAME (decl, get_identifier (new_name));
name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
}
--- 925,931 ----
if (name != new_name)
{
! cgraph_set_decl_assembler_name (decl, get_identifier (new_name));
name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
}