> jemarch@termi:~/gnu/src/gcc-git/build-bpf/gcc$ PATH=.:$PATH ./xgcc -O2 -c 
/home/jemarch/gnu/src/gcc-git/gcc/testsuite/gcc.c-torture/compile/pr39928-2.c
    > during RTL pass: ira
    > 
/home/jemarch/gnu/src/gcc-git/gcc/testsuite/gcc.c-torture/compile/pr39928-2.c: 
In function ‘vq_nbest’:
    > 
/home/jemarch/gnu/src/gcc-git/gcc/testsuite/gcc.c-torture/compile/pr39928-2.c:8:1:
 internal compiler error: Segmentation fault
    >     8 | }
    >       | ^
    > 0xfa8cb7 crash_signal
    >   ../../gcc/toplev.c:326
    > 0x7f278d44e05f ???
    >   
/build/glibc-yWQXbR/glibc-2.24/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
    > 0xd4ec8b update_costs_from_allocno
    >   ../../gcc/ira-color.c:1382
    > 0xd4ee09 update_costs_from_prefs
    >   ../../gcc/ira-color.c:1422
    > 0xd535d9 color_allocnos
    >   ../../gcc/ira-color.c:3170
    > 0xd53e21 color_pass
    >   ../../gcc/ira-color.c:3309
    > 0xd39b10 ira_traverse_loop_tree(bool, ira_loop_tree_node*, void 
(*)(ira_loop_tree_node*), void (*)(ira_loop_tree_node*))
    >   ../../gcc/ira-build.c:1781
    > 0xd54703 do_coloring
    >   ../../gcc/ira-color.c:3460
    > 0xd58203 color
    >   ../../gcc/ira-color.c:4837
    > 0xd58746 ira_color()
    >   ../../gcc/ira-color.c:4968
    > 0xd34990 ira
    >   ../../gcc/ira.c:5365
    > 0xd35118 execute
    >   ../../gcc/ira.c:5663
    > Please submit a full bug report,
    > with preprocessed source if appropriate.
    > Please include the complete backtrace with any bug report.
    > See <https://gcc.gnu.org/bugs/> for instructions.
    
    Yeah, this looks like a bug.  Further up we have:
    
          mode = ALLOCNO_MODE (allocno);
          ira_init_register_move_cost_if_necessary (mode);
    
    which copes with the lazy initialisation.  But then we have:
    
          mode = narrower_subreg_mode (mode, ALLOCNO_MODE (cp->second));
          
          cost = (cp->second == allocno
                  ? ira_register_move_cost[mode][rclass][aclass]
                  : ira_register_move_cost[mode][aclass][rclass]);
    
    where we can change the mode without initialising the move cost tables.
    Does it work if you change it to:
    
          if (paradoxical_subreg_p (mode, ALLOCNO_MODE (cp->second)))
            {
              mode = ALLOCNO_MODE (cp->second);
              ira_init_register_move_cost_if_necessary (mode);
            }
    
    ?  The mode handling seems generally a bit weird though: we never
    reset "mode" when processing the next copy, and "cp->second" might
    be "allocno" itself, depending on which way round the move is.
    But the above seems like an obvious change relative to the status quo.
    
That change fixes the segfault :)

Reply via email to