Bug 104989 - [11 Regression] ICE in rtl_verify_bb_insns, at cfgrtl.cc:2797 (error: flow control insn inside a basic block)
Summary: [11 Regression] ICE in rtl_verify_bb_insns, at cfgrtl.cc:2797 (error: flow co...
Status: ASSIGNED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 12.0
: P3 normal
Target Milestone: 11.5
Assignee: Jakub Jelinek
URL:
Keywords: error-recovery, ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2022-03-20 04:29 UTC by Arseny Solokha
Modified: 2023-07-07 10:42 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 7.5.0
Known to fail: 10.3.0, 11.2.0, 12.0, 8.5.0, 9.4.0
Last reconfirmed: 2022-03-21 00:00:00


Attachments
gcc12-pr104989.patch (995 bytes, patch)
2022-03-21 10:34 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Arseny Solokha 2022-03-20 04:29:51 UTC
g++ 12.0.1 20220313 snapshot (g:7e28750395889d16a9cba49cd5935ced7dc00ce8) ICEs when compiling gcc/testsuite/g++.dg/other/pr84964.C w/ -fnon-call-exceptions:

% g++-12.0.1 -fchecking -fnon-call-exceptions -w gcc/testsuite/g++.dg/other/pr84964.C
gcc/testsuite/g++.dg/other/pr84964.C: In function 'void c(...)':
gcc/testsuite/g++.dg/other/pr84964.C:6:16: sorry, unimplemented: passing too large argument on stack
    6 | void c(...) { c(a()); }
      |               ~^~~~~
gcc/testsuite/g++.dg/other/pr84964.C:6:23: error: in basic block 2:
    6 | void c(...) { c(a()); }
      |                       ^
gcc/testsuite/g++.dg/other/pr84964.C:6:23: error: flow control insn inside a basic block
(call_insn 9 8 14 2 (call (mem:QI (symbol_ref:DI ("_Z1cz") [flags 0x3] <function_decl 0x7f451f1a4400 c>) [0 c S1 A8])
        (const_int 2305843009213693952 [0x2000000000000000])) "gcc/testsuite/g++.dg/other/pr84964.C":6:16 -1
     (expr_list:REG_ARGS_SIZE (const_int 0 [0])
        (expr_list:REG_NORETURN (const_int 0 [0])
            (nil)))
    (expr_list (use (reg:QI 0 ax))
        (nil)))
during RTL pass: expand
gcc/testsuite/g++.dg/other/pr84964.C:6:23: internal compiler error: in rtl_verify_bb_insns, at cfgrtl.cc:2797
0x800d85 _fatal_insn(char const*, rtx_def const*, char const*, int, char const*)
	/var/tmp/portage/sys-devel/gcc-12.0.1_p20220313/work/gcc-12-20220313/gcc/rtl-error.cc:108
0xcd5ff3 rtl_verify_bb_insns
	/var/tmp/portage/sys-devel/gcc-12.0.1_p20220313/work/gcc-12-20220313/gcc/cfgrtl.cc:2797
0xcde38a rtl_verify_flow_info_1
	/var/tmp/portage/sys-devel/gcc-12.0.1_p20220313/work/gcc-12-20220313/gcc/cfgrtl.cc:2883
0xcde38a rtl_verify_flow_info
	/var/tmp/portage/sys-devel/gcc-12.0.1_p20220313/work/gcc-12-20220313/gcc/cfgrtl.cc:3126
0xcc456a verify_flow_info()
	/var/tmp/portage/sys-devel/gcc-12.0.1_p20220313/work/gcc-12-20220313/gcc/cfghooks.cc:282
0x1ee7578 checking_verify_flow_info
	/var/tmp/portage/sys-devel/gcc-12.0.1_p20220313/work/gcc-12-20220313/gcc/cfghooks.h:214
0x1ee7578 try_optimize_cfg
	/var/tmp/portage/sys-devel/gcc-12.0.1_p20220313/work/gcc-12-20220313/gcc/cfgcleanup.cc:2980
0x1ee7578 cleanup_cfg(int)
	/var/tmp/portage/sys-devel/gcc-12.0.1_p20220313/work/gcc-12-20220313/gcc/cfgcleanup.cc:3143
0xcc1f1f execute
	/var/tmp/portage/sys-devel/gcc-12.0.1_p20220313/work/gcc-12-20220313/gcc/cfgexpand.cc:6971
Comment 1 Martin Liška 2022-03-21 09:33:54 UTC
Started with r8-5501-ga20c5714c689bf1c.
Comment 2 Jakub Jelinek 2022-03-21 10:34:10 UTC
Created attachment 52653 [details]
gcc12-pr104989.patch

IMHO the flags |= ECF_NORETURN; change is too problematic, because for
noreturn calls we rely on the containing bb to not have fallthru edges and the call being at the end of the bb.  This patch arranges that assertion not to trigger either, but throws away the whole call insn sequence.
Comment 3 GCC Commits 2022-03-22 07:40:18 UTC
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:6adbb51eaa85f5bfed1ee06327daca306d48986d

commit r12-7749-g6adbb51eaa85f5bfed1ee06327daca306d48986d
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Mar 22 08:39:40 2022 +0100

    calls: Fix error recovery after sorry differently [PR104989]
    
    On Mon, Feb 28, 2022 at 07:52:56AM -0000, Roger Sayle wrote:
    > This patch resolves PR c++/84964 which is an ICE in the middle-end after
    > emitting a "sorry, unimplemented" message, and is a regression from
    > earlier releases of GCC.  This issue is that after encountering a
    > function call requiring an unreasonable amount of stack space, the
    > code continues and falls foul of an assert checking that stack pointer
    > has been correctly updated.  The fix is to (locally) consider aborted
    > function calls as "no return", which skips this downstream sanity check.
    
    As can be seen on PR104989, just setting ECF_NORETURN after sorry is quite
    risky and leads to other ICEs.  The problem is that ECF_NORETURN calls
    better should be at the end of basic blocks that don't have any fallthru
    successor edges, otherwise we can ICE later.
    
    This patch instead sets sibcall_failure if in pass == 0 (sibcall_failure
    means that the tail call sequence is not useful/not desirable and throws
    it away) and otherwise sets a new bool variable that will let us pass
    the assertion and also throws away the whole call sequence, I think that is
    best for error recovery.
    
    2022-03-22  Jakub Jelinek  <jakub@redhat.com>
    
            PR rtl-optimization/104989
            * calls.cc (expand_call): Don't set ECF_NORETURN in flags after
            sorry for passing too large argument, instead set sibcall_failure
            for pass == 0, or a new normal_failure flag otherwise.  If
            normal_failure is set, don't assert all stack has been deallocated
            at the end and throw away the whole insn sequence.
    
            * g++.dg/other/pr104989.C: New test.
Comment 4 Jakub Jelinek 2022-03-22 07:43:46 UTC
Fixed on the trunk so far.
Comment 5 Richard Biener 2022-05-27 09:47:43 UTC
GCC 9 branch is being closed
Comment 6 Jakub Jelinek 2022-06-28 10:48:41 UTC
GCC 10.4 is being released, retargeting bugs to GCC 10.5.
Comment 7 GCC Commits 2023-04-15 17:03:27 UTC
The master branch has been updated by John David Anglin <danglin@gcc.gnu.org>:

https://gcc.gnu.org/g:4f1c5e54d782b26304b0095ffb3ceb4c92c3c78d

commit r13-7194-g4f1c5e54d782b26304b0095ffb3ceb4c92c3c78d
Author: John David Anglin <danglin@gcc.gnu.org>
Date:   Sat Apr 15 17:02:44 2023 +0000

    Fix handling of large arguments passed by value.
    
    2023-04-15  John David Anglin  <danglin@gcc.gnu.org>
    
    gcc/ChangeLog:
    
            PR target/104989
            * config/pa/pa-protos.h (pa_function_arg_size): Update prototype.
            * config/pa/pa.cc (pa_function_arg): Return NULL_RTX if argument
            size is zero.
            (pa_arg_partial_bytes): Don't call pa_function_arg_size twice.
            (pa_function_arg_size): Change return type to int.  Return zero
            for arguments larger than 1 GB.  Update comments.
Comment 8 Sam James 2023-04-16 03:18:32 UTC
(In reply to CVS Commits from comment #7)
> The master branch has been updated by John David Anglin
> <danglin@gcc.gnu.org>:
> 
> https://gcc.gnu.org/g:4f1c5e54d782b26304b0095ffb3ceb4c92c3c78d
> 
> commit r13-7194-g4f1c5e54d782b26304b0095ffb3ceb4c92c3c78d
> Author: John David Anglin <danglin@gcc.gnu.org>
> Date:   Sat Apr 15 17:02:44 2023 +0000
> 
>     Fix handling of large arguments passed by value.
>     
>     2023-04-15  John David Anglin  <danglin@gcc.gnu.org>
>     
>     gcc/ChangeLog:
>     
>             PR target/104989
> [...]

This was for PR109478 instead.
Comment 9 Richard Biener 2023-07-07 10:42:42 UTC
GCC 10 branch is being closed.