public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/102395] New: [nvptx, vax] enum reg_class inferred as signed / unsigned
@ 2021-09-18  7:53 jbglaw@lug-owl.de
  2021-09-18  8:01 ` [Bug middle-end/102395] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: jbglaw@lug-owl.de @ 2021-09-18  7:53 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102395
           Summary: [nvptx, vax] enum reg_class inferred as signed /
                    unsigned
           Product: gcc
           Version: analyzer branch
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jbglaw@lug-owl.de
  Target Milestone: ---

Created attachment 51477
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51477&action=edit
Testcase

Running automated testing, I get similar errors then building for
--target=nvptx-none and vax-linux using a fairly recent GCC version:

$ .../configure --target=nvptx-none \
                --enable-werror-always \
                --enable-languages=all \
                --disable-gcov \
                --disable-shared \
                --disable-threads \
                --without-headers
[..]
$ make all-gcc
[...]
[all 2021-09-13 12:37:11] /usr/lib/gcc-snapshot/bin/g++  -fno-PIE -c   -g -O2
-DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE   -fno-exceptions -fno-rtti
-fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings
-Wcast-qual -Wno-error=format-diag -Wmissing-format-attribute
-Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros
-Wno-overlength-strings -Werror -fno-common  -DHAVE_CONFIG_H -I. -I.
-I../../gcc/gcc -I../../gcc/gcc/. -I../../gcc/gcc/../include
-I../../gcc/gcc/../libcpp/include -I../../gcc/gcc/../libcody 
-I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd
-I../libdecnumber -I../../gcc/gcc/../libbacktrace   -o lra-constraints.o -MT
lra-constraints.o -MMD -MP -MF ./.deps/lra-constraints.TPo
../../gcc/gcc/lra-constraints.c
[all 2021-09-13 12:37:20] In function 'bool check_and_process_move(bool*,
bool*)',
[all 2021-09-13 12:37:20]     inlined from 'bool curr_insn_transform(bool)' at
../../gcc/gcc/lra-constraints.c:4092:33:
[all 2021-09-13 12:37:20] ../../gcc/gcc/lra-constraints.c:1317:56: error: array
subscript -1 is below array bounds of 'short int [2][16]'
[-Werror=array-bounds]
[all 2021-09-13 12:37:20]  1317 |       reg_renumber[dregno] =
ira_class_hard_regs[dclass][0];
[all 2021-09-13 12:37:20] In file included from
../../gcc/gcc/lra-constraints.c:123:
[all 2021-09-13 12:37:20] ../../gcc/gcc/ira.h: In function 'bool
curr_insn_transform(bool)':
[all 2021-09-13 12:37:20] ../../gcc/gcc/ira.h:85:9: note: while referencing
'target_ira::x_ira_class_hard_regs'
[all 2021-09-13 12:37:20]    85 |   short
x_ira_class_hard_regs[N_REG_CLASSES][FIRST_PSEUDO_REGISTER];
[all 2021-09-13 12:37:20]       |         ^~~~~~~~~~~~~~~~~~~~~
[all 2021-09-13 12:37:20] In function 'bool check_and_process_move(bool*,
bool*)',
[all 2021-09-13 12:37:20]     inlined from 'bool curr_insn_transform(bool)' at
../../gcc/gcc/lra-constraints.c:4092:33:
[all 2021-09-13 12:37:20] ../../gcc/gcc/lra-constraints.c:1324:56: error: array
subscript -1 is below array bounds of 'short int [2][16]'
[-Werror=array-bounds]
[all 2021-09-13 12:37:20]  1324 |       reg_renumber[sregno] =
ira_class_hard_regs[sclass][0];
[all 2021-09-13 12:37:20] In file included from
../../gcc/gcc/lra-constraints.c:123:
[all 2021-09-13 12:37:20] ../../gcc/gcc/ira.h: In function 'bool
curr_insn_transform(bool)':
[all 2021-09-13 12:37:20] ../../gcc/gcc/ira.h:85:9: note: while referencing
'target_ira::x_ira_class_hard_regs'
[all 2021-09-13 12:37:20]    85 |   short
x_ira_class_hard_regs[N_REG_CLASSES][FIRST_PSEUDO_REGISTER];
[all 2021-09-13 12:37:20]       |         ^~~~~~~~~~~~~~~~~~~~~
[all 2021-09-13 12:37:26] cc1plus: all warnings being treated as errors
[all 2021-09-13 12:37:26] make[1]: *** [Makefile:1142: lra-constraints.o] Error
1
[all 2021-09-13 12:37:26] make[1]: Leaving directory
'/var/lib/laminar/run/gcc-nvptx-none/8/toolchain-build/gcc'
[all 2021-09-13 12:37:26] make: *** [Makefile:4407: all-gcc] Error 2

(Initial report can be found at
https://gcc.gnu.org/pipermail/gcc/2021-September/237237.html)

Martin Sebor already had a look at it (cf.
https://gcc.gnu.org/pipermail/gcc/2021-September/237383.html) and suggested to
explicitely make reg_class an unsigned enum, or to add gcc_unreachable() for <
0 to indicate the non-negativeness of sclass/dclass.

Preprocessed / minimized testcase attached (based on --target=nvptx-none),
build with a recent GCC:

g++ -c -O2 -Wall -o lra-constraints.o lra-constraints.ii

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/102395] [nvptx, vax] enum reg_class inferred as signed / unsigned
  2021-09-18  7:53 [Bug middle-end/102395] New: [nvptx, vax] enum reg_class inferred as signed / unsigned jbglaw@lug-owl.de
@ 2021-09-18  8:01 ` pinskia at gcc dot gnu.org
  2021-09-18  8:05 ` pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-18  8:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Actually it might be easier to change line 1291:
  gcc_assert (sclass < LIM_REG_CLASSES);

to be:
  gcc_assert (sclass < LIM_REG_CLASSES && sclass >= 0);

I don't see how -1 is coming into play ...

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/102395] [nvptx, vax] enum reg_class inferred as signed / unsigned
  2021-09-18  7:53 [Bug middle-end/102395] New: [nvptx, vax] enum reg_class inferred as signed / unsigned jbglaw@lug-owl.de
  2021-09-18  8:01 ` [Bug middle-end/102395] " pinskia at gcc dot gnu.org
@ 2021-09-18  8:05 ` pinskia at gcc dot gnu.org
  2021-09-18  8:13 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-18  8:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Can you attach the original full preprocessed source?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/102395] [nvptx, vax] enum reg_class inferred as signed / unsigned
  2021-09-18  7:53 [Bug middle-end/102395] New: [nvptx, vax] enum reg_class inferred as signed / unsigned jbglaw@lug-owl.de
  2021-09-18  8:01 ` [Bug middle-end/102395] " pinskia at gcc dot gnu.org
  2021-09-18  8:05 ` pinskia at gcc dot gnu.org
@ 2021-09-18  8:13 ` pinskia at gcc dot gnu.org
  2021-09-18  8:17 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-18  8:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note your reduced testcase is no where near what the code looks like.

The code is like this:
if (!(sclass < LIM_REG_CLASSES))__builtin_unreachable();
if (slcass == ALL_REGS) return;
if (sclass != NO_REGS && g()) f(x_ira_class_hard_regs[slcass][0]);

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/102395] [nvptx, vax] enum reg_class inferred as signed / unsigned
  2021-09-18  7:53 [Bug middle-end/102395] New: [nvptx, vax] enum reg_class inferred as signed / unsigned jbglaw@lug-owl.de
                   ` (2 preceding siblings ...)
  2021-09-18  8:13 ` pinskia at gcc dot gnu.org
@ 2021-09-18  8:17 ` pinskia at gcc dot gnu.org
  2021-09-18  8:19 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-18  8:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #1)
> Actually it might be easier to change line 1291:
>   gcc_assert (sclass < LIM_REG_CLASSES);
> 
> to be:
>   gcc_assert (sclass < LIM_REG_CLASSES && sclass >= NO_REGS);
> 
> I don't see how -1 is coming into play ...



So the requirement is NO_REGS first is documented in tm.texi so
gcc_assert (sclass < LIM_REG_CLASSES && sclass >= NO_REGS);

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/102395] [nvptx, vax] enum reg_class inferred as signed / unsigned
  2021-09-18  7:53 [Bug middle-end/102395] New: [nvptx, vax] enum reg_class inferred as signed / unsigned jbglaw@lug-owl.de
                   ` (3 preceding siblings ...)
  2021-09-18  8:17 ` pinskia at gcc dot gnu.org
@ 2021-09-18  8:19 ` pinskia at gcc dot gnu.org
  2021-09-18  9:40 ` jbglaw@lug-owl.de
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-18  8:19 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |pinskia at gcc dot gnu.org
   Last reconfirmed|                            |2021-09-18
     Ever confirmed|0                           |1

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 51478
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51478&action=edit
Patch

This patch should fix the issue.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/102395] [nvptx, vax] enum reg_class inferred as signed / unsigned
  2021-09-18  7:53 [Bug middle-end/102395] New: [nvptx, vax] enum reg_class inferred as signed / unsigned jbglaw@lug-owl.de
                   ` (4 preceding siblings ...)
  2021-09-18  8:19 ` pinskia at gcc dot gnu.org
@ 2021-09-18  9:40 ` jbglaw@lug-owl.de
  2021-09-19  3:51 ` pinskia at gcc dot gnu.org
  2021-09-19  8:02 ` jbglaw@lug-owl.de
  7 siblings, 0 replies; 9+ messages in thread
From: jbglaw@lug-owl.de @ 2021-09-18  9:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Jan-Benedict Glaw <jbglaw@lug-owl.de> ---
I'll fetch that patch and stuff it in the autobuilder, then let it run for
nvptx, vax and a few others.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/102395] [nvptx, vax] enum reg_class inferred as signed / unsigned
  2021-09-18  7:53 [Bug middle-end/102395] New: [nvptx, vax] enum reg_class inferred as signed / unsigned jbglaw@lug-owl.de
                   ` (5 preceding siblings ...)
  2021-09-18  9:40 ` jbglaw@lug-owl.de
@ 2021-09-19  3:51 ` pinskia at gcc dot gnu.org
  2021-09-19  8:02 ` jbglaw@lug-owl.de
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-19  3:51 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.0
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed:
https://gcc.gnu.org/pipermail/gcc-cvs/2021-September/353733.html

I forgot to include the PR # in the changelog part.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/102395] [nvptx, vax] enum reg_class inferred as signed / unsigned
  2021-09-18  7:53 [Bug middle-end/102395] New: [nvptx, vax] enum reg_class inferred as signed / unsigned jbglaw@lug-owl.de
                   ` (6 preceding siblings ...)
  2021-09-19  3:51 ` pinskia at gcc dot gnu.org
@ 2021-09-19  8:02 ` jbglaw@lug-owl.de
  7 siblings, 0 replies; 9+ messages in thread
From: jbglaw@lug-owl.de @ 2021-09-19  8:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Jan-Benedict Glaw <jbglaw@lug-owl.de> ---
Autobuilder also picked it, fixed for all.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-09-19  8:02 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-18  7:53 [Bug middle-end/102395] New: [nvptx, vax] enum reg_class inferred as signed / unsigned jbglaw@lug-owl.de
2021-09-18  8:01 ` [Bug middle-end/102395] " pinskia at gcc dot gnu.org
2021-09-18  8:05 ` pinskia at gcc dot gnu.org
2021-09-18  8:13 ` pinskia at gcc dot gnu.org
2021-09-18  8:17 ` pinskia at gcc dot gnu.org
2021-09-18  8:19 ` pinskia at gcc dot gnu.org
2021-09-18  9:40 ` jbglaw@lug-owl.de
2021-09-19  3:51 ` pinskia at gcc dot gnu.org
2021-09-19  8:02 ` jbglaw@lug-owl.de

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).