Hi Jakub,

>> That's great to hear, but all the other targets still need to be fixed 
>> somehow.
>
> Not all other targets, just some.  I don't see what you find wrong on
> actually fixing them.  The tail call in that spot is actually very
> desirable, but only if we can do a shrink wrapping for it, by doing

Without a torture test this it's not obvious how many targets actually get it 
right.

If it's desirable to optimize RaiseException (is that really the common case?), 
then
why not optimize the source code to:

_Unwind_Reason_Code
_Unwind_Resume_or_Rethrow (struct _Unwind_Exception *exc)
{
  if (exc->private_1 == 0)
    return _Unwind_RaiseException (exc);
  
  _Unwind_Resume_Tailcall (exc);
}

_Unwind_Reason_Code __attribute__((optimize ("no-omit-frame-pointer")))
_Unwind_Resume_Tailcall (struct _Unwind_Exception *exc)
{
  struct _Unwind_Context this_context, cur_context;
  _Unwind_Reason_Code code;
  unsigned long frames;
  do { __builtin_unwind_init (); uw_init_context_1 (&this_context, 
__builtin_dwarf_cfa (), __builtin_return_address (0)); } while (0);
  cur_context = this_context;
  code = _Unwind_ForcedUnwind_Phase2 (exc, &cur_context, &frames);
  ((void)(!(code == _URC_INSTALL_CONTEXT) ? abort (), 0 : 0));
  do { long offset = uw_install_context_1 ((&this_context), (&cur_context)); 
void *handler = uw_frob_return_addr ((&this_context), (&cur_context));
 _Unwind_DebugHook ((&cur_context)->cfa, handler); ; __builtin_eh_return 
(offset, handler); } while (0);
}


> If you want just ignore the problem, we can just
--- libgcc/unwind.inc.jj        2019-01-01 12:38:17.345987416 +0100
+++ libgcc/unwind.inc   2019-05-10 16:12:18.330555718 +0200
@@ -252,6 +252,7 @@ _Unwind_Resume (struct _Unwind_Exception
    a normal exception that was handled.  */
 
 _Unwind_Reason_Code LIBGCC2_UNWIND_ATTRIBUTE
+__attribute__((optimize ("no-omit-sibling-calls")))
 _Unwind_Resume_or_Rethrow (struct _Unwind_Exception *exc)
 {
   struct _Unwind_Context this_context, cur_context;

> and be done with that.

Yes that's a safe temporary workaround to get things working again, I don't
think anyone can object to that.

Note typo "no-optimize-sibling-calls". And it needs a comment with the PRs
created for this.

Wilco
    

Reply via email to