public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/107300] New: ICE: verify_ssa failed (error: virtual definition of statement not up to date)
@ 2022-10-18  3:33 asolokha at gmx dot com
  2022-10-18  7:32 ` [Bug ipa/107300] [13 Regression] " rguenth at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: asolokha at gmx dot com @ 2022-10-18  3:33 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107300
           Summary: ICE: verify_ssa failed (error: virtual definition of
                    statement not up to date)
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: 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: ---

gcc 13.0.0 20221016 snapshot (g:6366e3e8847af98d4728d55951534769d034d02a) ICEs
when compiling the following testcase, reduced from
gcc/testsuite/gcc.c-torture/execute/pr81281.c, w/ -O2 -fipa-cp-clone
-funreachable-traps -fno-inline:

void
bar (int x, int y)
{
  if (x)
    __builtin_unreachable ();

  if (y)
    __builtin_abort ();
}

void
foo (void)
{
  bar (0, 0);
}

% gcc-13 -O2 -fipa-cp-clone -funreachable-traps -fno-inline -c bppprfmm.c
bppprfmm.c: In function 'bar.constprop':
bppprfmm.c:2:1: error: virtual definition of statement not up to date
    2 | bar (int x, int y)
      | ^~~
__builtin_trap ();
during GIMPLE pass: fixup_cfg
bppprfmm.c:2:1: internal compiler error: verify_ssa failed
0x1155fd5 verify_ssa(bool, bool)
       
/var/tmp/portage/sys-devel/gcc-13.0.0_p20221016/work/gcc-13-20221016/gcc/tree-ssa.cc:1211
0xe0737d execute_function_todo
       
/var/tmp/portage/sys-devel/gcc-13.0.0_p20221016/work/gcc-13-20221016/gcc/passes.cc:2098
0xe077ae execute_todo
       
/var/tmp/portage/sys-devel/gcc-13.0.0_p20221016/work/gcc-13-20221016/gcc/passes.cc:2145

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

* [Bug ipa/107300] [13 Regression] ICE: verify_ssa failed (error: virtual definition of statement not up to date)
  2022-10-18  3:33 [Bug tree-optimization/107300] New: ICE: verify_ssa failed (error: virtual definition of statement not up to date) asolokha at gmx dot com
@ 2022-10-18  7:32 ` rguenth at gcc dot gnu.org
  2022-10-18  7:54 ` marxin at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-10-18  7:32 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|tree-optimization           |ipa
            Summary|ICE: verify_ssa failed      |[13 Regression] ICE:
                   |(error: virtual definition  |verify_ssa failed (error:
                   |of statement not up to      |virtual definition of
                   |date)                       |statement not up to date)
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
                 CC|                            |marxin at gcc dot gnu.org
   Last reconfirmed|                            |2022-10-18
   Target Milestone|---                         |13.0

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  The unreachable doesn't have virtual operands but trap() should
have.  Oddly enough the abort is also replaced with trap!?

void bar.constprop ()
{
  int x;
  int y;

  <bb 7> [local count: 1073741824]:

  <bb 2> [local count: 1073741824]:
  if (0 != 0)
    goto <bb 3>; [0.00%]
  else
    goto <bb 4>; [100.00%]

  <bb 3> [count: 0]:
  __builtin_trap ();

  <bb 4> [local count: 1073741824]:
  if (0 != 0)
    goto <bb 5>; [0.00%]
  else
    goto <bb 6>; [100.00%]

  <bb 5> [count: 0]:
  # .MEM_2 = VDEF <.MEM_1(D)>
  __builtin_trap ();

  <bb 6> [local count: 1073741824]:
  # VUSE <.MEM_1(D)>
  return;

smells like a deeper regression in IPA (I suppose IPA CP marks stuff
unreachable and then we turn that into traps!?)

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

* [Bug ipa/107300] [13 Regression] ICE: verify_ssa failed (error: virtual definition of statement not up to date)
  2022-10-18  3:33 [Bug tree-optimization/107300] New: ICE: verify_ssa failed (error: virtual definition of statement not up to date) asolokha at gmx dot com
  2022-10-18  7:32 ` [Bug ipa/107300] [13 Regression] " rguenth at gcc dot gnu.org
@ 2022-10-18  7:54 ` marxin at gcc dot gnu.org
  2022-10-18  7:55 ` rguenth at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-10-18  7:54 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

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

--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
Btw. started with r13-2541-g78ef801b7263606d.

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

* [Bug ipa/107300] [13 Regression] ICE: verify_ssa failed (error: virtual definition of statement not up to date)
  2022-10-18  3:33 [Bug tree-optimization/107300] New: ICE: verify_ssa failed (error: virtual definition of statement not up to date) asolokha at gmx dot com
  2022-10-18  7:32 ` [Bug ipa/107300] [13 Regression] " rguenth at gcc dot gnu.org
  2022-10-18  7:54 ` marxin at gcc dot gnu.org
@ 2022-10-18  7:55 ` rguenth at gcc dot gnu.org
  2022-10-19 17:34 ` pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-10-18  7:55 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1
           Keywords|                            |ice-checking

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

* [Bug ipa/107300] [13 Regression] ICE: verify_ssa failed (error: virtual definition of statement not up to date)
  2022-10-18  3:33 [Bug tree-optimization/107300] New: ICE: verify_ssa failed (error: virtual definition of statement not up to date) asolokha at gmx dot com
                   ` (2 preceding siblings ...)
  2022-10-18  7:55 ` rguenth at gcc dot gnu.org
@ 2022-10-19 17:34 ` pinskia at gcc dot gnu.org
  2022-11-30 17:10 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-19 17:34 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #1)
> Confirmed.  The unreachable doesn't have virtual operands but trap() should
> have.  Oddly enough the abort is also replaced with trap!?

That seems like the same issue as mentioned in PR 106249.

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

* [Bug ipa/107300] [13 Regression] ICE: verify_ssa failed (error: virtual definition of statement not up to date)
  2022-10-18  3:33 [Bug tree-optimization/107300] New: ICE: verify_ssa failed (error: virtual definition of statement not up to date) asolokha at gmx dot com
                   ` (3 preceding siblings ...)
  2022-10-19 17:34 ` pinskia at gcc dot gnu.org
@ 2022-11-30 17:10 ` jakub at gcc dot gnu.org
  2022-12-01 15:11 ` marxin at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-11-30 17:10 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hubicka at gcc dot gnu.org,
                   |                            |jakub at gcc dot gnu.org

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The problem related to __builtin_unreachable -> __builtin_trap is during
redirect_to_unreachable, which now calls:
253       struct cgraph_node *target
254         = cgraph_node::get_create (builtin_decl_unreachable ());
and that for -funreachable-traps doesn't return __builtin_unreachable () (which
doesn't need vops) but __builtin_trap () which does.
We have also IFN_TRAP internal call which is like __builtin_trap () except it
doesn't need vops.  So, perhaps one way to fix this would be in
redirect_call_stmt_to_callee or in inline_transform to special case
redirections to BUILT_IN_TRAP if the call stmt doesn't have vdef and replace
them with IFN_TRAP call rather than __builtin_trap in that case.  A problem is
that internal calls don't have cgraph edges, so we'd need to remove the edge
after the adjustment rather than keep it.
Or redirect_to_unreachable could just builtin_decl_implicit
(BUILT_IN_UNREACHABLE), but then again is a question where if any would we
change it into __ubsan_handle_builtin_unreachable for -fsanitize=unreachable or
__builtin_trap/IFN_TRAP later on.

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

* [Bug ipa/107300] [13 Regression] ICE: verify_ssa failed (error: virtual definition of statement not up to date)
  2022-10-18  3:33 [Bug tree-optimization/107300] New: ICE: verify_ssa failed (error: virtual definition of statement not up to date) asolokha at gmx dot com
                   ` (4 preceding siblings ...)
  2022-11-30 17:10 ` jakub at gcc dot gnu.org
@ 2022-12-01 15:11 ` marxin at gcc dot gnu.org
  2022-12-01 15:27 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-12-01 15:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Martin Liška <marxin at gcc dot gnu.org> ---
@Honza: ?

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

* [Bug ipa/107300] [13 Regression] ICE: verify_ssa failed (error: virtual definition of statement not up to date)
  2022-10-18  3:33 [Bug tree-optimization/107300] New: ICE: verify_ssa failed (error: virtual definition of statement not up to date) asolokha at gmx dot com
                   ` (5 preceding siblings ...)
  2022-12-01 15:11 ` marxin at gcc dot gnu.org
@ 2022-12-01 15:27 ` jakub at gcc dot gnu.org
  2022-12-20 14:36 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-12-01 15:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
And yet another option would be to change the IFN_TRAP to a normal builtin with
space in name so users couldn't access it, which would somewhat simplify the
IPA code; for replacing a normal call stmt with internal call we don't have any
helper functions right now and we'd need to throw away the edge, while if it is
a normal builtin, we could just return that builtin from
builtin_decl_unreachable instead of __builtin_trap.

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

* [Bug ipa/107300] [13 Regression] ICE: verify_ssa failed (error: virtual definition of statement not up to date)
  2022-10-18  3:33 [Bug tree-optimization/107300] New: ICE: verify_ssa failed (error: virtual definition of statement not up to date) asolokha at gmx dot com
                   ` (6 preceding siblings ...)
  2022-12-01 15:27 ` jakub at gcc dot gnu.org
@ 2022-12-20 14:36 ` rguenth at gcc dot gnu.org
  2023-02-02  9:55 ` cvs-commit at gcc dot gnu.org
  2023-02-02 12:57 ` jakub at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-12-20 14:36 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2022-12-19 00:00:00         |2022-12-20

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
Re-confirmed.

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

* [Bug ipa/107300] [13 Regression] ICE: verify_ssa failed (error: virtual definition of statement not up to date)
  2022-10-18  3:33 [Bug tree-optimization/107300] New: ICE: verify_ssa failed (error: virtual definition of statement not up to date) asolokha at gmx dot com
                   ` (7 preceding siblings ...)
  2022-12-20 14:36 ` rguenth at gcc dot gnu.org
@ 2023-02-02  9:55 ` cvs-commit at gcc dot gnu.org
  2023-02-02 12:57 ` jakub at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-02-02  9:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:d2423144eb36a68fd0da9224857ce807714874a7

commit r13-5645-gd2423144eb36a68fd0da9224857ce807714874a7
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Feb 2 10:54:54 2023 +0100

    Replace IFN_TRAP with BUILT_IN_UNREACHABLE_TRAP [PR107300]

    For PR106099 I've added IFN_TRAP as an alternative to __builtin_trap
    meant for __builtin_unreachable purposes (e.g. with -funreachable-traps
    or some sanitizers) which doesn't need vops because __builtin_unreachable
    doesn't need them either.  This works in various cases, but unfortunately
    IPA likes to decide on the redirection to unreachable just by tweaking
    the cgraph edge to point to a different FUNCTION_DECL.  As internal
    functions don't have a decl, this causes problems like in the following
    testcase.

    The following patch fixes it by removing IFN_TRAP again and replacing
    it with user inaccessible BUILT_IN_UNREACHABLE_TRAP, so that e.g.
    builtin_decl_unreachable can return it directly and we don't need to tweak
    it later in wherever we actually replace the call stmt.

    2023-02-02  Jakub Jelinek  <jakub@redhat.com>

            PR ipa/107300
            * builtins.def (BUILT_IN_UNREACHABLE_TRAP): New builtin.
            * internal-fn.def (TRAP): Remove.
            * internal-fn.cc (expand_TRAP): Remove.
            * tree.cc (build_common_builtin_nodes): Define
            BUILT_IN_UNREACHABLE_TRAP if not yet defined.
            (builtin_decl_unreachable): Use BUILT_IN_UNREACHABLE_TRAP
            instead of BUILT_IN_TRAP.
            * gimple.cc (gimple_build_builtin_unreachable): Remove
            emitting internal function for BUILT_IN_TRAP.
            * asan.cc (maybe_instrument_call): Handle
BUILT_IN_UNREACHABLE_TRAP.
            * cgraph.cc (cgraph_edge::verify_corresponds_to_fndecl): Handle
            BUILT_IN_UNREACHABLE_TRAP instead of BUILT_IN_TRAP.
            * ipa-devirt.cc (possible_polymorphic_call_target_p): Handle
            BUILT_IN_UNREACHABLE_TRAP.
            * builtins.cc (expand_builtin, is_inexpensive_builtin): Likewise.
            * tree-cfg.cc (verify_gimple_call,
            pass_warn_function_return::execute): Likewise.
            * attribs.cc (decl_attributes): Don't report exclusions on
            BUILT_IN_UNREACHABLE_TRAP either.

            * gcc.dg/pr107300.c: New test.

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

* [Bug ipa/107300] [13 Regression] ICE: verify_ssa failed (error: virtual definition of statement not up to date)
  2022-10-18  3:33 [Bug tree-optimization/107300] New: ICE: verify_ssa failed (error: virtual definition of statement not up to date) asolokha at gmx dot com
                   ` (8 preceding siblings ...)
  2023-02-02  9:55 ` cvs-commit at gcc dot gnu.org
@ 2023-02-02 12:57 ` jakub at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-02-02 12:57 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Should be fixed now.

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

end of thread, other threads:[~2023-02-02 12:57 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-18  3:33 [Bug tree-optimization/107300] New: ICE: verify_ssa failed (error: virtual definition of statement not up to date) asolokha at gmx dot com
2022-10-18  7:32 ` [Bug ipa/107300] [13 Regression] " rguenth at gcc dot gnu.org
2022-10-18  7:54 ` marxin at gcc dot gnu.org
2022-10-18  7:55 ` rguenth at gcc dot gnu.org
2022-10-19 17:34 ` pinskia at gcc dot gnu.org
2022-11-30 17:10 ` jakub at gcc dot gnu.org
2022-12-01 15:11 ` marxin at gcc dot gnu.org
2022-12-01 15:27 ` jakub at gcc dot gnu.org
2022-12-20 14:36 ` rguenth at gcc dot gnu.org
2023-02-02  9:55 ` cvs-commit at gcc dot gnu.org
2023-02-02 12:57 ` jakub 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).