From: Ramana Radhakrishnan <ramana.gcc@googlemail.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: "Maciej W. Rozycki" <macro@wdc.com>,
Andrew Waterman <andrew@sifive.com>,
Kito Cheng <kito.cheng@gmail.com>,
Andreas Schwab <schwab@linux-m68k.org>,
GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH v3] libgcc: Use `-fasynchronous-unwind-tables' for LIB2_DIVMOD_FUNCS
Date: Fri, 28 Aug 2020 16:47:22 +0100 [thread overview]
Message-ID: <CAJA7tRbcgpVtUBEJbEbpOwi4B26QxP9QU9cBHBS4QGRUwgMMzA@mail.gmail.com> (raw)
In-Reply-To: <CAFiYyc2-kXt8xksf3JB4kDO_L3izCQ6F9_iKxmR7mcSpLZFRrA@mail.gmail.com>
On Wed, Aug 26, 2020 at 12:08 PM Richard Biener via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> On Tue, Aug 25, 2020 at 6:32 PM Maciej W. Rozycki <macro@wdc.com> wrote:
> >
> > Hi Kito,
> >
> > > I just found the mail thread about div mod with -fnon-call-exceptions,
> > > I think keeping the default LIB2_DIVMOD_EXCEPTION_FLAGS unchanged
> > > should be the best way to go.
> > >
> > > Non-call exceptions and libcalls
> > > https://gcc.gnu.org/legacy-ml/gcc/2001-06/msg01108.html
> > >
> > > Non-call exceptions and libcalls Part 2
> > > https://gcc.gnu.org/legacy-ml/gcc/2001-07/msg00402.html
> >
> > Thank you for your input. I believe I had a look at these commits before
> > I posted my original proposal. Please note however that they both predate
> > the addition of `-fasynchronous-unwind-tables', so clearly the option
> > could not have been considered at the time the changes were accepted into
> > GCC.
> >
> > Please note that, as observed by Andreas and Richard here:
> > <https://gcc.gnu.org/pipermail/gcc/2020-July/233122.html> in no case we
> > want to have full exception handling here, so we clearly need no
> > `-fexceptions'; this libcall code won't itself ever call `throw'.
> >
> > Now it might be a bit unclear from documentation as to whether we want
> > `-fnon-call-exceptions' or `-fasynchronous-unwind-tables', as it says that
> > the former option makes GCC:
> >
> > " Generate code that allows trapping instructions to throw
> > exceptions. Note that this requires platform-specific runtime
> > support that does not exist everywhere. Moreover, it only allows
> > _trapping_ instructions to throw exceptions, i.e. memory references
> > or floating-point instructions. It does not allow exceptions to be
> > thrown from arbitrary signal handlers such as 'SIGALRM'."
> >
> > Note the observation that arbitrary signal handlers (invoked at more inner
> > a frame level, and necessarily built with `-fexceptions') are still not
> > allowed to throw exceptions. For that, as far as I understand it, you
> > actually need `-fasynchronous-unwind-tables', which makes GCC:
> >
> > " Generate unwind table in DWARF format, if supported by target
> > machine. The table is exact at each instruction boundary, so it
> > can be used for stack unwinding from asynchronous events (such as
> > debugger or garbage collector)."
> >
> > and therefore allows arbitrary signal handlers to throw exceptions,
> > effectively making the option a superset of `-fexceptions'. As libcall
> > code can generally be implicitly invoked everywhere, we want people not to
> > be restrained by it and let a exception thrown by e.g. a user-supplied
> > SIGALRM handler propagate through the relevant libcall's stack frame,
> > rather than just those exceptions the libcall itself might indirectly
> > cause.
> >
> > Maybe I am missing something here, especially as `-fexceptions' mentions
> > code generation, while `-fasynchronous-unwind-tables' only refers to
> > unwind table generation, but then what would be the option to allow
> > exceptions to be thrown from arbitrary signal handlers rather than those
> > for memory references or floating-point instructions (where by a special
> > provision integer division falls as well)?
> >
> > My understanding has been it is `-fasynchronous-unwind-tables', but I'll
> > be gladly straightened out otherwise. If I am indeed right, then perhaps
> > the documentation could be clarified and expanded a bit.
> >
> > Barring evidence to the contrary I maintain the change I have proposed is
> > correct, and not only removes the RISC-V `ld.so' build issue, but it fixes
> > the handling of asynchronous events arriving in the middle of the relevant
> > libcalls for all platforms as well.
> >
> > Please let me know if you have any further questions, comments or
> > concerns.
>
> You only need -fexceptions for that, then you can throw; from a signal handler
> for example. If you want to be able to catch the exception somewhere up
> the call chain all intermediate code needs to be compiled so that unwinding
> from asynchronous events is possible - -fasynchronous-unwind-tables.
>
> So -fasynchronous-unwind-tables is about unwinding. -f[non-call]-exceptions
> is about throw/catch. Clearly libgcc does neither throw nor catch but with
> async events we might need to unwind from inside it.
>
> Now I don't know about the arm situation but if arm cannot do async unwinding
> then even -fexceptions won't help it here - libgcc still does not throw.
On Arm as in the AArch32 port, async unwinding will not work as those
can't be expressed in the EH format tables.
regards
Ramana
>
> Richard.
>
> >
> > Maciej
next prev parent reply other threads:[~2020-08-28 15:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-20 18:45 Maciej W. Rozycki
2020-08-25 1:41 ` Kito Cheng
2020-08-25 9:29 ` Kito Cheng
2020-08-25 16:32 ` Maciej W. Rozycki
2020-08-26 3:42 ` Kito Cheng
2020-08-26 11:08 ` Richard Biener
2020-08-26 11:33 ` Jakub Jelinek
2020-08-28 15:40 ` Maciej W. Rozycki
2020-08-28 17:04 ` Jakub Jelinek
2020-08-31 15:26 ` Maciej W. Rozycki
2020-08-28 15:47 ` Ramana Radhakrishnan [this message]
2020-08-31 8:04 ` Richard Biener
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAJA7tRbcgpVtUBEJbEbpOwi4B26QxP9QU9cBHBS4QGRUwgMMzA@mail.gmail.com \
--to=ramana.gcc@googlemail.com \
--cc=andrew@sifive.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=kito.cheng@gmail.com \
--cc=macro@wdc.com \
--cc=richard.guenther@gmail.com \
--cc=schwab@linux-m68k.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).