https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91683
--- Comment #2 from Zdenek Sojka <zsojka at seznam dot cz> --- (In reply to Jim Wilson from comment #1) > Created attachment 46850 [details] > proposed fix > > This is failing in undo_all in combine, trying to write to a pointer into > data that has been garbage collected. > > The problem starts with a riscv.md splitter which calls riscv_move_integer > which checks can_create_pseudo_p and calls force_reg if allowed. This > eventually calls gen_reg_rtx which calls ensure_regno_capacity which calls > ggc_realloc, which invalidates the data in the undo buffer since all pseudo > reg addresses change. I guess this is another reason why calling > gen_reg_rtx in a splitter is a bad idea. > > I can fix it by adding another option to riscv_move_integer to indicate when > we are calling it from inside a splitter, but maybe I will think of a better > way to fix the problem later. > Thank you for the patch! > The fact that this requires a ggc_realloc call to happen in a very precise > place means that this testcase does not appear to be very useful. There is > no guarantee it will trigger the problem if other parts of the compiler > change. Would --param=ggc-min-expand=0 and/or --param=ggc-min-heapsize=0 help to reproduce the issue?