public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew Pinski <pinskia@gmail.com>
To: Julian Waters <tanksherman27@gmail.com>
Cc: gcc@gcc.gnu.org
Subject: Re: [PATCH] Basic asm blocks should always be volatile
Date: Tue, 27 Jun 2023 09:23:49 -0700	[thread overview]
Message-ID: <CA+=Sn1mAe2Maud1P+m++Sg0AHNCUyMOyXXHXrjkBSGWGdw=XKw@mail.gmail.com> (raw)
In-Reply-To: <CAP2b4GNuVAxSFnyFkYQ+U_5wvY268NJ70OO7tBTA5OJuTqit5g@mail.gmail.com>

On Tue, Jun 27, 2023 at 9:15 AM Julian Waters <tanksherman27@gmail.com> wrote:
>
> Hi Andrew,
>
> That can't be right, on my system a test of asm vs asm volatile with -O3 and -flto=auto yields very different results, with only the latter being correct. The patch fixed it and caused gcc to emit correct assembly

Can you provide a few testcases? Because the gimplifier should always happen.

Thanks,
Andrew Pinski

>
> best regards,
> Julian
>
> On Wed, Jun 28, 2023 at 12:08 AM Andrew Pinski <pinskia@gmail.com> wrote:
>>
>> On Tue, Jun 27, 2023 at 9:03 AM Julian Waters via Gcc <gcc@gcc.gnu.org> wrote:
>> >
>> > gcc's documentatation mentions that all basic asm blocks are always volatile,
>> > yet the parser fails to account for this by only ever setting
>> > volatile_p to true
>> > if the volatile qualifier is found. This patch fixes this by adding a
>> > special case check for extended_p before finish_asm_statement is called
>>
>> The patch which are you doing will not change the behavior of GCC as
>> GCC already treats them as volatile later on.
>> non-extended inline-asm has no outputs so the following code in the
>> gimplifier will kick in and turn the gimple statement into volatile:
>>       gimple_asm_set_volatile (stmt, ASM_VOLATILE_P (expr) || noutputs == 0);
>>
>> (note I am about to push a patch which changes the condition slightly
>> to have `asm goto` as volatile).
>>
>> Thanks,
>> Andrew
>>
>> >
>> > From 3094be39e3e65a6a638f05fafd858b89fefde6b5 Mon Sep 17 00:00:00 2001
>> > From: TheShermanTanker <tanksherman27@gmail.com>
>> > Date: Tue, 27 Jun 2023 23:56:38 +0800
>> > Subject: [PATCH] asm not using extended syntax should always be volatile
>> >
>> > ---
>> >  gcc/cp/parser.cc | 3 +++
>> >  1 file changed, 3 insertions(+)
>> >
>> > diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
>> > index a6341b9..ef3d06a 100644
>> > --- a/gcc/cp/parser.cc
>> > +++ b/gcc/cp/parser.cc
>> > @@ -22355,6 +22355,9 @@ cp_parser_asm_definition (cp_parser* parser)
>> >        /* Create the ASM_EXPR.  */
>> >        if (parser->in_function_body)
>> >   {
>> > +          if (!extended_p) {
>> > +            volatile_p = true;
>> > +          }
>> >     asm_stmt = finish_asm_stmt (asm_loc, volatile_p, string, outputs,
>> >         inputs, clobbers, labels, inline_p);
>> >     /* If the extended syntax was not used, mark the ASM_EXPR.  */
>> > --
>> > 2.35.1.windows.2

  parent reply	other threads:[~2023-06-27 16:24 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-27 16:01 Julian Waters
2023-06-27 16:08 ` Andrew Pinski
2023-06-27 16:15   ` Julian Waters
2023-06-27 16:15     ` Julian Waters
2023-06-27 16:24       ` Andrew Pinski
2023-06-27 16:23     ` Andrew Pinski [this message]
2023-06-28  7:31       ` Julian Waters
2023-06-28  7:38         ` Andrew Pinski
2023-06-28 10:43           ` Julian Waters
2023-06-28 15:04             ` Michael Matz
2023-06-28 18:46               ` Andrew Pinski
2023-06-29  6:42                 ` Julian Waters
2023-06-29 13:27                   ` Michael Matz
2023-06-30  6:11                     ` Julian Waters
2023-06-27 16:07 Julian Waters

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='CA+=Sn1mAe2Maud1P+m++Sg0AHNCUyMOyXXHXrjkBSGWGdw=XKw@mail.gmail.com' \
    --to=pinskia@gmail.com \
    --cc=gcc@gcc.gnu.org \
    --cc=tanksherman27@gmail.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).