public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/103163] New: stack_limit_rtx is created too early
@ 2021-11-10  2:48 sandra at gcc dot gnu.org
  2021-11-17  7:36 ` [Bug middle-end/103163] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: sandra at gcc dot gnu.org @ 2021-11-10  2:48 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103163
           Summary: stack_limit_rtx is created too early
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: other
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sandra at gcc dot gnu.org
  Target Milestone: ---

stack_limit_rtx is initialized in init_emit_once() before
init_reg_modes_target() is called to fill in the table for hard_regno_nregs. 
For -fstack-limit-register, this means the REG is created with a zero nregs
field, and this ends up tripping over the assertion in df_ref_record while
processing prologue instructions using stack_limit_rtx.

I observed this in a nios2-elf build, where the testcase 
gcc.target/nios2/nios2-stack-check-1.c is ICE'ing:

$ nios2-elf-gcc
/scratch/sandra/nios2-elf-fsf/src/gcc-mainline/gcc/testsuite/gcc.target/nios2/nios2-stack-check-1.c
-fdiagnostics-plain-output -fstack-limit-register=et -ffat-lto-objects
-fno-ident -S -o nios2-stack-check-1.s
during RTL pass: pro_and_epilogue
/scratch/sandra/nios2-elf-fsf/src/gcc-mainline/gcc/testsuite/gcc.target/nios2/nios2-stack-check-1.c:
In function 'test':
/scratch/sandra/nios2-elf-fsf/src/gcc-mainline/gcc/testsuite/gcc.target/nios2/nios2-stack-check-1.c:10:1:
internal compiler error: in df_ref_record, at df-scan.c:2610
0xecb4e2 df_ref_record
        /scratch/sandra/nios2-elf-fsf/src/gcc-mainline/gcc/df-scan.c:2610
0xecbd10 df_uses_record
        /scratch/sandra/nios2-elf-fsf/src/gcc-mainline/gcc/df-scan.c:2869
0xecc1af df_uses_record
        /scratch/sandra/nios2-elf-fsf/src/gcc-mainline/gcc/df-scan.c:3045
0xecca08 df_insn_refs_collect
        /scratch/sandra/nios2-elf-fsf/src/gcc-mainline/gcc/df-scan.c:3224
0xec774a df_insn_rescan(rtx_insn*)
        /scratch/sandra/nios2-elf-fsf/src/gcc-mainline/gcc/df-scan.c:1087
0xf69280 emit_insn_after_1
        /scratch/sandra/nios2-elf-fsf/src/gcc-mainline/gcc/emit-rtl.c:4598
0xf69439 emit_pattern_after_noloc
        /scratch/sandra/nios2-elf-fsf/src/gcc-mainline/gcc/emit-rtl.c:4646
0xf694a0 emit_insn_after_noloc(rtx_def*, rtx_insn*, basic_block_def*)
        /scratch/sandra/nios2-elf-fsf/src/gcc-mainline/gcc/emit-rtl.c:4670
0xe59262 commit_one_edge_insertion(edge_def*)
        /scratch/sandra/nios2-elf-fsf/src/gcc-mainline/gcc/cfgrtl.c:2051
0xe593ea commit_edge_insertions()
        /scratch/sandra/nios2-elf-fsf/src/gcc-mainline/gcc/cfgrtl.c:2103
0x105b646 thread_prologue_and_epilogue_insns()
        /scratch/sandra/nios2-elf-fsf/src/gcc-mainline/gcc/function.c:6160
0x105c1cc rest_of_handle_thread_prologue_and_epilogue
        /scratch/sandra/nios2-elf-fsf/src/gcc-mainline/gcc/function.c:6534
0x105c3ac execute
        /scratch/sandra/nios2-elf-fsf/src/gcc-mainline/gcc/function.c:6610
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

I think I could hack around this by having the nios2 backend create a fresh REG
instead of using stack_limit_rtx directly in the prologue, but that does seem
like a hack instead of a proper fix....  Also, it looks like the bfin, m68k,
and rs6000 backends use stack_pointer_rtx too and probably have similar issues.

Looks like the assert was introduced in commit
7232f7c4c2d727431096a7ecfcf4ad4db71dcf2a but the underlying problem probably
long predates that (it's just that nothing was tripping over it in such an
obvious way).

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

* [Bug middle-end/103163] stack_limit_rtx is created too early
  2021-11-10  2:48 [Bug other/103163] New: stack_limit_rtx is created too early sandra at gcc dot gnu.org
@ 2021-11-17  7:36 ` pinskia at gcc dot gnu.org
  2021-11-17  7:40 ` [Bug middle-end/103163] [12 Regression] " pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-17  7:36 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=48344,
                   |                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=101157

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Hmm, looks like it has been a bug for a long time really.
r6-6965-gecf835e90129 (PR48344) improved the situtation slightly.

Looks like the powerpc folks did report PR 101157 (right after
r12-1702-g7232f7c4c2d727431096a) which was the failure of
gcc.target/powerpc/pr48344-1.c but they reported it was fixed not far after the
failure ...

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

* [Bug middle-end/103163] [12 Regression] stack_limit_rtx is created too early
  2021-11-10  2:48 [Bug other/103163] New: stack_limit_rtx is created too early sandra at gcc dot gnu.org
  2021-11-17  7:36 ` [Bug middle-end/103163] " pinskia at gcc dot gnu.org
@ 2021-11-17  7:40 ` pinskia at gcc dot gnu.org
  2021-11-17  7:40 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-17  7:40 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|stack_limit_rtx is created  |[12 Regression]
                   |too early                   |stack_limit_rtx is created
                   |                            |too early
   Target Milestone|---                         |12.0
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-11-17
             Status|UNCONFIRMED                 |NEW

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #1)
> Looks like the powerpc folks did report PR 101157 (right after
> r12-1702-g7232f7c4c2d727431096a) which was the failure of
> gcc.target/powerpc/pr48344-1.c but they reported it was fixed not far after
> the failure ...

But still fails:
https://gcc.gnu.org/pipermail/gcc-testresults/2021-November/735755.html

The ICE is new on the trunk though.

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

* [Bug middle-end/103163] [12 Regression] stack_limit_rtx is created too early
  2021-11-10  2:48 [Bug other/103163] New: stack_limit_rtx is created too early sandra at gcc dot gnu.org
  2021-11-17  7:36 ` [Bug middle-end/103163] " pinskia at gcc dot gnu.org
  2021-11-17  7:40 ` [Bug middle-end/103163] [12 Regression] " pinskia at gcc dot gnu.org
@ 2021-11-17  7:40 ` pinskia at gcc dot gnu.org
  2022-01-17 12:59 ` [Bug middle-end/103163] [12 Regression] stack_limit_rtx is created too early causing nregs field on REG to be zero (gcc.target/nios2/nios2-stack-check-1.c and gcc.target/powerpc/stack-limit.c) rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-17  7:40 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |seurer at gcc dot gnu.org

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 101157 has been marked as a duplicate of this bug. ***

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

* [Bug middle-end/103163] [12 Regression] stack_limit_rtx is created too early causing nregs field on REG to be zero (gcc.target/nios2/nios2-stack-check-1.c and gcc.target/powerpc/stack-limit.c)
  2021-11-10  2:48 [Bug other/103163] New: stack_limit_rtx is created too early sandra at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-11-17  7:40 ` pinskia at gcc dot gnu.org
@ 2022-01-17 12:59 ` rguenth at gcc dot gnu.org
  2022-01-17 17:37 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-17 12:59 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Not sure how it became a regression in GCC 12, but it sure looks worth fixing.

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

* [Bug middle-end/103163] [12 Regression] stack_limit_rtx is created too early causing nregs field on REG to be zero (gcc.target/nios2/nios2-stack-check-1.c and gcc.target/powerpc/stack-limit.c)
  2021-11-10  2:48 [Bug other/103163] New: stack_limit_rtx is created too early sandra at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2022-01-17 12:59 ` [Bug middle-end/103163] [12 Regression] stack_limit_rtx is created too early causing nregs field on REG to be zero (gcc.target/nios2/nios2-stack-check-1.c and gcc.target/powerpc/stack-limit.c) rguenth at gcc dot gnu.org
@ 2022-01-17 17:37 ` pinskia at gcc dot gnu.org
  2022-01-18 17:29 ` cvs-commit at gcc dot gnu.org
  2022-01-18 17:32 ` sandra at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-17 17:37 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #4)
> Not sure how it became a regression in GCC 12, but it sure looks worth
> fixing.

I reported how the ice became a regression in comment #1. It used to not ice
before r12-1702 as the assert was added in that revision.

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

* [Bug middle-end/103163] [12 Regression] stack_limit_rtx is created too early causing nregs field on REG to be zero (gcc.target/nios2/nios2-stack-check-1.c and gcc.target/powerpc/stack-limit.c)
  2021-11-10  2:48 [Bug other/103163] New: stack_limit_rtx is created too early sandra at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2022-01-17 17:37 ` pinskia at gcc dot gnu.org
@ 2022-01-18 17:29 ` cvs-commit at gcc dot gnu.org
  2022-01-18 17:32 ` sandra at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-01-18 17:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Sandra Loosemore <sandra@gcc.gnu.org>:

https://gcc.gnu.org/g:3a0837b8fb96f50f2e60222ce289cc2542bbb477

commit r12-6693-g3a0837b8fb96f50f2e60222ce289cc2542bbb477
Author: Sandra Loosemore <sandra@codesourcery.com>
Date:   Tue Jan 18 09:27:36 2022 -0800

    middle-end: move initialization of stack_limit_rtx [PR103163]

    stack_limit_rtx was being initialized before init_reg_modes_target (),
    resulting in the REG expression being created incorrectly and an ICE
    later in compilation.

    2022-01-18  Sandra Loosemore  <sandra@codesourcery.com>

            PR middle-end/103163

            gcc/
            * emit-rtl.cc (init_emit_regs): Initialize stack_limit_rtx here...
            (init_emit_once): ...not here.

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

* [Bug middle-end/103163] [12 Regression] stack_limit_rtx is created too early causing nregs field on REG to be zero (gcc.target/nios2/nios2-stack-check-1.c and gcc.target/powerpc/stack-limit.c)
  2021-11-10  2:48 [Bug other/103163] New: stack_limit_rtx is created too early sandra at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2022-01-18 17:29 ` cvs-commit at gcc dot gnu.org
@ 2022-01-18 17:32 ` sandra at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: sandra at gcc dot gnu.org @ 2022-01-18 17:32 UTC (permalink / raw)
  To: gcc-bugs

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

sandra at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #7 from sandra at gcc dot gnu.org ---
Should be fixed now.

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

end of thread, other threads:[~2022-01-18 17:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-10  2:48 [Bug other/103163] New: stack_limit_rtx is created too early sandra at gcc dot gnu.org
2021-11-17  7:36 ` [Bug middle-end/103163] " pinskia at gcc dot gnu.org
2021-11-17  7:40 ` [Bug middle-end/103163] [12 Regression] " pinskia at gcc dot gnu.org
2021-11-17  7:40 ` pinskia at gcc dot gnu.org
2022-01-17 12:59 ` [Bug middle-end/103163] [12 Regression] stack_limit_rtx is created too early causing nregs field on REG to be zero (gcc.target/nios2/nios2-stack-check-1.c and gcc.target/powerpc/stack-limit.c) rguenth at gcc dot gnu.org
2022-01-17 17:37 ` pinskia at gcc dot gnu.org
2022-01-18 17:29 ` cvs-commit at gcc dot gnu.org
2022-01-18 17:32 ` sandra at gcc dot gnu.org

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).