https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127084
--- Comment #1 from Senthil Kumar Selvaraj <saaadhu at gcc dot gnu.org> ---
The segfault happens when emit-rtl.cc::4375 add_insn_after does BB_END (bb). At
this time, bb->flags does not have BB_RTL set, and bb->il.x.rtx is NULL.
(gdb) p bb->il.x
$3 = {head_ = 0x7ffff7a0d990, rtl = 0x0}
(gdb) p bb->flags
$2 = 1
Because BB_END is defined as
#define BB_END(B) (B)->il.x.rtl->end_
the compiler segfaults.
The commit that introduces the failure is
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=8154fc95f097a146f9c80edcaafb2baff73065b5,
which deliberately delays recording BB_RTL/rtl for a BB. I guess it did not
account for mips16_gp_pseudo_reg inserting insns (and relying on BB_END being
available)?