[Bug target/82975] [6/7/8 Regression] ICE in baseness at rtlanal.c:6220

2017-12-19 Thread ktkachov at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82975

--- Comment #6 from ktkachov at gcc dot gnu.org ---
Author: ktkachov
Date: Tue Dec 19 16:58:22 2017
New Revision: 255830

URL: https://gcc.gnu.org/viewcvs?rev=255830=gcc=rev
Log:
[arm] PR target/82975: Guard against reg_renumber being NULL in arm.h

In this bug we ICE when checking REGNO_OK_FOR_INDEX_P on arm during pre-IRA
scheduling.
This is because REGNO_OK_FOR_INDEX_P ends up checking the reg_renumber array.
Before IRA reg_renumber is NULL and thus we segfault.

The fix is to guard the use of reg_renumber in the logic in TEST_REGNO in
arm.h.
On aarch64, for example, we also guard against the reg_renumber == NULL case.
This fixes the ICE. I also remove the part of the comment that muses on when
reg_renumber
is available as with this patch it should now be safe to use at any point.

Bootstrapped and tested on arm-none-linux-gnueabihf.

PR target/82975
* config/arm/arm.h (TEST_REGNO): Check reg_renumber is set before
accessing it.  Adjust comment.

* gcc.dg/pr82975.c: New test.

Added:
trunk/gcc/testsuite/gcc.dg/pr82975.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/config/arm/arm.h
trunk/gcc/testsuite/ChangeLog

[Bug target/82975] [6/7/8 Regression] ICE in baseness at rtlanal.c:6220

2017-12-18 Thread ktkachov at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82975

ktkachov at gcc dot gnu.org changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |ktkachov at gcc dot 
gnu.org

--- Comment #5 from ktkachov at gcc dot gnu.org ---
This is indeed an arm target issue. As part of the computation in rtlanal.c it
uses REGNO_OK_FOR_INDEX_P which for arm eventually expands to something
referencing reg_renumber. But during sched1 (where we ICE) we haven't run IRA
yet to setup reg_renumber, so it's NULL at that point, causing the segfault. We
should guard against that case in the definition of REGNO_OK_FOR_INDEX_P and
REGNO_MODE_OK_FOR_BASE_P.

The aarch64 port, for example, bails out when reg_renumber is not set.

Testing a simple patch.

[Bug target/82975] [6/7/8 Regression] ICE in baseness at rtlanal.c:6220

2017-12-18 Thread ktkachov at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82975

ktkachov at gcc dot gnu.org changed:

   What|Removed |Added

   Priority|P3  |P2
   Last reconfirmed|2017-11-23 00:00:00 |2017-12-18
 CC||ktkachov at gcc dot gnu.org
  Known to work||4.9.4
Summary|ICE in baseness at  |[6/7/8 Regression] ICE in
   |rtlanal.c:6220  |baseness at rtlanal.c:6220
  Known to fail||5.4.1, 6.4.1, 7.2.1, 8.0

--- Comment #4 from ktkachov at gcc dot gnu.org ---
I've reproduced this ICE with the options Martin provided on arm-none-eabi
cross compilers from GCC 5 onwards. 4.9 doesn't ICE for me. I think 4.9 didn't
have the autopref scheduling stuff.

It's not clear if this is an rtl-optimization or a target issue, but needs to
be looked at anyway.