https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66229
Bug ID: 66229 Summary: LTO fails with -fauto-profile on mcf Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto Assignee: hubicka at gcc dot gnu.org Reporter: spop at gcc dot gnu.org CC: dehao at gcc dot gnu.org, hiraditya at msn dot com Target Milestone: --- lto1: internal compiler error: in compute_working_sets, at gcov-io.c:1006 0x790dad compute_working_sets(gcov_ctr_summary const*, gcov_working_set_info*) ../../gcc/gcov-io.c:1006 0xba0faa get_working_sets() ../../gcc/profile.c:264 0xaf0ac7 input_symtab() ../../gcc/lto-cgraph.c:1880 0x6c3da0 read_cgraph_and_symbols ../../gcc/lto/lto.c:3061 0x6c4be9 lto_main() ../../gcc/lto/lto.c:3479 MCF from SPEC 2006 on x86_64-linux and other programs would fail with LTO + AutoFDO with the following flags: COPTIMIZE = -Ofast -g3 -fno-strict-aliasing -flto -fauto-profile=mcf_base.gcc43-64bit.gcov This fails with both trunk gcc and with the 5.1 release. Also fails with an empty profile. We collected the profile with create_gcov from a linux perf data. We ran gdb on lto1 and have seen that the crash happens in gcov reader of lto: gcc/gcov-io.c:1006 /* Compute the working set information from the counter histogram in the profile summary. This is an array of information corresponding to a range of percentages of the total execution count (sum_all), and includes the number of counters required to cover that working set percentage and the minimum counter value in that working set. */ GCOV_LINKAGE void compute_working_sets (const struct gcov_ctr_summary *summary, gcov_working_set_t *gcov_working_sets) { [...] /* Next, walk through the histogram in decending order of hotness and compute the statistics for the working set summary array. As histogram entries are accumulated, we check to see which working set entries have had their expected cum_value reached and fill them in, walking the working set entries in increasing size of cum_value. */ ws_ix = 0; /* The current entry into the working set array. */ cum = 0; /* The current accumulated counter sum. */ count = 0; /* The current accumulated count of block counters. */ for (h_ix = GCOV_HISTOGRAM_SIZE - 1; h_ix >= 0 && ws_ix < NUM_GCOV_WORKING_SETS; h_ix--) { histo_bucket = &summary->histogram[h_ix]; /* If we haven't reached the required cumulative counter value for the current working set percentage, simply accumulate this histogram entry into the running sums and continue to the next histogram entry. */ if (cum + histo_bucket->cum_value < working_set_cum_values[ws_ix]) { cum += histo_bucket->cum_value; count += histo_bucket->num_counters; continue; } [Here continue is always taken such that ws_ix never gets incremented.] [...] } gcov_nonruntime_assert (ws_ix == NUM_GCOV_WORKING_SETS); [And this would assert because ws_ix is still 0.]