From 638531ad8032e096a740db1801b4f3ed656298d9 Mon Sep 17 00:00:00 2001 From: hubicka Date: Tue, 9 Sep 2003 20:27:52 +0000 Subject: [PATCH] * cgraphunit.c (cgraph_finalize_function): Fix handling of extern inline functions. (cgraph_finalize_compilation_unit): Fix crash when dealing with lost DECL_SAVED_TREE. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@71245 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 7 +++++++ gcc/cgraphunit.c | 44 ++++++++++++++++++++++++++------------------ 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6754c80b56e..49a3826553e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +Tue Sep 9 22:18:48 CEST 2003 Jan Hubicka + + * cgraphunit.c (cgraph_finalize_function): Fix handling of extern + inline functions. + (cgraph_finalize_compilation_unit): Fix crash when dealing with lost + DECL_SAVED_TREE. + 2003-09-09 Roger Sayle * builtins.c (fold_builtin_cabs): Protect the complex argument diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index a41182f7d3e..10bf8377ede 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -160,26 +160,28 @@ cgraph_finalize_function (tree decl, tree body ATTRIBUTE_UNUSED) ??? It may make more sense to use one body for inlining and other body for expanding the function but this is dificult to do. */ - if (!node->needed) + /* Reset our datastructures so we can analyze the function body + again. */ + memset (&node->local, 0, sizeof (node->local)); + memset (&node->global, 0, sizeof (node->global)); + memset (&node->rtl, 0, sizeof (node->rtl)); + node->lowered = false; + if (node->output) + abort (); + while (node->callees) + cgraph_remove_call (node->decl, node->callees->callee->decl); + /* We may need to re-queue the node for assembling in case + we already proceeded it and ignored as not needed. */ + if (node->reachable && !flag_unit_at_a_time) { - /* Reset our datastructures so we can analyze the function body - again. */ - memset (&node->local, 0, sizeof (node->local)); - memset (&node->global, 0, sizeof (node->global)); - memset (&node->rtl, 0, sizeof (node->rtl)); - node->lowered = false; - if (node->output) - abort (); - while (node->callees) - cgraph_remove_call (node->decl, node->callees->callee->decl); + struct cgraph_node *n; + + for (n = cgraph_nodes_queue; n; n = n->next_needed) + if (n == node) + break; + if (!n) + node->reachable = 0; } - else - /* Frontend may call finalize_function twice when it is incorrectly - redefined. */ - if (errorcount || sorrycount) - return; - else - abort (); } notice_global_symbol (decl); node->decl = decl; @@ -333,6 +335,12 @@ cgraph_finalize_compilation_unit (void) node = cgraph_nodes_queue; cgraph_nodes_queue = cgraph_nodes_queue->next_needed; + /* ??? It is possible to create extern inline function and later using + weak alas attribute to kill it's body. See + gcc.c-torture/compile/20011119-1.c */ + if (!DECL_SAVED_TREE (decl)) + continue; + if (node->lowered || !node->reachable || !DECL_SAVED_TREE (decl)) abort (); -- 2.11.0