Hello. Following patch correctly handles filtered removed items, where we forgot to check that a cgraph node is deleted or not. Apart from that, logic in the function was rewritten and is much more understandable what's going on.
Tested on x86_64-linux-pc. Ready for installation? Thanks, Martin
>From 3f1d52424d01e7a76b127bf91bdaa04077371d30 Mon Sep 17 00:00:00 2001 From: mliska <mli...@suse.cz> Date: Mon, 19 Jan 2015 14:28:50 +0100 Subject: [PATCH] Fix PR64664. gcc/ChangeLog: 2015-01-19 Martin Liska <mli...@suse.cz> * ipa-icf.c (sem_item_optimizer::filter_removed_items): Handle safe potentially removed nodes during filtering. --- gcc/ipa-icf.c | 47 +++++++++++++++++++---------------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c index 0ac01a9..449d552 100644 --- a/gcc/ipa-icf.c +++ b/gcc/ipa-icf.c @@ -1652,40 +1652,31 @@ sem_item_optimizer::filter_removed_items (void) { sem_item *item = m_items[i]; - if (item->type == FUNC - && !opt_for_fn (item->decl, flag_ipa_icf_functions)) - { - remove_item (item); - continue; - } - - if (!flag_ipa_icf_variables && item->type == VAR) - { + if (m_removed_items_set.contains (item->node)) + { remove_item (item); continue; - } - - bool no_body_function = false; + } if (item->type == FUNC) - { + { cgraph_node *cnode = static_cast <sem_function *>(item)->get_node (); - no_body_function = in_lto_p && (cnode->alias || cnode->body_removed); - } - - if(!m_removed_items_set.contains (m_items[i]->node) - && !no_body_function) - { - if (item->type == VAR || (!DECL_CXX_CONSTRUCTOR_P (item->decl) - && !DECL_CXX_DESTRUCTOR_P (item->decl))) - { - filtered.safe_push (m_items[i]); - continue; - } - } - - remove_item (item); + bool no_body_function = in_lto_p && (cnode->alias || cnode->body_removed); + if (no_body_function || !opt_for_fn (item->decl, flag_ipa_icf_functions) + || DECL_CXX_CONSTRUCTOR_P (item->decl) + || DECL_CXX_DESTRUCTOR_P (item->decl)) + remove_item (item); + else + filtered.safe_push (item); + } + else /* VAR. */ + { + if (!flag_ipa_icf_variables) + remove_item (item); + else + filtered.safe_push (item); + } } /* Clean-up of released semantic items. */ -- 2.1.2