df: Fix up handling of paradoxical subregs in debug insns [PR101170]
authorJakub Jelinek <jakub@redhat.com>
Thu, 24 Jun 2021 10:24:48 +0000 (12:24 +0200)
committerJakub Jelinek <jakub@redhat.com>
Thu, 24 Jun 2021 10:24:48 +0000 (12:24 +0200)
commit9872bd8c35be0f4d475fac739115cf5b82cdabc0
treeccf9f8ec9fab3fc57077c6b23da5dcbaeca6cfe8
parent65371066d8967560e3508af4a804e0ddb90acee7
df: Fix up handling of paradoxical subregs in debug insns [PR101170]

The recent addition of gcc_assert (regno < endregno); triggers during
glibc build on m68k.
The problem is that RA decisions shouldn't depend on expressions in
DEBUG_INSNs and those expressions can contain paradoxical subregs of certain
pseudos.  If RA then decides to allocate the pseudo to a register
with very small hard register REGNO, we can trigger the new assert,
as (int) subreg_regno_offset may be negative on big endian and the small
REGNO + the negative offset can wrap around.

The following patch in that case records the range from the REGNO 0 to
endregno, before the addition of the assert as both regno and endregno are
unsigned it wouldn't record anything at all silently.

2021-06-24  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/101170
* df-scan.c (df_ref_record): For paradoxical big-endian SUBREGs
where regno + subreg_regno_offset wraps around use 0 as starting
regno.

* gcc.dg/pr101170.c: New test.
gcc/df-scan.c
gcc/testsuite/gcc.dg/pr101170.c [new file with mode: 0644]