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: [tree-ssa] Fix cgraph related PR opt/13729


Hi,
sorry, I actually sent completely wrong file out.  That patch was about
proposed patch for jump combining:
  http://gcc.gnu.org/ml/gcc/2003-11/msg01216.html

It supposed to be:
Hi,
This patch fix some desynchronization about what shall be marked dead in
cgraph_remove_unreachable_nodes so we don't end up remove reachable extern
inline nodes that don't have body defined.

Bootstrapped/regtested i686-pc-gnu-linux, will commit it to the tree shortly.
Honza

2004-01-18  Jan Hubicka  <jh@suse.cz>
	PR opt/13729
	* cgraphunit.c (cgraph_finalize_compilation_unit): Fix memory leak.
	(cgraph_remove_unreachable_nodes):  Do not mix analyzed and DECL_SAVED_TREE
	flags.
Index: cgraphunit.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cgraphunit.c,v
retrieving revision 1.1.4.30
diff -c -3 -p -r1.1.4.30 cgraphunit.c
*** cgraphunit.c	9 Jan 2004 21:19:27 -0000	1.1.4.30
--- cgraphunit.c	18 Jan 2004 21:52:12 -0000
*************** cgraph_finalize_compilation_unit (void)
*** 561,566 ****
--- 561,568 ----
  	    fprintf (cgraph_dump_file, " %s", cgraph_node_name (node));
  	  cgraph_remove_node (node);
  	}
+       else
+ 	node->next_needed = NULL;
      }
    if (cgraph_dump_file)
      {
*************** cgraph_postorder (struct cgraph_node **o
*** 704,719 ****
  static bool
  cgraph_remove_unreachable_nodes (void)
  {
!   struct cgraph_node *first = (void *)1;
    struct cgraph_node *node;
    bool changed = false;
    int insns = 0;
  
    if (cgraph_dump_file)
      fprintf (cgraph_dump_file, "\nReclaiming functions:");
    for (node = cgraph_nodes; node; node = node->next)
!     if (node->needed
! 	&& (!DECL_EXTERNAL (node->decl) || !DECL_SAVED_TREE (node->decl)))
        {
  	node->aux = first;
  	first = node;
--- 706,726 ----
  static bool
  cgraph_remove_unreachable_nodes (void)
  {
!   struct cgraph_node *first = (void *) 1;
    struct cgraph_node *node;
    bool changed = false;
    int insns = 0;
  
+   verify_cgraph ();
    if (cgraph_dump_file)
      fprintf (cgraph_dump_file, "\nReclaiming functions:");
+ #ifdef ENABLE_CHECKING
    for (node = cgraph_nodes; node; node = node->next)
!     if (node->aux)
!       abort ();
! #endif
!   for (node = cgraph_nodes; node; node = node->next)
!     if (node->needed && (!DECL_EXTERNAL (node->decl) || !node->analyzed))
        {
  	node->aux = first;
  	first = node;
*************** cgraph_remove_unreachable_nodes (void)
*** 724,730 ****
    /* Perform reachability analysis.  As a special case do not consider
       extern inline functions not inlined as live because we won't output
       them at all.  */
!   while (first != (void *)1)
      {
        struct cgraph_edge *e;
        node = first;
--- 731,737 ----
    /* Perform reachability analysis.  As a special case do not consider
       extern inline functions not inlined as live because we won't output
       them at all.  */
!   while (first != (void *) 1)
      {
        struct cgraph_edge *e;
        node = first;
*************** cgraph_remove_unreachable_nodes (void)
*** 732,738 ****
  
        for (e = node->callees; e; e = e->next_callee)
  	if (!e->callee->aux
! 	    && (!e->inline_failed || !DECL_SAVED_TREE (e->callee->decl)
  		|| !DECL_EXTERNAL (e->callee->decl)))
  	  {
  	    e->callee->aux = first;
--- 739,746 ----
  
        for (e = node->callees; e; e = e->next_callee)
  	if (!e->callee->aux
! 	    && node->analyzed
! 	    && (!e->inline_failed || !e->callee->analyzed
  		|| !DECL_EXTERNAL (e->callee->decl)))
  	  {
  	    e->callee->aux = first;
*************** cgraph_remove_unreachable_nodes (void)
*** 752,791 ****
      {
        if (!node->aux)
  	{
! 	  struct cgraph_edge *e = NULL;
  
  	  if (cgraph_dump_file)
  	    fprintf (cgraph_dump_file, " %s", cgraph_node_name (node));
! 	  insns += node->local.self_insns;
! 
! 	  if (DECL_EXTERNAL (node->decl) && DECL_SAVED_TREE (node->decl))
  	    {
  	      for (e = node->callers; e; e = e->next_caller)
  		if (e->caller->aux)
  		  break;
  	    }
! 	  if (e || node->needed)
! 	    {
! 	      struct cgraph_node *clone;
! 
! 	      for (clone = node->next_clone; clone; clone = clone->next_clone)
! 		if (clone->aux)
! 		  break;
! 	      if (!clone)
! 	        DECL_SAVED_TREE (node->decl) = NULL_TREE;
! 	      while (node->callees)
! 	        cgraph_remove_edge (node->callees);
! 	      node->analyzed = false;
! 	    }
! 	  else
! 	    cgraph_remove_node (node);
  	  changed = true;
  	}
      }
    for (node = cgraph_nodes; node; node = node->next)
      node->aux = NULL;
    if (cgraph_dump_file)
!     fprintf (cgraph_dump_file, "\nReclaimed %i insns:", insns);
    verify_cgraph ();
    return changed;
  }
--- 760,809 ----
      {
        if (!node->aux)
  	{
! 	  int local_insns;
! 	  tree decl = node->decl;
  
+ 	  if (DECL_SAVED_INSNS (decl))
+ 	    local_insns = node->local.self_insns;
+ 	  else
+ 	    local_insns = 0;
  	  if (cgraph_dump_file)
  	    fprintf (cgraph_dump_file, " %s", cgraph_node_name (node));
! 	  if (!node->analyzed || !DECL_EXTERNAL (node->decl))
! 	    cgraph_remove_node (node);
! 	  else
  	    {
+ 	      struct cgraph_edge *e;
+ 
  	      for (e = node->callers; e; e = e->next_caller)
  		if (e->caller->aux)
  		  break;
+ 	      if (e || node->needed)
+ 		{
+ 		  struct cgraph_node *clone;
+ 
+ 		  for (clone = node->next_clone; clone;
+ 		       clone = clone->next_clone)
+ 		    if (clone->aux)
+ 		      break;
+ 		  if (!clone)
+ 		    DECL_SAVED_TREE (node->decl) = NULL_TREE;
+ 		  while (node->callees)
+ 		    cgraph_remove_edge (node->callees);
+ 		  node->analyzed = false;
+ 		}
+ 	      else
+ 		cgraph_remove_node (node);
  	    }
! 	  if (!DECL_SAVED_TREE (decl))
! 	    insns += local_insns;
  	  changed = true;
  	}
      }
    for (node = cgraph_nodes; node; node = node->next)
      node->aux = NULL;
    if (cgraph_dump_file)
!     fprintf (cgraph_dump_file, "\nReclaimed %i insns", insns);
    verify_cgraph ();
    return changed;
  }


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