public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/111942] New: ICE in rtl_split_edge, at cfgrtl.cc:1943 on pr98096.c with new -fharden-control-flow-redundancy
@ 2023-10-23 18:45 mjires at suse dot cz
  2023-10-26  7:39 ` [Bug middle-end/111942] ICE in rtl_split_edge, at cfgrtl.cc:1943 on pr98096.c with new -fharden-control-flow-redundancy with asm goto aoliva at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: mjires at suse dot cz @ 2023-10-23 18:45 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111942
           Summary: ICE in rtl_split_edge, at cfgrtl.cc:1943 on pr98096.c
                    with new -fharden-control-flow-redundancy
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mjires at suse dot cz
                CC: aoliva at gcc dot gnu.org
  Target Milestone: ---

Following testcase causes ICE with new -fharden-control-flow-redundancy

$ cat pr98096.c
/* Test for correct naming of label operands in asm goto in case of presence of
   input/output operands. */
/* { dg-do compile { target lra } } */
int i, j;
int f(void) {
  asm goto ("# %0 %2" : "+r" (i) ::: jmp);
  i += 2;
  asm goto ("# %0 %1 %l[jmp]" : "+r" (i), "+r" (j) ::: jmp);
 jmp: return i;
}



$ gcc pr98096.c -fharden-control-flow-redundancy -fnon-call-exceptions
during RTL pass: expand
pr98096.c: In function ‘f’:
pr98096.c:10:1: internal compiler error: in rtl_split_edge, at cfgrtl.cc:1943
   10 | }
      | ^
0x755d25 rtl_split_edge
        /home/mjires/git/GCC/master/gcc/cfgrtl.cc:1943
0xad6acb split_edge(edge_def*)
        /home/mjires/git/GCC/master/gcc/cfghooks.cc:670
0xaec884 commit_one_edge_insertion(edge_def*)
        /home/mjires/git/GCC/master/gcc/cfgrtl.cc:2058
0xaf14e1 commit_edge_insertions()
        /home/mjires/git/GCC/master/gcc/cfgrtl.cc:2127
0xad2a1d execute
        /home/mjires/git/GCC/master/gcc/cfgexpand.cc:6906
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

$ gcc -v
Using built-in specs.
COLLECT_GCC=/home/mjires/checks/master/bin/gcc
COLLECT_LTO_WRAPPER=/home/mjires/checks/master/libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /home/mjires/git/GCC/master/configure
--prefix=/home/mjires/checks/master
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.0.0 20231023 (experimental) (GCC)

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

* [Bug middle-end/111942] ICE in rtl_split_edge, at cfgrtl.cc:1943 on pr98096.c with new -fharden-control-flow-redundancy with asm goto
  2023-10-23 18:45 [Bug rtl-optimization/111942] New: ICE in rtl_split_edge, at cfgrtl.cc:1943 on pr98096.c with new -fharden-control-flow-redundancy mjires at suse dot cz
@ 2023-10-26  7:39 ` aoliva at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: aoliva at gcc dot gnu.org @ 2023-10-26  7:39 UTC (permalink / raw)
  To: gcc-bugs

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

Alexandre Oliva <aoliva at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2023-10-26
     Ever confirmed|0                           |1

--- Comment #1 from Alexandre Oliva <aoliva at gcc dot gnu.org> ---
Thanks for the report.

This latent bug is independent from -fharden-control-flow-redundancy.

The issue is that volatile asm stmts are considered throw points when
-fnon-call-exceptions is enabled.

I'm not sure where C++ wires non-call exceptions to enclosing handlers, but it
appears that it doesn't: even with a handler added around f's body, no EH edges
are added.

However, inlining f() into another function with a handler for the call will
wire all escaping exceptions to that handler, creating the same arrangement of
3 outgoing edges (fallthrough, asm jmp, and EH) that the rtl splitter barfs at.

/* compile with -fnon-call-exceptions */
int i, j;
int f(void) {
  asm goto ("# %0 %2" : "+r" (i) ::: jmp);
  i += 2;
  asm goto ("# %0 %1 %l[jmp]" : "+r" (i), "+r" (j) ::: jmp);
 jmp: return i;
}
int inline __attribute__ ((__always_inline__)) f(void);
int g(void) {
  try {
    return f();
  } catch (...) {
    i++;
    throw;
  }
}

./xgcc -B./ pr98096.cc -fno-harden-control-flow-redundancy
-fnon-call-exceptions
during RTL pass: expand
pr98096.cc: In function ‘int g()’:
pr98096.cc:19:1: internal compiler error: in rtl_split_edge, at cfgrtl.cc:1943
   19 | }

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

end of thread, other threads:[~2023-10-26  7:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-23 18:45 [Bug rtl-optimization/111942] New: ICE in rtl_split_edge, at cfgrtl.cc:1943 on pr98096.c with new -fharden-control-flow-redundancy mjires at suse dot cz
2023-10-26  7:39 ` [Bug middle-end/111942] ICE in rtl_split_edge, at cfgrtl.cc:1943 on pr98096.c with new -fharden-control-flow-redundancy with asm goto aoliva 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).