From: Richard Biener <richard.guenther@gmail.com>
To: Jens Gustedt <jens.gustedt@inria.fr>
Cc: Jakub Jelinek <jakub@redhat.com>,
"gcc@gcc.gnu.org" <gcc@gcc.gnu.org>,
"cl-c-memory-object-model@lists.cam.ac.uk"
<cl-c-memory-object-model@lists.cam.ac.uk>,
"law@redhat.com" <law@redhat.com>
Subject: Re: C provenance semantics proposal
Date: Wed, 24 Apr 2019 10:24:00 -0000 [thread overview]
Message-ID: <CAFiYyc18hL5NS0mTGNkNJN8uFTOWEKqfzxJOidGsMSSy-NtT3A@mail.gmail.com> (raw)
In-Reply-To: <20190419110927.7138a599@inria.fr>
On Fri, Apr 19, 2019 at 11:09 AM Jens Gustedt <jens.gustedt@inria.fr> wrote:
>
> Hello Jakub,
>
> On Fri, 19 Apr 2019 10:49:08 +0200 Jakub Jelinek <jakub@redhat.com>
> wrote:
>
> > On Fri, Apr 19, 2019 at 10:19:28AM +0200, Jens Gustedt wrote:
> > > > OTOH GCC transforms
> > > > (uintptr_t)&a != (uintptr_t)(&b+1)
> > > > into &a != &b + 1 (for equality compares) and then
> > > > doesn't follow this C rule anyways.
> > >
> > > Actually our proposal we are discussing here goes exactly the other
> > > way around. It basically reduces
> > >
> > > &a != &b + 1
> > >
> > > to
> > >
> > > (uintptr_t)&a != (uintptr_t)(&b+1)
> > >
> > > with only an exception for null pointers, but which probably don't
> > > matter for a platform where null pointers are just all bits 0.
> >
> > That penalizes quite a few optimizations though.
> > If you have
> > ptr != ptr2
> > and points-to analysis finds a set of variables ptr as well as ptr2
> > points to and the sets would be disjoint, it would be nice to be able
> > to optimize that comparison away
>
> yes
>
> > (gcc does);
>
> great
>
> > similarly, if one of the
> > pointers is &object or &object + sizeof (object).
>
> Here I don't follow. Why would one waste brain and ressources to
> optimize code that does such tricks?
>
> > By requiring what you request above, it can be pretty much never
> > optimized, unless the points-to analysis is able to also record if
> > the pointer points to the start, middle or end of object and only if
> > it is known to be in the middle it can safely optimize, for start or
> > end it would need to prove the other pointer is to end or start and
> > only non-zero sized objects are involved.
>
> I have the impression that you just propose an inversion of the
> roles. What you require is the user to keep track of this kind of
> information, and to know when they do (or should not) compare a
> one-passed pointer to something with a different provenance.
>
> I just don't feel that it is adequate to impose such a detailed
> knowledge on users, which is basically about a marginal use
> case. One-off pointers don't occur "naturally" in many places,
They occur in the single important place - loop IV tests in
C++ style iterator != end where end is a "pointer" to one after
the last valid iterator value.
I'd
> guess. Using them for anything else than to test bounds for array
> traversal is insane, and there "usually" the test is with `<`, anyhow,
> which has different rules.
Unfortunately then C++ arrived and compilers were expected to
also optimize that nasty code.
Richard.
>
> Jens
>
> --
> :: INRIA Nancy Grand Est ::: Camus ::::::: ICube/ICPS :::
> :: ::::::::::::::: office Strasbourg : +33 368854536 ::
> :: :::::::::::::::::::::: gsm France : +33 651400183 ::
> :: ::::::::::::::: gsm international : +49 15737185122 ::
> :: http://icube-icps.unistra.fr/index.php/Jens_Gustedt ::
next prev parent reply other threads:[~2019-04-24 10:24 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-02 8:11 Peter Sewell
2019-04-12 14:51 ` Jeff Law
2019-04-12 15:31 ` Peter Sewell
2019-04-17 9:06 ` Richard Biener
2019-04-17 9:15 ` Peter Sewell
2019-04-17 9:41 ` Richard Biener
2019-04-17 11:53 ` Uecker, Martin
2019-04-17 12:41 ` Richard Biener
2019-04-17 12:56 ` Uecker, Martin
2019-04-17 13:35 ` Richard Biener
2019-04-17 14:12 ` Uecker, Martin
2019-04-17 17:31 ` Peter Sewell
2019-04-18 9:32 ` Richard Biener
2019-04-18 9:56 ` Richard Biener
2019-04-18 10:48 ` Peter Sewell
2019-04-18 11:57 ` Uecker, Martin
2019-04-18 12:31 ` Richard Biener
2019-04-18 13:25 ` Uecker, Martin
2019-04-18 10:45 ` Peter Sewell
2019-04-18 12:20 ` Uecker, Martin
2019-04-18 12:42 ` Richard Biener
2019-04-18 12:47 ` Jakub Jelinek
2019-04-18 12:51 ` Jakub Jelinek
2019-04-18 13:29 ` Jeff Law
2019-04-24 10:12 ` Richard Biener
2019-04-18 13:49 ` Uecker, Martin
2019-04-19 8:19 ` Jens Gustedt
2019-04-19 8:49 ` Jakub Jelinek
2019-04-19 9:09 ` Jens Gustedt
2019-04-19 9:34 ` Jakub Jelinek
2019-04-21 8:15 ` Jens Gustedt
2019-04-24 10:24 ` Richard Biener [this message]
2019-04-24 18:43 ` Jeff Law
2019-04-24 19:21 ` Jens Gustedt
2019-04-19 9:11 ` Peter Sewell
2019-04-19 9:15 ` Jens Gustedt
2019-04-19 9:35 ` Peter Sewell
2019-04-19 10:35 ` Uecker, Martin
2019-04-19 10:01 ` Uecker, Martin
2019-04-18 13:42 ` Jeff Law
2019-04-18 13:54 ` Uecker, Martin
2019-04-18 14:49 ` Peter Sewell
2019-04-18 15:09 ` Uecker, Martin
2019-04-24 10:19 ` Richard Biener
2019-04-24 18:41 ` Jeff Law
2019-04-24 19:30 ` Philipp Klaus Krause
2019-04-24 19:55 ` Uecker, Martin
2019-04-24 19:33 ` Jakub Jelinek
2019-04-24 21:19 ` Peter Sewell
2019-04-25 12:42 ` Richard Biener
2019-04-25 13:03 ` Peter Sewell
2019-04-25 13:13 ` Richard Biener
2019-04-25 13:20 ` Peter Sewell
2019-04-29 14:31 ` Joseph Myers
2019-04-25 12:39 ` Richard Biener
2019-05-09 11:26 ` Ralf Jung
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=CAFiYyc18hL5NS0mTGNkNJN8uFTOWEKqfzxJOidGsMSSy-NtT3A@mail.gmail.com \
--to=richard.guenther@gmail.com \
--cc=cl-c-memory-object-model@lists.cam.ac.uk \
--cc=gcc@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=jens.gustedt@inria.fr \
--cc=law@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).