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]

Unnecessary hash lookup in cgraph_finalize_function?


There seems to be some unnecessary hash lookup in cgraph_finalize_function.
It clears out a list of edges with:

    while (node->callees)
      cgraph_remove_call (node->decl, node->callees->callee->decl);

...which in turn calls...

    void
    cgraph_remove_call (tree caller, tree callee)
    {
      cgraph_remove_edge (cgraph_node (caller), cgraph_node (callee));
    }

...which looks up the nodes for caller and callee in the hash table.
Couldn't it just call cgraph_remove_edge directly, as per the patch below?

The patch also means that the glibcism:

    void foo (void);
    extern inline void bar (void) { foo (); }
    extern void foo (void) __asm__ ("fooname");
    void bar (void) { foo (); }

no longer causes an ICE with -O2 -fno-unit-at-a-time.  At the moment,
the lookup of foo() returns a different decl than the one which it
had originally.  cgraph_remove_edge() is then not able to find the
edge it's looking for.

ISTR Jan suggesting we declare this invalid (no opinion on that).
But this patch seems to allow older glibcs to build with the options
above.

Bootstrapped on i686-pc-linux-gnu.  OK to install?

Richard


	* cgraph.h (cgraph_remove_edge): Declare.
	* cgraph.c (cgraph_remove_edge): Make extern.
	* cgraphunit.c (cgraph_finalize_function): Call cgraph_remove_edge
	instead of cgraph_remove_call.

Index: cgraph.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cgraph.h,v
retrieving revision 1.20
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.20 cgraph.h
--- cgraph.h	11 Sep 2003 07:14:01 -0000	1.20
+++ cgraph.h	25 Sep 2003 10:33:53 -0000
@@ -150,6 +150,7 @@ extern GTY(()) struct cgraph_varpool_nod
 
 /* In cgraph.c  */
 void dump_cgraph (FILE *);
+void cgraph_remove_edge (struct cgraph_node *, struct cgraph_node *);
 void cgraph_remove_call (tree, tree);
 void cgraph_remove_node (struct cgraph_node *);
 struct cgraph_edge *cgraph_record_call (tree, tree);
Index: cgraph.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cgraph.c,v
retrieving revision 1.28
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.28 cgraph.c
--- cgraph.c	9 Sep 2003 00:31:39 -0000	1.28
+++ cgraph.c	25 Sep 2003 10:33:53 -0000
@@ -68,7 +68,6 @@ static GTY(())  struct cgraph_varpool_no
 
 static struct cgraph_edge *create_edge (struct cgraph_node *,
 					struct cgraph_node *);
-static void cgraph_remove_edge (struct cgraph_node *, struct cgraph_node *);
 static hashval_t hash_node (const void *);
 static int eq_node (const void *, const void *);
 
@@ -180,7 +179,7 @@ create_edge (struct cgraph_node *caller,
 
 /* Remove the edge from CALLER to CALLEE in the cgraph.  */
 
-static void
+void
 cgraph_remove_edge (struct cgraph_node *caller, struct cgraph_node *callee)
 {
   struct cgraph_edge **edge, **edge2;
Index: cgraphunit.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cgraphunit.c,v
retrieving revision 1.29
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.29 cgraphunit.c
--- cgraphunit.c	11 Sep 2003 07:14:01 -0000	1.29
+++ cgraphunit.c	25 Sep 2003 10:33:53 -0000
@@ -173,7 +173,7 @@ cgraph_finalize_function (tree decl, boo
       memset (&node->rtl, 0, sizeof (node->rtl));
       node->analyzed = false;
       while (node->callees)
-	cgraph_remove_call (node->decl, node->callees->callee->decl);
+	cgraph_remove_edge (node, node->callees->callee);
 
       /* We may need to re-queue the node for assembling in case
          we already proceeded it and ignored as not needed.  */


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