public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Sandiford <richard.sandiford@arm.com>
To: "J.W. Jagersma" <jwjagersma@gmail.com>
Cc: Segher Boessenkool <segher@kernel.crashing.org>,
	 gcc-patches@gcc.gnu.org
Subject: Re: [PATCH v2] generate EH info for volatile asm statements (PR93981)
Date: Mon, 09 Mar 2020 12:13:19 +0000	[thread overview]
Message-ID: <mpt8sk9lo9s.fsf@arm.com> (raw)
In-Reply-To: <bde4684c-6cab-1a9a-3cf7-172c6eabd243@gmail.com> (J. W. Jagersma's message of "Sat, 7 Mar 2020 21:43:59 +0100")

Thanks for doing this.

"J.W. Jagersma" <jwjagersma@gmail.com> writes:
> On 2020-03-07 20:20, Segher Boessenkool wrote:
>> Hi!
>> 
>> On Sat, Mar 07, 2020 at 06:12:45PM +0100, J.W. Jagersma wrote:
>>> The following patch extends the generation of exception handling
>>> information to cover volatile asms too.  This was already mostly
>>> implemented, and only minor changes are required in order to make it
>>> work.
>> 
>> This should wait for stage 1, IMO.  Looks pretty good to me, thanks!
>
> Hi, thanks for your response.
> What does stage 1 refer to?  I'm sorry, this is my first gcc patch and
> I'm still learning how this all works.
>
>> Some comments:
>> 
>>> +When non-call exceptions (@option{-fnon-call-exceptions}) are enabled, a
>>> +@code{volatile asm} statement is also allowed to throw exceptions.  If it
>>> +does, then the compiler assumes that its output operands have not been written
>>> +yet.
>> 
>> That reads as if the compiler assumes the outputs retain their original
>> value, but that isn't true (I hope!)  The compiler assumes the output
>> are clobbered, but it doesn't assume they are assigned any definite
>> value?
>
> Register outputs are assumed to be clobbered, yes.  For memory outputs
> this is not the case, if the asm writes it before throwing then the
> memory operand retains this value.  It should be the user's
> responsibility to ensure that an asm has no side-effects if it throws.

I guess one problem is that something like "=&m" explicitly says that
the operand is clobbered "early", and I think it would be fair for
"early" to include clobbers before the exception.  So IMO we should
allow at least early-clobbered memory outputs to be clobbered by the
exception.

And if we do that, then I'm not sure there's much benefit in trying to
treat the non-earlyclobber memory case specially.

It would be good to have testcases for the output cases.  E.g. for:

        int foo;
        int bar = 0;
        try
          {
            foo = 1;
            asm volatile ("..." : "=m" (foo));
          }
        catch (...whatever...)
          {
            bar = foo;
          }
        ...use bar...

What does "bar = foo" read?  Is it always undefined behaviour if executed?
Or does it always read "foo" from memory?  Can it be optimised to "bar = 1"?
Is "foo = 1" dead code?

Thanks,
Richard

  parent reply	other threads:[~2020-03-09 12:13 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-05 16:49 [PATCH] generate EH info for volatile asm statements (PR inline-asm/93981) J.W. Jagersma
2020-03-06  8:55 ` Richard Biener
2020-03-06 16:13   ` J.W. Jagersma
2020-03-07 17:12   ` [PATCH v2] generate EH info for volatile asm statements (PR93981) J.W. Jagersma
2020-03-07 19:20     ` Segher Boessenkool
2020-03-07 20:43       ` J.W. Jagersma
2020-03-07 20:48         ` Marek Polacek
2020-03-07 21:06           ` J.W. Jagersma
2020-03-07 23:03             ` Segher Boessenkool
2020-03-08 16:18               ` J.W. Jagersma
2020-03-09 22:10                 ` Segher Boessenkool
2020-03-10  1:10                   ` J.W. Jagersma
2020-03-07 20:52         ` Gerald Pfeifer
2020-03-09 12:13         ` Richard Sandiford [this message]
2020-03-09 12:54           ` Richard Biener
2020-03-09 18:01             ` Segher Boessenkool
2020-03-09 18:42               ` J.W. Jagersma
2020-03-10  0:25                 ` Segher Boessenkool
2020-03-10  1:12                   ` J.W. Jagersma
2020-03-09 15:49           ` J.W. Jagersma
2020-03-12  9:59             ` Richard Sandiford
2020-03-12 13:08               ` Richard Biener
2020-03-12 15:32                 ` Segher Boessenkool
2020-03-12 18:42                   ` J.W. Jagersma
2020-03-12 19:26                     ` Segher Boessenkool
2020-03-13  1:06                       ` J.W. Jagersma
2020-03-13 15:55                         ` Segher Boessenkool
2020-03-12 22:06               ` J.W. Jagersma
2020-03-13 13:31                 ` Richard Sandiford
2020-03-13 14:58                   ` Segher Boessenkool
2020-03-16 17:47                     ` Richard Sandiford
2020-03-16 19:02                       ` Segher Boessenkool
2020-03-16 19:46                         ` Richard Sandiford
2020-03-16 20:19                           ` Segher Boessenkool
2020-03-17 15:32                           ` Michael Matz
2020-03-18 15:42                             ` J.W. Jagersma
2020-03-19 17:06                               ` Michael Matz
2020-03-20 19:09                                 ` J.W. Jagersma
2020-03-24 17:54                                 ` J.W. Jagersma
2020-03-18 23:56                             ` Segher Boessenkool
2020-03-19 16:42                               ` Michael Matz
2020-03-19 16:59                               ` J.W. Jagersma
2020-03-19 17:17                                 ` Michael Matz
2020-03-13 16:40                   ` J.W. Jagersma

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=mpt8sk9lo9s.fsf@arm.com \
    --to=richard.sandiford@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jwjagersma@gmail.com \
    --cc=segher@kernel.crashing.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).