From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E3513385801A; Wed, 10 Nov 2021 02:48:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E3513385801A From: "sandra at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug other/103163] New: stack_limit_rtx is created too early Date: Wed, 10 Nov 2021 02:48:26 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: other X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: sandra at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Nov 2021 02:48:27 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103163 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= .=20 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=20 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/nio= s2/nios2-stack-check-1.c -fdiagnostics-plain-output -fstack-limit-register=3Det -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/nio= s2/nios2-stack-check-1.c: In function 'test': /scratch/sandra/nios2-elf-fsf/src/gcc-mainline/gcc/testsuite/gcc.target/nio= s2/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 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 se= em 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 iss= ues. 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).=