Reported by t.w. lefering by email: ------------------------------------------------------------ Using GCC snapshot gcc-6-20160410.tar.bz2 and the -fdump-tree-all-graph option to generate graph data internal gcc error happens when compiling Linux sparse: parse.c:1362:22: internal compiler error: in operator[], at vec.h:714 in tree-ssa-structalias.c line 1212 is build_pred_graph() at line 1229 the get_varinfo() using vec.h routines hits the internal compiler error: for (j = 1; j < FIRST_REF_NODE; j++) { if (!get_varinfo (j)->is_special_var) bitmap_set_bit (graph->direct_nodes, j); } Looks like the variable j gets out-of-range then hit this assert in vec.h:714 in vec.h: template<typename T, typename A> inline T & vec<T, A, vl_embed>::operator[] (unsigned ix) { gcc_checking_assert (ix < m_vecpfx.m_num); return m_vecdata[ix]; } And this is in the generated output: parse.c: In function 'const_qualifier': parse.c:1362:22: internal compiler error: in operator[], at vec.h:714 static struct token *const_qualifier(struct token *next, struct decl_state *ctx) ^~~~~~~~~~~~~~~ 0xce89e7 vec<variable_info*, va_heap, vl_embed>::operator[](unsigned int) ../.././gcc/vec.h:714 0xce89e7 vec<variable_info*, va_heap, vl_ptr>::operator[](unsigned int) ../.././gcc/vec.h:1180 0xce89e7 get_varinfo ../.././gcc/tree-ssa-structalias.c:333 0xcf7cd7 get_varinfo ../.././gcc/vec.h:714 0xcf7cd7 build_pred_graph ../.././gcc/tree-ssa-structalias.c:1231 0xcf7cd7 solve_constraints ../.././gcc/tree-ssa-structalias.c:6961 0xcf9593 compute_points_to_sets ../.././gcc/tree-ssa-structalias.c:7062 0xcf9593 compute_may_aliases() ../.././gcc/tree-ssa-structalias.c:7389 0xa5afdc execute_function_todo ../.././gcc/passes.c:1930 0xa5baab execute_todo ../.././gcc/passes.c:2010 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. ------------------------------------------------------------
Created attachment 38294 [details] parse.i
Confirmed using: ... $ gcc -O3 parse.i -fdump-tree-all-graph ...
Can't really bisect this one. This particular ICE started with r215016, but with r215015 I see another ICE: $ ./cc1.215015 -quiet ~/x.i -fdump-tree-all-graph -O3 parse.c: In function ‘type_is_ok.isra.0’: parse.c:2837:1: internal compiler error: in get_loop_body, at cfgloop.c:835 0x772ce6 get_loop_body(loop const*) ../../gcc/cfgloop.c:835 0x1361812 draw_cfg_nodes_for_loop ../../gcc/graph.c:218 0x1361914 draw_cfg_nodes ../../gcc/graph.c:242 0x1361a5c print_graph_cfg(char const*, function*) ../../gcc/graph.c:287 0xaf3f9a execute_function_dump ../../gcc/passes.c:1557 0xaf3c15 do_per_function ../../gcc/passes.c:1478 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions.
struct S { long m; }; struct S fn1 (struct S *a) { if (a->m) a->m |= 2; return *a; }
(gdb) p varmap.length() $5 = 13 (gdb) p n $6 = 21 so yeah - we're out-of-range.
Could be just --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -2241,7 +2241,11 @@ dump_pred_graph (struct scc_info *si, FILE *file) if (graph->points_to[i] && !bitmap_empty_p (graph->points_to[i])) { - fprintf (file, "[label=\"%s = {", get_varinfo (i)->name); + if (i < FIRST_REF_NODE) + fprintf (file, "[label=\"%s = {", get_varinfo (i)->name); + else + fprintf (file, "[label=\"*%s = {", + get_varinfo (i - FIRST_REF_NODE)->name); unsigned j; bitmap_iterator bi; EXECUTE_IF_SET_IN_BITMAP (graph->points_to[i], 0, j, bi) but someone would need to check whether we still print a correct info with this.
(In reply to Marek Polacek from comment #6) > Could be just > > --- a/gcc/tree-ssa-structalias.c > +++ b/gcc/tree-ssa-structalias.c > @@ -2241,7 +2241,11 @@ dump_pred_graph (struct scc_info *si, FILE *file) > if (graph->points_to[i] > && !bitmap_empty_p (graph->points_to[i])) > { > - fprintf (file, "[label=\"%s = {", get_varinfo (i)->name); > + if (i < FIRST_REF_NODE) > + fprintf (file, "[label=\"%s = {", get_varinfo (i)->name); > + else > + fprintf (file, "[label=\"*%s = {", > + get_varinfo (i - FIRST_REF_NODE)->name); > unsigned j; > bitmap_iterator bi; > EXECUTE_IF_SET_IN_BITMAP (graph->points_to[i], 0, j, bi) > > but someone would need to check whether we still print a correct info with > this. I've build the compiler with the patch, compiled the example from comment 4, extracted the dot files using the script mentioned in PR70221 and generated pdf files from those. They look ok to me. Also, the patch itself looks good to me.
Created attachment 38386 [details] proposed patch Patch with testcase included. I'll put this through testing.
Yep, the patch looks ok and pre-approved.
Author: vries Date: Mon May 2 07:42:06 2016 New Revision: 235700 URL: https://gcc.gnu.org/viewcvs?rev=235700&root=gcc&view=rev Log: Fix ICE in dump_pred_graph 2016-05-02 Marek Polacek <polacek@redhat.com> Tom de Vries <tom@codesourcery.com> PR tree-optimization/70700 * tree-ssa-structalias.c (dump_pred_graph): Fix getting varinfo for ids bigger than FIRST_REF_NODE. * gcc.dg/pr70700.c: New test. Added: trunk/gcc/testsuite/gcc.dg/pr70700.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-ssa-structalias.c
Patch with testcase committed, marking resolved-fixed.