From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3292 invoked by alias); 17 Apr 2011 14:58:38 -0000 Received: (qmail 3282 invoked by uid 22791); 17 Apr 2011 14:58:38 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 17 Apr 2011 14:58:23 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 7958FCB0248 for ; Sun, 17 Apr 2011 16:58:22 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FTU0DupPQxin for ; Sun, 17 Apr 2011 16:58:19 +0200 (CEST) Received: from [192.168.1.2] (bon31-9-83-155-120-49.fbx.proxad.net [83.155.120.49]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 6CC51CB01DD for ; Sun, 17 Apr 2011 16:58:19 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: Fix PR lto/48538 Date: Sun, 17 Apr 2011 15:36:00 -0000 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_q/vqN2EmCX9Hq9F" Message-Id: <201104171657.46523.ebotcazou@adacore.com> Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-04/txt/msg01323.txt.bz2 --Boundary-00=_q/vqN2EmCX9Hq9F Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 1634 This fixes profiled LTO bootstrap with Ada enabled on the 4.6 branch. The bug is a segfault in merge_profile_summaries: Program received signal SIGSEGV, Segmentation fault. merge_profile_summaries (file_data_vec=0x7ffff18c9000) at /home/eric/svn/gcc-4_6-branch/gcc/lto-cgraph.c:1504 1504 if (node->local.lto_file_data->profile_info.runs) (gdb) p debug_generic_expr(node->decl) gnat1drv__check_library_items gdb) p node->local.lto_file_data $4 = (struct lto_file_decl_data *) 0x0 It turns out that the other accesses to node->local.lto_file_data are guarded, for example in materialize_cgraph: for (node = cgraph_nodes; node; node = node->next) { if (node->local.lto_file_data) { lto_materialize_function (node); lto_stats.num_input_cgraph_nodes++; } } The reason is given in a comment in input_cgraph: /* Some nodes may have been created by cgraph_node. This happens when the callgraph contains nested functions. If the node for the parent function was never emitted to the gimple file, cgraph_node will create a node for it when setting the context of the nested function. */ if (node->local.lto_file_data) node->aux = NULL; In this case, the nested function is gnat1drv__check_library_items__action. Fixed by adding the missing guard, profiled-LTO-bootstrapped on x86_64/Linux, applied on the mainline and 4.6 branch as obvious. 2011-04-17 Eric Botcazou PR lto/48538 * lto-cgraph.c (merge_profile_summaries): Check that lto_file_data is non-null before accessing it. (input_cgraph): Remove trailing spaces. -- Eric Botcazou --Boundary-00=_q/vqN2EmCX9Hq9F Content-Type: text/x-diff; charset="iso 8859-15"; name="p.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="p.diff" Content-length: 873 Index: lto-cgraph.c =================================================================== --- lto-cgraph.c (revision 172603) +++ lto-cgraph.c (working copy) @@ -1463,7 +1463,8 @@ merge_profile_summaries (struct lto_file During LTRANS we already have values of count_materialization_scale computed, so just update them. */ for (node = cgraph_nodes; node; node = node->next) - if (node->local.lto_file_data->profile_info.runs) + if (node->local.lto_file_data + && node->local.lto_file_data->profile_info.runs) { int scale; @@ -1535,8 +1536,8 @@ input_cgraph (void) VEC_free (cgraph_node_ptr, heap, nodes); VEC_free (varpool_node_ptr, heap, varpool); } + merge_profile_summaries (file_data_vec); - /* Clear out the aux field that was used to store enough state to tell which nodes should be overwritten. */ --Boundary-00=_q/vqN2EmCX9Hq9F--