From patchwork Mon Jul 5 23:50:36 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Fix undefined symbols in WHOPR build of Mozilla's javascript interpretter Date: Mon, 05 Jul 2010 13:50:36 -0000 From: Jan Hubicka X-Patchwork-Id: 57945 Message-Id: <20100705235036.GC12132@kam.mff.cuni.cz> To: gcc-patches@gcc.gnu.org, martinj@suse.cz, rguenther@suse.de 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. 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); }