* 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
2010-09-18 Jan Hubicka <jh@suse.cz>
+ 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.
+
+2010-09-18 Jan Hubicka <jh@suse.cz>
+
PR tree-optimization/45605
* cgraphunit.c (cgraph_analyze_functions): Allocate bitmap obstack.
* gimple-fold.c (static_object_in_other_unit_p): New function.
there. */
if ((TREE_PUBLIC (decl) && !DECL_COMDAT (decl) && !DECL_EXTERNAL (decl))
|| DECL_STATIC_CONSTRUCTOR (decl)
- || DECL_STATIC_DESTRUCTOR (decl))
+ || DECL_STATIC_DESTRUCTOR (decl)
+ /* COMDAT virtual functions may be referenced by vtable from
+ other compilatoin unit. Still we want to devirtualize calls
+ to those so we need to analyze them.
+ FIXME: We should introduce may edges for this purpose and update
+ their handling in unreachable function removal and inliner too. */
+ || (DECL_VIRTUAL_P (decl) && (DECL_COMDAT (decl) || DECL_EXTERNAL (decl))))
cgraph_mark_reachable_node (node);
/* If we've not yet emitted decl, tell the debug info about it. */
In that case just go ahead and re-use it. */
if (!e->callee->callers->next_caller
&& cgraph_can_remove_if_no_direct_calls_p (e->callee)
+ /* Inlining might enable more devirtualizing, so we want to remove
+ those only after all devirtualizable virtual calls are processed.
+ Lacking may edges in callgraph we just preserve them post
+ inlining. */
+ && (!DECL_VIRTUAL_P (e->callee->decl)
+ || (!DECL_COMDAT (e->callee->decl) && !DECL_EXTERNAL (e->callee->decl)))
/* Don't reuse if more than one function shares a comdat group.
If the other function(s) are needed, we need to emit even
this function out of line. */
}
TREE_TYPE (fndecl) = new_type;
+ DECL_VIRTUAL_P (fndecl) = 0;
if (otypes)
VEC_free (tree, heap, otypes);
VEC_free (tree, heap, oparms);
#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))
{
+2010-09-18 Jan Hubicka <jh@suse.cz>
+
+ PR tree-optimization/45453
+ * g++.dg/tree-ssa/pr45453.C: New testcase.
+
2010-09-18 Jason Merrill <jason@redhat.com>
* g++.dg/cpp0x/initlist44.C: New.
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+struct S
+{
+ S();
+ virtual inline void foo ()
+ {
+ foo();
+ }
+};
+
+void
+B ()
+{
+ S().foo ();
+}
+/* We should inline foo and devirtualize call to foo in the inlined version. */
+// { dg-final { scan-tree-dump-times "OBJ_TYPE_REF" 1 "optimized" } }
+// { dg-final { cleanup-tree-dump "optimized" } }