summaryrefslogtreecommitdiff
path: root/gcc/ipa.c
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2010-09-18 23:13:17 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2010-09-18 23:13:17 +0000
commitd050bafd156a2ec8ce1382590158b853acf1c6ee (patch)
tree863c05e9f2399d3ae354b494076e8a668b4ee323 /gcc/ipa.c
parent83428098eae0722871c4cd0ae3da93525757ce29 (diff)
downloadgcc-d050bafd156a2ec8ce1382590158b853acf1c6ee.tar.gz
PR tree-optimization/45453
* cgraphunit.c (cgraph_finalize_function): Consider comdat & external virtual functions are reachable. * ipa-inline.c (cgraph_clone_inlined_nodes): Likewise. * ipa.c (cgraph_remove_unreachable_nodes): Likewise. * ipa-prop.c (ipa_modify_formal_parameters): Clear DECL_VIRTUAL_P when modifying function. * g++.dg/tree-ssa/pr45453.C: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@164405 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ipa.c')
-rw-r--r--gcc/ipa.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/gcc/ipa.c b/gcc/ipa.c
index 8c0ca86d59d..e4835c1e03f 100644
--- a/gcc/ipa.c
+++ b/gcc/ipa.c
@@ -238,7 +238,12 @@ cgraph_remove_unreachable_nodes (bool before_inlining_p, FILE *file)
#endif
varpool_reset_queue ();
for (node = cgraph_nodes; node; node = node->next)
- if (!cgraph_can_remove_if_no_direct_calls_and_refs_p (node)
+ if ((!cgraph_can_remove_if_no_direct_calls_and_refs_p (node)
+ /* Keep around virtual functions for possible devirtualization. */
+ || (!before_inlining_p
+ && !node->global.inlined_to
+ && DECL_VIRTUAL_P (node->decl)
+ && (DECL_COMDAT (node->decl) || DECL_EXTERNAL (node->decl))))
&& ((!DECL_EXTERNAL (node->decl))
|| before_inlining_p))
{