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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
>The similar two() function does not do this

But it is different and not always semantically the same (due to a GNU
extension).

In the one case, the labada is called during a "finally" statement.

In the finally statement, rax becomes the exception (struct _Unwind_Exception
*) that is being thrown currently at the landing pad, this needs to be saved
around the call to fclose, so it is stored in r12 (maybe it could be pushed to
the stack instead but that raises more issues than it solves) and then it needs
to be in the function arugment for _Unwind_Resume.

In the two case, we do a catch and then we throw the current handled exception.
If you noticed the exception that is being currently throw is in eax but saved
off via __cxa_begin_catch into TLS global and then inside __cxa_rethrow, it
will grab that saved off value and then call _Unwind_Resume_or_Rethrow (~the
same call to _Unwind_Resume).  Oh there is an extra step "finally" step to call
__cxa_end_catch too after resuming of the unwinding.

So the one case is actually better for the normal case and the exception case.

Reply via email to