From f0c882ab6fcf7595b5d12203a9840202167d45f1 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Wed, 18 Jun 2008 15:42:36 +0200 Subject: [PATCH] cgraph.h (cgraph_mark_if_needed): New function. * cgraph.h (cgraph_mark_if_needed): New function. * cgraphunit.c (cgraph_mark_if_needed): New function. * c-decl.c (duplicate_decl): Use it. From-SVN: r136893 --- gcc/ChangeLog | 6 ++++++ gcc/c-decl.c | 4 ++-- gcc/cgraph.h | 1 + gcc/cgraphunit.c | 12 ++++++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 32fb7e8d364..743b89b4a55 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2008-06-16 Jan Hubicka + + * cgraph.h (cgraph_mark_if_needed): New function. + * cgraphunit.c (cgraph_mark_if_needed): New function. + * c-decl.c (duplicate_decl): Use it. + 2008-06-16 Jan Hubicka * cgraph.c (cgraph_add_new_function): When in expansion state, do diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 89fdf3d1b45..38c1581b3ff 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -1913,9 +1913,9 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype) /* If we changed a function from DECL_EXTERNAL to !DECL_EXTERNAL, and the definition is coming from the old version, cgraph needs to be called again. */ - if (extern_changed && !new_is_definition + if (extern_changed && !new_is_definition && TREE_CODE (olddecl) == FUNCTION_DECL && DECL_INITIAL (olddecl)) - cgraph_finalize_function (olddecl, false); + cgraph_mark_if_needed (olddecl); } /* Handle when a new declaration NEWDECL has the same name as an old diff --git a/gcc/cgraph.h b/gcc/cgraph.h index b537cb5785b..dda2a1891f5 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -331,6 +331,7 @@ void cgraph_add_new_function (tree, bool); /* In cgraphunit.c */ void cgraph_finalize_function (tree, bool); +void cgraph_mark_if_needed (tree); void cgraph_finalize_compilation_unit (void); void cgraph_optimize (void); void cgraph_mark_needed_node (struct cgraph_node *); diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index 7c0db40ce7c..dec22131712 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -642,6 +642,18 @@ cgraph_finalize_function (tree decl, bool nested) do_warn_unused_parameter (decl); } +/* C99 extern inline keywords allow changing of declaration after function + has been finalized. We need to re-decide if we want to mark the function as + needed then. */ + +void +cgraph_mark_if_needed (tree decl) +{ + struct cgraph_node *node = cgraph_node (decl); + if (node->local.finalized && decide_is_function_needed (node, decl)) + cgraph_mark_needed_node (node); +} + /* Verify cgraph nodes of given cgraph node. */ void verify_cgraph_node (struct cgraph_node *node) -- 2.30.2