This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix -fno-unit-at-a-time handling of redefined extern inlines (PR tree-optimization/18947)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: jh at suse dot cz, gcc-patches at gcc dot gnu dot org
- Date: Tue, 15 Feb 2005 18:00:07 -0500
- Subject: [PATCH] Fix -fno-unit-at-a-time handling of redefined extern inlines (PR tree-optimization/18947)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
On the testcases below with -fno-unit-at-a-time, we get an ICE in
verify_cgraph, because redefined extern inline node removed edges to the
functions it inlined into itself, but did not remove the nodes to,
so we end up with nodes that have callers = NULL, but global.inlined_to !=
NULL.
The following patch works for me, though I'm not 100% sure whether this is
the correct approach.
2005-02-15 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/18947
* cgraphunit.c (cgraph_finalize_function): When redefining an extern
inline, remove all nodes that are inlined into the extern inline
being redefined.
* gcc.c-torture/compile/20050215-1.c: New test.
* gcc.c-torture/compile/20050215-2.c: New test.
* gcc.c-torture/compile/20050215-3.c: New test.
--- gcc/cgraphunit.c.jj 2004-12-14 12:21:56.000000000 +0100
+++ gcc/cgraphunit.c 2005-02-15 23:28:39.996499250 +0100
@@ -346,6 +346,16 @@ cgraph_finalize_function (tree decl, boo
memset (&node->rtl, 0, sizeof (node->rtl));
node->analyzed = false;
node->local.redefined_extern_inline = true;
+
+ if (!flag_unit_at_a_time)
+ {
+ struct cgraph_node *n;
+
+ for (n = cgraph_nodes; n; n = n->next)
+ if (n->global.inlined_to == node)
+ cgraph_remove_node (n);
+ }
+
while (node->callees)
cgraph_remove_edge (node->callees);
--- gcc/testsuite/gcc.c-torture/compile/20050215-1.c.jj 2005-02-15 23:39:39.106088047 +0100
+++ gcc/testsuite/gcc.c-torture/compile/20050215-1.c 2005-02-15 23:40:58.668912843 +0100
@@ -0,0 +1,4 @@
+/* PR tree-optimization/18947 */
+extern __inline void f1 (void) { }
+extern __inline void f2 (void) { f1 (); }
+void f2 (void) {}
--- gcc/testsuite/gcc.c-torture/compile/20050215-2.c.jj 2005-02-15 23:39:39.106088047 +0100
+++ gcc/testsuite/gcc.c-torture/compile/20050215-2.c 2005-02-15 23:41:59.237121981 +0100
@@ -0,0 +1,7 @@
+/* PR tree-optimization/18947 */
+int v;
+extern __inline void f1 (void) { v++; }
+void f4 (void) { f1 (); }
+extern __inline void f2 (void) { f1 (); }
+void f3 (void) { f2 (); }
+void f2 (void) { f1 (); }
--- gcc/testsuite/gcc.c-torture/compile/20050215-3.c.jj 2005-02-15 23:39:39.106088047 +0100
+++ gcc/testsuite/gcc.c-torture/compile/20050215-3.c 2005-02-15 23:42:04.665154928 +0100
@@ -0,0 +1,8 @@
+/* PR tree-optimization/18947 */
+int v;
+extern __inline void f0 (void) { v++; }
+extern __inline void f1 (void) { f0 (); }
+void f4 (void) { f1 (); }
+extern __inline void f2 (void) { f1 (); }
+void f3 (void) { f2 (); }
+void f2 (void) { f1 (); }
Jakub