Re: Make change_decl_assembler_name functional with inline clones

2013-04-09 Thread Bernhard Reutner-Fischer

On 8 April 2013 22:08:54 Jan Hubicka hubi...@ucw.cz wrote:

Hi,
this patch makes change_decl_assembler_name to do the right thing with inline
clones.  My original plan was to remove inline clones from assembler_name_hash,
but it hits the problem that we currently need to make them unique for purposes
of LTO sreaming.

It is not hard to walk the clone tree and update it.
Later we can reorg streaming to not rely on uniqueness of symbol names of 
function

bodies not associated with a real symbol and perhaps simplify this somewhat.

Bootstrapped/regtested x86_64-linux, will commit it shortly.

PR lto/54095
* symtab.c (insert_to_assembler_name_hash): Handle clones.
(unlink_from_assembler_name_hash): Likewise.
(symtab_prevail_in_asm_name_hash, symtab_register_node,
symtab_unregister_node, symtab_initialize_asm_name_hash,
change_decl_assembler_name): Update.

Index: symtab.c
===
*** symtab.c(revision 197551)
--- symtab.c(working copy)
*** eq_assembler_name (const void *p1, const
*** 102,108 
  /* Insert NODE to assembler name hash.  */

  static void
! insert_to_assembler_name_hash (symtab_node node)
  {
if (is_a varpool_node (node)  DECL_HARD_REGISTER (node-symbol.decl))
  return;
--- 102,108 
  /* Insert NODE to assembler name hash.  */

  static void
! insert_to_assembler_name_hash (symtab_node node, bool with_clones)
  {
if (is_a varpool_node (node)  DECL_HARD_REGISTER (node-symbol.decl))
  return;
*** insert_to_assembler_name_hash (symtab_no
*** 111,116 
--- 111,119 
if (assembler_name_hash)
  {
void **aslot;
+   struct cgraph_node *cnode;
+   tree decl = node-symbol.decl;
+ tree name = DECL_ASSEMBLER_NAME (node-symbol.decl);


Maybe use decl here?
Thanks,


Sent with AquaMail for Android
http://www.aqua-mail.com




Make change_decl_assembler_name functional with inline clones

2013-04-08 Thread Jan Hubicka
Hi,
this patch makes change_decl_assembler_name to do the right thing with inline
clones.  My original plan was to remove inline clones from assembler_name_hash,
but it hits the problem that we currently need to make them unique for purposes
of LTO sreaming.

It is not hard to walk the clone tree and update it.
Later we can reorg streaming to not rely on uniqueness of symbol names of 
function
bodies not associated with a real symbol and perhaps simplify this somewhat.

Bootstrapped/regtested x86_64-linux, will commit it shortly.

PR lto/54095
* symtab.c (insert_to_assembler_name_hash): Handle clones.
(unlink_from_assembler_name_hash): Likewise.
(symtab_prevail_in_asm_name_hash, symtab_register_node,
symtab_unregister_node, symtab_initialize_asm_name_hash,
change_decl_assembler_name): Update.

Index: symtab.c
===
*** symtab.c(revision 197551)
--- symtab.c(working copy)
*** eq_assembler_name (const void *p1, const
*** 102,108 
  /* Insert NODE to assembler name hash.  */
  
  static void
! insert_to_assembler_name_hash (symtab_node node)
  {
if (is_a varpool_node (node)  DECL_HARD_REGISTER (node-symbol.decl))
  return;
--- 102,108 
  /* Insert NODE to assembler name hash.  */
  
  static void
! insert_to_assembler_name_hash (symtab_node node, bool with_clones)
  {
if (is_a varpool_node (node)  DECL_HARD_REGISTER (node-symbol.decl))
  return;
*** insert_to_assembler_name_hash (symtab_no
*** 111,116 
--- 111,119 
if (assembler_name_hash)
  {
void **aslot;
+   struct cgraph_node *cnode;
+   tree decl = node-symbol.decl;
+ 
tree name = DECL_ASSEMBLER_NAME (node-symbol.decl);
  
aslot = htab_find_slot_with_hash (assembler_name_hash, name,
*** insert_to_assembler_name_hash (symtab_no
*** 121,126 
--- 124,136 
if (*aslot != NULL)
((symtab_node)*aslot)-symbol.previous_sharing_asm_name = node;
*aslot = node;
+ 
+   /* Update also possible inline clones sharing a decl.  */
+   cnode = dyn_cast cgraph_node (node);
+   if (cnode  cnode-clones  with_clones)
+   for (cnode = cnode-clones; cnode; cnode = cnode-next_sibling_clone)
+ if (cnode-symbol.decl == decl)
+   insert_to_assembler_name_hash ((symtab_node) cnode, true);
  }
  
  }
*** insert_to_assembler_name_hash (symtab_no
*** 128,137 
  /* Remove NODE from assembler name hash.  */
  
  static void
! unlink_from_assembler_name_hash (symtab_node node)
  {
if (assembler_name_hash)
  {
if (node-symbol.next_sharing_asm_name)
node-symbol.next_sharing_asm_name-symbol.previous_sharing_asm_name
  = node-symbol.previous_sharing_asm_name;
--- 138,150 
  /* Remove NODE from assembler name hash.  */
  
  static void
! unlink_from_assembler_name_hash (symtab_node node, bool with_clones)
  {
if (assembler_name_hash)
  {
+   struct cgraph_node *cnode;
+   tree decl = node-symbol.decl;
+ 
if (node-symbol.next_sharing_asm_name)
node-symbol.next_sharing_asm_name-symbol.previous_sharing_asm_name
  = node-symbol.previous_sharing_asm_name;
*** unlink_from_assembler_name_hash (symtab_
*** 155,160 
--- 168,180 
}
node-symbol.next_sharing_asm_name = NULL;
node-symbol.previous_sharing_asm_name = NULL;
+ 
+   /* Update also possible inline clones sharing a decl.  */
+   cnode = dyn_cast cgraph_node (node);
+   if (cnode  cnode-clones  with_clones)
+   for (cnode = cnode-clones; cnode; cnode = cnode-next_sibling_clone)
+ if (cnode-symbol.decl == decl)
+   unlink_from_assembler_name_hash ((symtab_node) cnode, true);
  }
  }
  
*** unlink_from_assembler_name_hash (symtab_
*** 163,170 
  void
  symtab_prevail_in_asm_name_hash (symtab_node node)
  {
!   unlink_from_assembler_name_hash (node);
!   insert_to_assembler_name_hash (node);
  }
  
  
--- 183,190 
  void
  symtab_prevail_in_asm_name_hash (symtab_node node)
  {
!   unlink_from_assembler_name_hash (node, false);
!   insert_to_assembler_name_hash (node, false);
  }
  
  
*** symtab_register_node (symtab_node node)
*** 196,202 
  
/* Be sure to do this last; C++ FE might create new nodes via
   DECL_ASSEMBLER_NAME langhook!  */
!   insert_to_assembler_name_hash (node);
  }
  
  /* Make NODE to be the one symtab hash is pointing to.  Used when reshaping 
tree
--- 216,222 
  
/* Be sure to do this last; C++ FE might create new nodes via
   DECL_ASSEMBLER_NAME langhook!  */
!   insert_to_assembler_name_hash (node, false);
  }
  
  /* Make NODE to be the one symtab hash is pointing to.  Used when reshaping 
tree
*** symtab_unregister_node (symtab_node node
*** 259,265 
else
*slot =