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 | }

Reply via email to