https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91683

Jim Wilson <wilson at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2019-09-06
                 CC|                            |wilson at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |wilson at gcc dot 
gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Jim Wilson <wilson at gcc dot gnu.org> ---
Created attachment 46850
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46850&action=edit
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.

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.

Reply via email to