This is the mail archive of the
mailing list for the GCC project.
- From: Richard Guenther <rguenther at suse dot de>
- To: Jan Hubicka <hubicka at ucw dot cz>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 6 Jul 2010 11:23:50 +0200 (CEST)
- References: <20100705235036.GC12132@kam.mff.cuni.cz>
On Tue, 6 Jul 2010, Jan Hubicka wrote:
> -fwhole-program and WHOPR. The problem here is that cloning causes
> devirtualization. This devirtualization is recognized during virtual clone
> materialization (i.e. late) because Martin did not merge his IPA
> devritualization code yet.
> Because WHOPR brings the function static and house it in different file
> than the devirtualized call, we get undefined symbol on the partition.
> This problem is not limited to WHOPR only. Same problem can appear in
> normal compilation when call to COMDAT function is devirtualized after
> COMDAT was declared dead.
> This patch adds neccesary checking and prevents devirtualization when we
> can't anymore.
Hm, I don't understand. When there is a virtual call we should still
have the functions address taken and thus cannot eliminate it. So
why can this be a problem? At least I don't see how it can be for
non-WHOPR. COMDAT cannot be declared dead when there is still a
virtual call to it.
What am I missing?
> Bootstrapped/regtested x86_64-linux, OK?
> * gimple-fold.c (gimple_fold_obj_type_ref_known_binfo): Check that
> function is still available to fold into.
> Index: gimple-fold.c
> --- gimple-fold.c (revision 161847)
> +++ gimple-fold.c (working copy)
> @@ -1351,6 +1351,7 @@ gimple_fold_obj_type_ref_known_binfo (HO
> HOST_WIDE_INT i;
> tree v, fndecl;
> + struct cgraph_node *node;
> v = BINFO_VIRTUALS (known_binfo);
> i = 0;
> @@ -1362,6 +1363,14 @@ gimple_fold_obj_type_ref_known_binfo (HO
> fndecl = TREE_VALUE (v);
> + node = cgraph_get_node (fndecl);
> + /* When cgraph node is missing and function is public, we can not
> + devirtualize. This can happen in WHOPR when the actual method
> + ends up in other partition, because we found devirtualization
> + possibility too late. */
> + if ((!node || !node->analyzed)
> + && (!TREE_PUBLIC (fndecl) || DECL_COMDAT (fndecl)))
> + return NULL;
> return build_fold_addr_expr (fndecl);
Richard Guenther <firstname.lastname@example.org>
Novell / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746 - GF: Markus Rex