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]

Wrong check in cgraphunit?


Hi,

I'm not completely sure about this one, but it looks like we are
computing the growth of inlining functions that we have decided
_not_ to inline in cgraph_estimate_growth:

/* Estimate the growth caused by inlining NODE into all callees.  */

static int
cgraph_estimate_growth (struct cgraph_node *node)
{
  int growth = 0;
  struct cgraph_edge *e;

  for (e = node->callers; e; e = e->next_caller)
    if (e->inline_failed)
      growth += (cgraph_estimate_size_after_inlining (1, e->caller, node)
                 - e->caller->global.insns);

  /* a few more lines... */

  return growth;
}

Now, e->inline_failed is non-NULL iff, well, inlining is not
possible for some reason.

So the way I read this code, we compute the growth based on
the number of callers that we do _not_ inline.  Which is the
reverse of what the function is supposed to do (the comment
on the top is wrong, the function should estimate the growth
caused by inlining NODE into all its _callers_, not callees).

[ But not being too familiar with this code, and because I would
 rather not touch our inlining heuristics ;-), I'm not  sure if
 my reading of this code is correct. ]

Anyway, the attached patch bootstrapped and passed testing 
on i686-unknown-linux-gnu.

Gr.
Steven

Index: cgraphunit.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cgraphunit.c,v
retrieving revision 1.65
diff -c -3 -p -r1.65 cgraphunit.c
*** cgraphunit.c	6 Jun 2004 13:03:08 -0000	1.65
--- cgraphunit.c	10 Jun 2004 17:47:25 -0000
*************** cgraph_estimate_growth (struct cgraph_no
*** 1005,1011 ****
    struct cgraph_edge *e;
  
    for (e = node->callers; e; e = e->next_caller)
!     if (e->inline_failed)
        growth += (cgraph_estimate_size_after_inlining (1, e->caller, node)
  		 - e->caller->global.insns);
  
--- 1005,1011 ----
    struct cgraph_edge *e;
  
    for (e = node->callers; e; e = e->next_caller)
!     if (!e->inline_failed)
        growth += (cgraph_estimate_size_after_inlining (1, e->caller, node)
  		 - e->caller->global.insns);
  


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