[Bug middle-end/16460] [3.5 Regression] ICE when compiling glibc (ld-ctype.c)

jh at suse dot cz gcc-bugzilla@gcc.gnu.org
Fri Sep 10 10:34:00 GMT 2004


------- Additional Comments From jh at suse dot cz  2004-09-10 10:34 -------
Subject: Re:  [3.5 Regression] ICE when compiling glibc (ld-ctype.c)

Hi,
the problem is that we can now inline nested functions across the
boundary of outer function but remove_node kills proactively all the
nested functions when it is done with the outer scope.

I am testing the attached patch.  I actually tried to kill nestedness of
datastructure part of cgraph as suggested by rth other time, but we have
quite a few use of this in the unnesting code itself and few other
places so it looks more convenient to kill it once we are done with
unnesting.

Richard, does this seem sane?  I probably should do that in
unnest_function_tree so it is done at the time unnesting really happens
instead of waiting for the end of compilation.  I will do this change
before putting in the patch if this approach looks sane to you.

Honza

static inline int g(int i) {
  auto inline int h(void);
  auto int h2(void) __attribute__((noinline));
  int h(void) { return i+1; }
  int h2(void) { return h(); }
  return h2();
}
int f(void) { return g(1); }
int f2(void) { return g(1); }

2004-09-10  Jan Hubicka  <jh@suse.cz>
	middle-end/16460
	* cgraphunit.c (decide_is_function_needed): Do not use node->origin.
	(cgraph_finalize_compilation_unit): Kill nestedness datastructure no longer
	important for the backend.

Index: cgraphunit.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cgraphunit.c,v
retrieving revision 1.79
diff -c -3 -p -r1.79 cgraphunit.c
*** cgraphunit.c	10 Sep 2004 08:56:35 -0000	1.79
--- cgraphunit.c	10 Sep 2004 10:27:52 -0000
*************** static FILE *cgraph_dump_file;
*** 220,226 ****
  static bool
  decide_is_function_needed (struct cgraph_node *node, tree decl)
  {
!   struct cgraph_node *origin;
  
    /* If we decided it was needed before, but at the time we didn't have
       the body of the function available, then it's still needed.  We have
--- 220,226 ----
  static bool
  decide_is_function_needed (struct cgraph_node *node, tree decl)
  {
!   tree origin;
  
    /* If we decided it was needed before, but at the time we didn't have
       the body of the function available, then it's still needed.  We have
*************** decide_is_function_needed (struct cgraph
*** 260,267 ****
      return false;
    /* Nested functions of extern inline function shall not be emit unless
       we inlined the origin.  */
!   for (origin = node->origin; origin; origin = origin->origin)
!     if (DECL_EXTERNAL (origin->decl))
        return false;
    /* We want to emit COMDAT functions only when absolutely necessary.  */
    if (DECL_COMDAT (decl))
--- 260,268 ----
      return false;
    /* Nested functions of extern inline function shall not be emit unless
       we inlined the origin.  */
!   for (origin = decl_function_context (decl);
!        origin; origin = decl_function_context (origin))
!     if (DECL_EXTERNAL (origin))
        return false;
    /* We want to emit COMDAT functions only when absolutely necessary.  */
    if (DECL_COMDAT (decl))
*************** cgraph_finalize_compilation_unit (void)
*** 692,697 ****
--- 693,703 ----
        struct cgraph_edge *edge;
        tree decl = cgraph_nodes_queue->decl;
  
+       /* We performed unnesting, so kill the no longer neccesary data.  */
+       node->origin = NULL;
+       node->next_nested = NULL;
+       node->nested = NULL;
+ 
        node = cgraph_nodes_queue;
        cgraph_nodes_queue = cgraph_nodes_queue->next_needed;
        node->next_needed = NULL;


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16460



More information about the Gcc-bugs mailing list