public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/107505] New: [13 Regression] ICE: verify_flow_info failed (error: returns_twice call is not first in basic block 2)
@ 2022-11-02  7:41 asolokha at gmx dot com
  2022-11-02 16:27 ` [Bug tree-optimization/107505] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: asolokha at gmx dot com @ 2022-11-02  7:41 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107505
           Summary: [13 Regression] ICE: verify_flow_info failed (error:
                    returns_twice call is not first in basic block 2)
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: ice-checking, ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: asolokha at gmx dot com
  Target Milestone: ---

An obligatory abnormal edge issue of the week.

gcc 13.0.0 20221030 snapshot (g:f36bba013361d8d4f9c7237c3307630de0cc0416) ICEs
when compiling the following testcase w/ -O2 -fno-guess-branch-probability:

int n;

void
bar (void);

__attribute__ ((noinline, returns_twice)) int
zero (void)
{
  return 0;
}

void
foo (void)
{
  int a = zero ();

  for (n = 0; n < 2; ++n)
    {
    }

  if (a)
    bar ();
}

% gcc-13 -O2 -fno-guess-branch-probability -c u9i2um01.c
u9i2um01.c: In function 'foo':
u9i2um01.c:13:1: error: returns_twice call is not first in basic block 2
   13 | foo (void)
      | ^~~
_7 = zero ();
during GIMPLE pass: cddce
u9i2um01.c:13:1: internal compiler error: verify_flow_info failed
0xa10ebd verify_flow_info()
       
/var/tmp/portage/sys-devel/gcc-13.0.0_p20221030/work/gcc-13-20221030/gcc/cfghooks.cc:284
0xf529c4 checking_verify_flow_info
       
/var/tmp/portage/sys-devel/gcc-13.0.0_p20221030/work/gcc-13-20221030/gcc/cfghooks.h:214
0xf529c4 cleanup_tree_cfg_noloop
       
/var/tmp/portage/sys-devel/gcc-13.0.0_p20221030/work/gcc-13-20221030/gcc/tree-cfgcleanup.cc:1161
0xf529c4 cleanup_tree_cfg(unsigned int)
       
/var/tmp/portage/sys-devel/gcc-13.0.0_p20221030/work/gcc-13-20221030/gcc/tree-cfgcleanup.cc:1212
0xe0b79c execute_function_todo
       
/var/tmp/portage/sys-devel/gcc-13.0.0_p20221030/work/gcc-13-20221030/gcc/passes.cc:2057
0xe0bbfe execute_todo
       
/var/tmp/portage/sys-devel/gcc-13.0.0_p20221030/work/gcc-13-20221030/gcc/passes.cc:2145

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

* [Bug tree-optimization/107505] [13 Regression] ICE: verify_flow_info failed (error: returns_twice call is not first in basic block 2)
  2022-11-02  7:41 [Bug tree-optimization/107505] New: [13 Regression] ICE: verify_flow_info failed (error: returns_twice call is not first in basic block 2) asolokha at gmx dot com
@ 2022-11-02 16:27 ` pinskia at gcc dot gnu.org
  2022-11-02 18:49 ` amonakov at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-02 16:27 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |13.0

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

* [Bug tree-optimization/107505] [13 Regression] ICE: verify_flow_info failed (error: returns_twice call is not first in basic block 2)
  2022-11-02  7:41 [Bug tree-optimization/107505] New: [13 Regression] ICE: verify_flow_info failed (error: returns_twice call is not first in basic block 2) asolokha at gmx dot com
  2022-11-02 16:27 ` [Bug tree-optimization/107505] " pinskia at gcc dot gnu.org
@ 2022-11-02 18:49 ` amonakov at gcc dot gnu.org
  2022-11-05 10:49 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: amonakov at gcc dot gnu.org @ 2022-11-02 18:49 UTC (permalink / raw)
  To: gcc-bugs

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

Alexander Monakov <amonakov at gcc dot gnu.org> changed:

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

--- Comment #1 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
Thanks. This is tree-ssa-sink relocating the call after 'zero' is discovered to
be const, so I think the fix may be as simple as

diff --git a/gcc/tree-ssa-sink.cc b/gcc/tree-ssa-sink.cc
index 921305201..631fc88c3 100644
--- a/gcc/tree-ssa-sink.cc
+++ b/gcc/tree-ssa-sink.cc
@@ -266,11 +266,11 @@ statement_sink_location (gimple *stmt, basic_block
frombb,
   /* We only can sink assignments and non-looping const/pure calls.  */
   int cf;
   if (!is_gimple_assign (stmt)
       && (!is_gimple_call (stmt)
          || !((cf = gimple_call_flags (stmt)) & (ECF_CONST|ECF_PURE))
-         || (cf & ECF_LOOPING_CONST_OR_PURE)))
+         || (cf & (ECF_LOOPING_CONST_OR_PURE|ECF_RETURNS_TWICE))))
     return false;

   /* We only can sink stmts with a single definition.  */
   def_p = single_ssa_def_operand (stmt, SSA_OP_ALL_DEFS);
   if (def_p == NULL_DEF_OPERAND_P)

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

* [Bug tree-optimization/107505] [13 Regression] ICE: verify_flow_info failed (error: returns_twice call is not first in basic block 2)
  2022-11-02  7:41 [Bug tree-optimization/107505] New: [13 Regression] ICE: verify_flow_info failed (error: returns_twice call is not first in basic block 2) asolokha at gmx dot com
  2022-11-02 16:27 ` [Bug tree-optimization/107505] " pinskia at gcc dot gnu.org
  2022-11-02 18:49 ` amonakov at gcc dot gnu.org
@ 2022-11-05 10:49 ` rguenth at gcc dot gnu.org
  2022-11-07 13:01 ` cvs-commit at gcc dot gnu.org
  2022-11-07 13:03 ` amonakov at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-11-05 10:49 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-11-05
             Status|UNCONFIRMED                 |NEW

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
That looks about correct - patch is OK if testing succeeds.

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

* [Bug tree-optimization/107505] [13 Regression] ICE: verify_flow_info failed (error: returns_twice call is not first in basic block 2)
  2022-11-02  7:41 [Bug tree-optimization/107505] New: [13 Regression] ICE: verify_flow_info failed (error: returns_twice call is not first in basic block 2) asolokha at gmx dot com
                   ` (2 preceding siblings ...)
  2022-11-05 10:49 ` rguenth at gcc dot gnu.org
@ 2022-11-07 13:01 ` cvs-commit at gcc dot gnu.org
  2022-11-07 13:03 ` amonakov at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-11-07 13:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Alexander Monakov <amonakov@gcc.gnu.org>:

https://gcc.gnu.org/g:5d060d8b0477ff4911f41c816281daaa24b41a13

commit r13-3753-g5d060d8b0477ff4911f41c816281daaa24b41a13
Author: Alexander Monakov <amonakov@ispras.ru>
Date:   Mon Nov 7 15:33:01 2022 +0300

    tree-ssa-sink: do not touch calls that return twice

    Avoid moving pure/const calls that may return twice in tree-ssa-sink:
    properly redirecting the associated abnormal edge is non-trivial.

    gcc/ChangeLog:

            PR tree-optimization/107505
            * tree-ssa-sink.cc (statement_sink_location): Additionally
            reject ECF_RETURNS_TWICE calls.

    gcc/testsuite/ChangeLog:

            PR tree-optimization/107505
            * gcc.dg/pr107505.c: New test.

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

* [Bug tree-optimization/107505] [13 Regression] ICE: verify_flow_info failed (error: returns_twice call is not first in basic block 2)
  2022-11-02  7:41 [Bug tree-optimization/107505] New: [13 Regression] ICE: verify_flow_info failed (error: returns_twice call is not first in basic block 2) asolokha at gmx dot com
                   ` (3 preceding siblings ...)
  2022-11-07 13:01 ` cvs-commit at gcc dot gnu.org
@ 2022-11-07 13:03 ` amonakov at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: amonakov at gcc dot gnu.org @ 2022-11-07 13:03 UTC (permalink / raw)
  To: gcc-bugs

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

Alexander Monakov <amonakov at gcc dot gnu.org> changed:

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

--- Comment #4 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #2)
> That looks about correct - patch is OK if testing succeeds.

Thanks, fixed.

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

end of thread, other threads:[~2022-11-07 13:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-02  7:41 [Bug tree-optimization/107505] New: [13 Regression] ICE: verify_flow_info failed (error: returns_twice call is not first in basic block 2) asolokha at gmx dot com
2022-11-02 16:27 ` [Bug tree-optimization/107505] " pinskia at gcc dot gnu.org
2022-11-02 18:49 ` amonakov at gcc dot gnu.org
2022-11-05 10:49 ` rguenth at gcc dot gnu.org
2022-11-07 13:01 ` cvs-commit at gcc dot gnu.org
2022-11-07 13:03 ` amonakov 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).