[arm] PR target/82975: Guard against reg_renumber being NULL in arm.h
commita04aca05ac9ba27219dc856d01d8a51c1e8205b6
authorktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 19 Dec 2017 16:58:22 +0000 (19 16:58 +0000)
committerktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 19 Dec 2017 16:58:22 +0000 (19 16:58 +0000)
tree51e517e0af38cf0dea1b64d47ade9c0235f32191
parent7c4f5bdebdaaa6353583ef224842f014f575019a
[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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@255830 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/config/arm/arm.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr82975.c [new file with mode: 0644]