public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "J.W. Jagersma" <jwjagersma@gmail.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: Jeff Law <law@redhat.com>, GCC Patches <gcc-patches@gcc.gnu.org>,
	vmakarov@redhat.com
Subject: Re: [PATCH v3 1/2] generate EH info for volatile asm statements (PR93981)
Date: Mon, 23 Nov 2020 17:45:50 +0100	[thread overview]
Message-ID: <ebaed3a2-f41c-15c2-8c0e-eb8f48c55654@gmail.com> (raw)
In-Reply-To: <CAFiYyc1zpU_xqwQvHodh+UFPFH+fPaTBe_NSt5KzU19Trse-xw@mail.gmail.com>

On 2020-11-23 09:20, Richard Biener wrote:
> On Sun, Nov 22, 2020 at 5:38 PM J.W. Jagersma <jwjagersma@gmail.com> wrote:
>>
>> On 2020-11-21 12:27, J.W. Jagersma wrote:
>>> ...
>>> Another idea I had is to introduce a new operand modifier, eg. '-', which
>>> would signify that the output *must* be considered clobbered on exception,
>>> and it would be an error if a copy is not possible.  Then the meaning of '+'
>>> can be extended to say that the output must be valid regardless of whether an
>>> exception occured or not.  Modifier '=' would mean the same as '+' with the
>>> additional implication that it is okay to eliminate earlier assignments, so
>>> that its value on the EH edge would be undefined.
>>
>> I've been working on implementing this, but I ran into an issue:
>>
>> First of all, in the first version of this patch I had to make sure that
>> debug stmts were inserted across the fallthrough edge, so that they don't
>> appear at the end a basic block.  I was surprised to find that this is no
>> longer necessary.
>>
>> Next I discovered that the following test case fails (returns -1):
>>
>>     int f ()
>>     {
>>       int i = 0;
>>       try { asm ("mov %0, 1; ud2" : "+r" (i)); }
>>       catch (...) { }
>>       return i - 1;
>>     }
>>
>> And this does succeed with a memory operand.
>>
>> It seems that something changed in the past few months, and now asm register
>> outputs are already being assigned via a temporary variable, somewhere.  Does
>> anyone know where that might be?
> 
> It's likely out-of SSA / RTL expansion inserting a bogus copy or doing
> coalescing on the EH edge.  Semantics of throwing asm stmts need to be
> honored there.
> 
> Richard.

I believe the issue is caused by commit e3b3b59 which adds support for outputs
from asm goto (CC-ing the author of that patch).  I don't yet see how to
reconcile this with the idea to add a new constraint modifier.

Also, that patch has another problem:
    asm goto ("# %0 %1 %2" : "+r" (i) ::: jmp);
Prints two registers and a label offset, which is somewhat unexpected.

And then:
    asm goto ("# %l[jmp]" : "+r" (i) ::: jmp);
Produces an error: '%l' operand isn't a label.

So label operands are numbered after the in-out operand is split, but %l is
evaluated before the split.  The examples given in extend.texi can never work.

  reply	other threads:[~2020-11-23 16:45 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-12  0:38 [PATCH v3 0/2] generate EH info for " J.W. Jagersma
2020-03-12  0:38 ` [PATCH v3 1/2] generate EH info for volatile " J.W. Jagersma
2020-11-12 15:51   ` Jeff Law
2020-11-13  8:45     ` Richard Biener
2020-11-19  5:51       ` Jeff Law
2020-11-15 13:00     ` J.W. Jagersma
2020-11-19  5:54       ` Jeff Law
2020-11-13  8:41   ` Richard Biener
2020-11-15 13:04     ` J.W. Jagersma
2020-11-19  5:55       ` Jeff Law
2020-11-21 11:27         ` J.W. Jagersma
2020-11-22 16:38           ` J.W. Jagersma
2020-11-23  8:20             ` Richard Biener
2020-11-23 16:45               ` J.W. Jagersma [this message]
2020-11-30 16:47               ` J.W. Jagersma
2020-12-01 17:02                 ` J.W. Jagersma
2020-11-24  2:57     ` Segher Boessenkool
2020-03-12  0:38 ` [PATCH v3 2/2] generate EH info for all " 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=ebaed3a2-f41c-15c2-8c0e-eb8f48c55654@gmail.com \
    --to=jwjagersma@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=law@redhat.com \
    --cc=richard.guenther@gmail.com \
    --cc=vmakarov@redhat.com \
    /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).