public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Eric Botcazou <ebotcazou@adacore.com>
To: gcc-patches@gcc.gnu.org
Subject: Fix PR lto/48538
Date: Sun, 17 Apr 2011 15:36:00 -0000	[thread overview]
Message-ID: <201104171657.46523.ebotcazou@adacore.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1634 bytes --]

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  <ebotcazou@adacore.com>

	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

[-- Attachment #2: p.diff --]
[-- Type: text/x-diff, Size: 873 bytes --]

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.  */

                 reply	other threads:[~2011-04-17 14:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201104171657.46523.ebotcazou@adacore.com \
    --to=ebotcazou@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).