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