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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Iain Sandoe from comment #2)
> (In reply to Jakub Jelinek from comment #1)
> > Most likely similar problem to the one analyzed in PR59813, after all, it is
> > the same function.  Previously, in that function there were no tail calls
> > and most likely no tailcalls in any function with __builtin_eh_return call,
> > now it is possible, so various targets need to either catch up and handle
> > that case properly, or declare they don't want to support tailcalls if
> > cfun->calls_eh_return in *_ok_for_sibcall target hook.
> 
> thanks for the suggestion, I tried disabling sib calls when
> crtl->calls_eh_return (it is probably something that should be done anyway,
> given what's below).  That's not sufficient to resolve the bug.

I guess the problem is then:
  /* This will not work in conjunction with sibcalls.  Make sure there
     are none.  (This check is expensive, but seldom executed.) */
  if (WORLD_SAVE_P (info))
    {
      rtx_insn *insn;
      for (insn = get_last_insn_anywhere (); insn; insn = PREV_INSN (insn))
        if (CALL_P (insn) && SIBLING_CALL_P (insn))
          {
            info->world_save_p = 0;
            break;
          }
    }
if powerpc-darwin relies on world save in order to implement
__builtin_eh_return.  Though, I don't understand why that
if (DEFAULT_ABI == ABI_DARWIN && crtl->calls_eh_return) return false;
wouldn't work in rs6000_function_ok_for_sibcall, because that conditional
should make sure we don't have any tail calls in such functions and thus the
above shouldn't trigger.

> We actually generate correct code for -O1, but fail at -O2,3,s.

tail calls are optimized only at -O2.

Reply via email to