public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Michael Matz <matz@suse.de>
Cc: Martin Uecker <ma.uecker@gmail.com>, "gcc@gcc.gnu.org" <gcc@gcc.gnu.org>
Subject: Re: reordering of trapping operations and volatile
Date: Tue, 18 Jan 2022 09:31:19 +0100	[thread overview]
Message-ID: <CAFiYyc1pqAepV8WUffQHDk5z-xj7Jmd7gg5Kzs5+N4ck=eXqOQ@mail.gmail.com> (raw)
In-Reply-To: <alpine.LSU.2.20.2201171338100.4251@wotan.suse.de>

On Mon, Jan 17, 2022 at 3:11 PM Michael Matz via Gcc <gcc@gcc.gnu.org> wrote:
>
> Hello,
>
> On Sat, 15 Jan 2022, Martin Uecker wrote:
>
> > > Because it interferes with existing optimisations. An explicit
> > > checkpoint has a clear meaning. Using every volatile access that way
> > > will hurt performance of code that doesn't require that behaviour for
> > > correctness.
> >
> > This is why I would like to understand better what real use cases of
> > performance sensitive code actually make use of volatile and are
> > negatively affected. Then one could discuss the tradeoffs.
>
> But you seem to ignore whatever we say in this thread.  There are now
> multiple examples that demonstrate problems with your proposal as imagined
> (for lack of a _concrete_ proposal with wording from you), problems that
> don't involve volatile at all.  They all stem from the fact that you order
> UB with respect to all side effects (because you haven't said how you want
> to avoid such total ordering with all side effects).
>
> As I said upthread: you need to define a concept of time at whose
> granularity you want to limit the effects of UB, and the borders of each
> time step can't simply be (all) the existing side effects.  Then you need
> to have wording of what it means for UB to occur within such time step, in
> particular if multiple UB happens within one (for best results it should
> simply be UB, not individual instances of different UBs).
>
> If you look at the C++ proposal (thanks Jonathan) I think you will find
> that if you replace 'std::observable' with 'sequence point containing a
> volatile access' that you basically end up with what you wanted.  The
> crucial point being that the time steps (epochs in that proposal) aren't
> defined by all side effects but by a specific and explicit thing only (new
> function in the proposal, volatile accesses in an alternative).
>
> FWIW: I think for a new language feature reusing volatile accesses as the
> clock ticks are the worse choice: if you intend that feature to be used
> for writing safer programs (a reasonable thing) I think being explicit and
> at the same time null-overhead is better (i.e. a new internal
> function/keyword/builtin, specified to have no effects except moving the
> clock forward).  volatile accesses obviously already exist and hence are
> easier to integrate into the standard, but in a given new/safe program,
> whenever you see a volatile access you would always need to ask 'is thise
> for clock ticks, or is it a "real" volatile access for memmap IO'.

I guess Martin want's to have accesses to volatiles handled the same as
function calls where we do not know whether the function call will return
or terminate the program normally.  As if the volatile access could have
a similar effect (it might actually reboot the machine or so - but of course
that and anything else I can imagine would be far from "normal termination
of the program").  That's technically possible to implement with a yet unknown
amount of work.

Btw, I'm not sure we all agree that (*) in the following program doesn't make
it invoke UB and thus the compiler is not free to re-order the
offending statement
to before the exit (0) call.  Thus UB is only "realized" if a stmt
containing it is
executed in the abstract machine.

int main()
{
   exit(0);
   1 / 0;  /// (*)
}

>
>
> Ciao,
> Michael.

  reply	other threads:[~2022-01-18  8:31 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-08  8:32 Martin Uecker
2022-01-08 12:41 ` Richard Biener
2022-01-08 13:50   ` Martin Uecker
2022-01-08 14:13     ` Marc Glisse
2022-01-08 14:41     ` Eric Botcazou
2022-01-08 15:27       ` Martin Uecker
2022-01-08 17:33         ` Eric Botcazou
2022-01-08 15:03 ` David Brown
2022-01-08 16:42   ` Martin Uecker
2022-01-08 18:35 ` Andrew Pinski
2022-01-08 21:07   ` Martin Uecker
2022-01-10  9:04     ` Richard Biener
2022-01-10 17:36       ` Martin Uecker
2022-01-11  7:11         ` Richard Biener
2022-01-11  8:17           ` Martin Uecker
2022-01-11  9:13             ` Richard Biener
2022-01-11 20:01               ` Martin Uecker
2022-01-13 16:45                 ` Michael Matz
2022-01-13 19:17                   ` Martin Uecker
2022-01-14 14:15                     ` Michael Matz
2022-01-14 14:58                       ` Paul Koning
2022-01-15 21:28                         ` Martin Sebor
2022-01-15 21:38                           ` Paul Koning
2022-01-16 12:37                             ` Martin Uecker
2022-01-14 15:46                       ` Martin Uecker
2022-01-14 19:54                       ` Jonathan Wakely
2022-01-15  9:00                         ` Martin Uecker
2022-01-15 16:33                           ` Jonathan Wakely
2022-01-15 18:48                             ` Martin Uecker
2022-01-17 14:10                               ` Michael Matz
2022-01-18  8:31                                 ` Richard Biener [this message]
2022-01-21 16:21                                   ` Martin Uecker
2022-01-11 18:17           ` David Brown

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='CAFiYyc1pqAepV8WUffQHDk5z-xj7Jmd7gg5Kzs5+N4ck=eXqOQ@mail.gmail.com' \
    --to=richard.guenther@gmail.com \
    --cc=gcc@gcc.gnu.org \
    --cc=ma.uecker@gmail.com \
    --cc=matz@suse.de \
    /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).