public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Fix PR lto/48538
@ 2011-04-17 15:36 Eric Botcazou
  0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2011-04-17 15:36 UTC (permalink / raw)
  To: gcc-patches

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-04-17 14:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-17 15:36 Fix PR lto/48538 Eric Botcazou

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).