This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix undefined symbols in WHOPR build of Mozilla's javascript interpretter


On Tue, 6 Jul 2010, Jan Hubicka wrote:

> Hi,
> this patch solves problem with building Mozilla javascript shell with
> -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?

Richard.

> Bootstrapped/regtested x86_64-linux, OK?
> 
> Honza
> 
> 	* 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 <rguenther@suse.de>
Novell / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746 - GF: Markus Rex


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]