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]

Re: [jh@suse.cz: Re: 6 GCC regressions, 2 new, with your patch on 2003-06-24T13:15:02Z.]


> > > On Wed, Jun 25, 2003 at 07:19:41PM +0200, Jan Hubicka wrote:
> > > > 	* c-common.c (handle_used_attribute): Use mark_referenced.
> > > > 	* varasm.c (mark_referenced): Break out from ...
> > > > 	(assemble_name): ... here.
> > > > 	* tree.h (mark_referenced): Declare.
> > > 
> > > Ok.
> > Thanks!  The PCH failure is actually more dificult to fix.
> > Storing callgraph into PCH hits the problem with hashtables using
> > pointers.  To avoid it we would have to hash the strings themselves that
> > is slow.  Another way is to re-construct the hashtable once we are
> > restored, for that I had to reinvent the linked chain of varpool nodes.
> > regtested i386, bootstrap in progress OK? 
> 
> No, don't do that.
> 
> If for speed reasons you absolutely must hash on pointers (and you
> should benchmark before you try this), you can use GTY((reorder("xxx"))).
> 
> It's quite likely that if you do benchmark, you'll find that the
> approach you tried below is slower than either of the alternatives.

Actually this looks like good answer :) IDENTIFIER_NODE already has
IDENTIFIER_HASH_VALUE that is the non-changing thing I need.  This patch
simply makes the table to be hashed using IDENTIFIER_HASH_VALUE instead
of pointer itself and put it into gty pool.  No more black magic needed
:)

OK?

Wed Jun 25 20:26:51 CEST 2003  Jan Hubicka  <jh@suse.cz>
	* Makefile.in (GTFILES): Add cgraph.h.
	* cgraph.c (known_decls): Remove.
	(cgraph_hash, cgraph_nodes, cgraph_nodes_queue,
	cgraph_varpool_hash, cgraph_varpool_nodes_queue): GTYize.
	(cgraph_node): Do not allocate known_decls; use polutate hashtable.
	(cgraph_varpool_node): Likewise; add next pointer.
	(cgraph_varpool_nodes): New static variable.
	* cgraph.h (cgraph_local_info, cgraph_global_info, cgraph_rtl_info,
	cgraph_node, cgraph_edge, cgraph_varpool_node, cgraph_nodes, cgraph_n_nodes,
	cgraph_varpool_n_nodes, cgraph_varpool_nodes_queue): GTYize.
	* gengtype.c (open_base_files): Include cgraph.h
Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.1093
diff -c -3 -p -r1.1093 Makefile.in
*** Makefile.in	28 Jun 2003 06:18:10 -0000	1.1093
--- Makefile.in	28 Jun 2003 12:25:54 -0000
*************** GTFILES = $(srcdir)/input.h $(srcdir)/co
*** 1999,2005 ****
    $(srcdir)/bitmap.h $(srcdir)/coverage.c $(srcdir)/function.h  $(srcdir)/rtl.h \
    $(srcdir)/optabs.h $(srcdir)/tree.h $(srcdir)/libfuncs.h $(srcdir)/hashtable.h \
    $(srcdir)/real.h $(srcdir)/varray.h $(srcdir)/ssa.h $(srcdir)/insn-addr.h \
!   $(srcdir)/cselib.h $(srcdir)/basic-block.h \
    $(srcdir)/c-common.h $(srcdir)/c-tree.h \
    $(srcdir)/alias.c $(srcdir)/bitmap.c $(srcdir)/cselib.c $(srcdir)/cgraph.c \
    $(srcdir)/dbxout.c $(srcdir)/dwarf2out.c $(srcdir)/dwarf2asm.c \
--- 1999,2005 ----
    $(srcdir)/bitmap.h $(srcdir)/coverage.c $(srcdir)/function.h  $(srcdir)/rtl.h \
    $(srcdir)/optabs.h $(srcdir)/tree.h $(srcdir)/libfuncs.h $(srcdir)/hashtable.h \
    $(srcdir)/real.h $(srcdir)/varray.h $(srcdir)/ssa.h $(srcdir)/insn-addr.h \
!   $(srcdir)/cselib.h $(srcdir)/basic-block.h  $(srcdir)/cgraph.h \
    $(srcdir)/c-common.h $(srcdir)/c-tree.h \
    $(srcdir)/alias.c $(srcdir)/bitmap.c $(srcdir)/cselib.c $(srcdir)/cgraph.c \
    $(srcdir)/dbxout.c $(srcdir)/dwarf2out.c $(srcdir)/dwarf2asm.c \
Index: cgraph.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cgraph.c,v
retrieving revision 1.14
diff -c -3 -p -r1.14 cgraph.c
*** cgraph.c	27 Jun 2003 15:42:48 -0000	1.14
--- cgraph.c	28 Jun 2003 12:25:54 -0000
*************** Software Foundation, 59 Temple Place - S
*** 35,49 ****
  #include "varray.h"
  #include "output.h"
  
- /* The known declarations must not get garbage collected.  Callgraph
-    datastructures should not get saved via PCH code since this would
-    make it difficult to extend into intra-module optimizer later.  So
-    we store only the references into the array to prevent gabrage
-    collector from deleting live data.  */
- static GTY(()) varray_type known_decls;
  
  /* Hash table used to convert declarations into nodes.  */
! static htab_t cgraph_hash = 0;
  
  /* The linked list of cgraph nodes.  */
  struct cgraph_node *cgraph_nodes;
--- 35,43 ----
  #include "varray.h"
  #include "output.h"
  
  
  /* Hash table used to convert declarations into nodes.  */
! static GTY((param_is (struct cgraph_node))) htab_t cgraph_hash;
  
  /* The linked list of cgraph nodes.  */
  struct cgraph_node *cgraph_nodes;
*************** int cgraph_n_nodes;
*** 58,64 ****
  bool cgraph_global_info_ready = false;
  
  /* Hash table used to convert declarations into nodes.  */
! static htab_t cgraph_varpool_hash = 0;
  
  /* Queue of cgraph nodes scheduled to be lowered and output.  */
  struct cgraph_varpool_node *cgraph_varpool_nodes_queue;
--- 52,58 ----
  bool cgraph_global_info_ready = false;
  
  /* Hash table used to convert declarations into nodes.  */
! static GTY((param_is (struct cgraph_varpool_node))) htab_t cgraph_varpool_hash;
  
  /* Queue of cgraph nodes scheduled to be lowered and output.  */
  struct cgraph_varpool_node *cgraph_varpool_nodes_queue;
*************** struct cgraph_varpool_node *cgraph_varpo
*** 66,71 ****
--- 60,68 ----
  /* Number of nodes in existence.  */
  int cgraph_varpool_n_nodes;
  
+ /* The linked list of cgraph varpool nodes.  */
+ static GTY(())  struct cgraph_varpool_node *cgraph_varpool_nodes;
+ 
  static struct cgraph_edge *create_edge PARAMS ((struct cgraph_node *,
  						struct cgraph_node *));
  static void cgraph_remove_edge PARAMS ((struct cgraph_node *, struct cgraph_node *));
*************** static hashval_t
*** 78,86 ****
  hash_node (p)
       const void *p;
  {
!   return (hashval_t)
!     htab_hash_pointer (DECL_ASSEMBLER_NAME
! 		       (((struct cgraph_node *) p)->decl));
  }
  
  /* Returns nonzero if P1 and P2 are equal.  */
--- 75,83 ----
  hash_node (p)
       const void *p;
  {
!   return ((hashval_t)
! 	  IDENTIFIER_HASH_VALUE (DECL_ASSEMBLER_NAME
! 				 (((struct cgraph_node *) p)->decl)));
  }
  
  /* Returns nonzero if P1 and P2 are equal.  */
*************** cgraph_node (decl)
*** 106,126 ****
      abort ();
  
    if (!cgraph_hash)
!     {
!       cgraph_hash = htab_create (10, hash_node, eq_node, NULL);
!       if (!known_decls)
!         VARRAY_TREE_INIT (known_decls, 32, "known_decls");
!     }
  
    slot =
      (struct cgraph_node **) htab_find_slot_with_hash (cgraph_hash,
  						      DECL_ASSEMBLER_NAME (decl),
! 						      htab_hash_pointer
  						      (DECL_ASSEMBLER_NAME
  						       (decl)), 1);
    if (*slot)
      return *slot;
!   node = xcalloc (sizeof (*node), 1);
    node->decl = decl;
    node->next = cgraph_nodes;
    if (cgraph_nodes)
--- 103,119 ----
      abort ();
  
    if (!cgraph_hash)
!     cgraph_hash = htab_create_ggc (10, hash_node, eq_node, NULL);
  
    slot =
      (struct cgraph_node **) htab_find_slot_with_hash (cgraph_hash,
  						      DECL_ASSEMBLER_NAME (decl),
! 						      IDENTIFIER_HASH_VALUE
  						      (DECL_ASSEMBLER_NAME
  						       (decl)), 1);
    if (*slot)
      return *slot;
!   node = ggc_alloc_cleared (sizeof (*node));
    node->decl = decl;
    node->next = cgraph_nodes;
    if (cgraph_nodes)
*************** cgraph_node (decl)
*** 135,141 ****
        node->next_nested = node->origin->nested;
        node->origin->nested = node;
      }
-   VARRAY_PUSH_TREE (known_decls, decl);
    return node;
  }
  
--- 128,133 ----
*************** static struct cgraph_edge *
*** 166,172 ****
  create_edge (caller, callee)
       struct cgraph_node *caller, *callee;
  {
!   struct cgraph_edge *edge = xmalloc (sizeof (struct cgraph_edge));
  
    edge->caller = caller;
    edge->callee = callee;
--- 158,164 ----
  create_edge (caller, callee)
       struct cgraph_node *caller, *callee;
  {
!   struct cgraph_edge *edge = ggc_alloc (sizeof (struct cgraph_edge));
  
    edge->caller = caller;
    edge->callee = callee;
*************** dump_cgraph (f)
*** 368,376 ****
  static hashval_t
  cgraph_varpool_hash_node (const PTR p)
  {
!   return (hashval_t)
!     htab_hash_pointer (DECL_ASSEMBLER_NAME
! 		       (((struct cgraph_varpool_node *) p)->decl));
  }
  
  /* Returns non-zero if P1 and P2 are equal.  */
--- 360,368 ----
  static hashval_t
  cgraph_varpool_hash_node (const PTR p)
  {
!   return ((hashval_t)
! 	  IDENTIFIER_HASH_VALUE (DECL_ASSEMBLER_NAME
! 				 (((struct cgraph_varpool_node *) p)->decl)));
  }
  
  /* Returns non-zero if P1 and P2 are equal.  */
*************** cgraph_varpool_node (tree decl)
*** 393,417 ****
      abort ();
  
    if (!cgraph_varpool_hash)
!     {
!       cgraph_varpool_hash = htab_create (10, cgraph_varpool_hash_node, eq_cgraph_varpool_node, NULL);
!       if (!known_decls)
!         VARRAY_TREE_INIT (known_decls, 32, "known_decls");
!     }
  
    slot =
      (struct cgraph_varpool_node **) htab_find_slot_with_hash (cgraph_varpool_hash,
  						      DECL_ASSEMBLER_NAME (decl),
! 						      htab_hash_pointer
  						      (DECL_ASSEMBLER_NAME
  						       (decl)), 1);
    if (*slot)
      return *slot;
!   node = xcalloc (sizeof (*node), 1);
    node->decl = decl;
    cgraph_varpool_n_nodes++;
    *slot = node;
-   VARRAY_PUSH_TREE (known_decls, decl);
    return node;
  }
  
--- 385,407 ----
      abort ();
  
    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)), 1);
    if (*slot)
      return *slot;
!   node = ggc_alloc_cleared (sizeof (*node));
    node->decl = decl;
    cgraph_varpool_n_nodes++;
+   cgraph_varpool_nodes = node;
    *slot = node;
    return node;
  }
  
Index: cgraph.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cgraph.h,v
retrieving revision 1.6
diff -c -3 -p -r1.6 cgraph.h
*** cgraph.h	24 Jun 2003 16:50:26 -0000	1.6
--- cgraph.h	28 Jun 2003 12:25:54 -0000
*************** Software Foundation, 59 Temple Place - S
*** 25,31 ****
  /* Information about the function collected locally.
     Available after function is lowered  */
  
! struct cgraph_local_info
  {
    /* Set when function function is visiable in current compilation unit only
       and it's address is never taken.  */
--- 25,31 ----
  /* Information about the function collected locally.
     Available after function is lowered  */
  
! struct cgraph_local_info GTY(())
  {
    /* Set when function function is visiable in current compilation unit only
       and it's address is never taken.  */
*************** struct cgraph_local_info
*** 40,46 ****
  /* Information about the function that needs to be computed globally
     once compilation is finished.  Available only with -funit-at-time.  */
  
! struct cgraph_global_info
  {
    /* Set when the function will be inlined exactly once.  */
    bool inline_once;
--- 40,46 ----
  /* Information about the function that needs to be computed globally
     once compilation is finished.  Available only with -funit-at-time.  */
  
! struct cgraph_global_info GTY(())
  {
    /* Set when the function will be inlined exactly once.  */
    bool inline_once;
*************** struct cgraph_global_info
*** 49,57 ****
  /* Information about the function that is propagated by the RTL backend.
     Available only for functions that has been already assembled.  */
  
! struct cgraph_rtl_info
  {
!    bool const_function, pure_function;
     int preferred_incoming_stack_boundary;
  };
  
--- 49,58 ----
  /* Information about the function that is propagated by the RTL backend.
     Available only for functions that has been already assembled.  */
  
! struct cgraph_rtl_info GTY(())
  {
!    bool const_function;
!    bool pure_function;
     int preferred_incoming_stack_boundary;
  };
  
*************** struct cgraph_rtl_info
*** 59,77 ****
  /* The cgraph data strutcture.
     Each function decl has assigned cgraph_node listing calees and callers.  */
  
! struct cgraph_node
  {
    tree decl;
    struct cgraph_edge *callees;
    struct cgraph_edge *callers;
!   struct cgraph_node *next, *previous;
    /* For nested functions points to function the node is nested in.  */
    struct cgraph_node *origin;
    /* Points to first nested function, if any.  */
    struct cgraph_node *nested;
    /* Pointer to the next function with same origin, if any.  */
    struct cgraph_node *next_nested;
!   void *aux;
  
    /* Set when function must be output - it is externally visible
       or it's address is taken.  */
--- 60,79 ----
  /* The cgraph data strutcture.
     Each function decl has assigned cgraph_node listing calees and callers.  */
  
! struct cgraph_node GTY(())
  {
    tree decl;
    struct cgraph_edge *callees;
    struct cgraph_edge *callers;
!   struct cgraph_node *next;
!   struct cgraph_node *previous;
    /* For nested functions points to function the node is nested in.  */
    struct cgraph_node *origin;
    /* Points to first nested function, if any.  */
    struct cgraph_node *nested;
    /* Pointer to the next function with same origin, if any.  */
    struct cgraph_node *next_nested;
!   PTR GTY ((skip (""))) aux;
  
    /* Set when function must be output - it is externally visible
       or it's address is taken.  */
*************** struct cgraph_node
*** 90,98 ****
    struct cgraph_rtl_info rtl;
  };
  
! struct cgraph_edge
  {
!   struct cgraph_node *caller, *callee;
    struct cgraph_edge *next_caller;
    struct cgraph_edge *next_callee;
  };
--- 92,101 ----
    struct cgraph_rtl_info rtl;
  };
  
! struct cgraph_edge GTY(())
  {
!   struct cgraph_node *caller;
!   struct cgraph_node *callee;
    struct cgraph_edge *next_caller;
    struct cgraph_edge *next_callee;
  };
*************** struct cgraph_edge
*** 100,109 ****
  /* The cgraph_varpool data strutcture.
     Each static variable decl has assigned cgraph_varpool_node.  */
  
! struct cgraph_varpool_node
  {
    tree decl;
!   void *aux;
  
    /* Set when function must be output - it is externally visible
       or it's address is taken.  */
--- 103,112 ----
  /* The cgraph_varpool data strutcture.
     Each static variable decl has assigned cgraph_varpool_node.  */
  
! struct cgraph_varpool_node GTY(())
  {
    tree decl;
!   PTR GTY ((skip (""))) aux;
  
    /* Set when function must be output - it is externally visible
       or it's address is taken.  */
*************** struct cgraph_varpool_node
*** 114,126 ****
    bool output;
  };
  
! extern struct cgraph_node *cgraph_nodes;
! extern int cgraph_n_nodes;
  extern bool cgraph_global_info_ready;
! extern struct cgraph_node *cgraph_nodes_queue;
  
! extern int cgraph_varpool_n_nodes;
! extern struct cgraph_varpool_node *cgraph_varpool_nodes_queue;
  
  
  /* In cgraph.c  */
--- 117,129 ----
    bool output;
  };
  
! extern GTY(()) struct cgraph_node *cgraph_nodes;
! extern GTY(()) int cgraph_n_nodes;
  extern bool cgraph_global_info_ready;
! extern GTY(()) struct cgraph_node *cgraph_nodes_queue;
  
! extern GTY(()) int cgraph_varpool_n_nodes;
! extern GTY(()) struct cgraph_varpool_node *cgraph_varpool_nodes_queue;
  
  
  /* In cgraph.c  */
Index: gengtype.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gengtype.c,v
retrieving revision 1.34
diff -c -3 -p -r1.34 gengtype.c
*** gengtype.c	17 Jun 2003 05:09:12 -0000	1.34
--- gengtype.c	28 Jun 2003 12:25:54 -0000
*************** open_base_files (void)
*** 1089,1095 ****
        "hashtab.h", "splay-tree.h", "bitmap.h", "tree.h", "rtl.h",
        "function.h", "insn-config.h", "expr.h", "hard-reg-set.h",
        "basic-block.h", "cselib.h", "insn-addr.h", "ssa.h", "optabs.h",
!       "libfuncs.h", "debug.h", "ggc.h",
        NULL
      };
      const char *const *ifp;
--- 1089,1095 ----
        "hashtab.h", "splay-tree.h", "bitmap.h", "tree.h", "rtl.h",
        "function.h", "insn-config.h", "expr.h", "hard-reg-set.h",
        "basic-block.h", "cselib.h", "insn-addr.h", "ssa.h", "optabs.h",
!       "libfuncs.h", "debug.h", "ggc.h", "cgraph.h",
        NULL
      };
      const char *const *ifp;


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