From: Jakub Jelinek <jakub@redhat.com>
To: Martin Uecker <uecker@tugraz.at>
Cc: Bill Wendling <isanbard@gmail.com>,
Qing Zhao <qing.zhao@oracle.com>,
Richard Biener <richard.guenther@gmail.com>,
Kees Cook <keescook@chromium.org>,
Joseph Myers <joseph@codesourcery.com>,
Siddhesh Poyarekar <siddhesh@gotplt.org>,
GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: RFC: the proposal to resolve the missing dependency issue for counted_by attribute
Date: Fri, 3 Nov 2023 07:22:32 +0100 [thread overview]
Message-ID: <ZUSRqHuO28MKzg0g@tucnak> (raw)
In-Reply-To: <3df84ff288be72e6e6198e0221389395d53f2d63.camel@tugraz.at>
On Fri, Nov 03, 2023 at 07:07:36AM +0100, Martin Uecker wrote:
> Am Donnerstag, dem 02.11.2023 um 17:28 -0700 schrieb Bill Wendling:
> > On Thu, Nov 2, 2023 at 1:36 PM Qing Zhao <qing.zhao@oracle.com> wrote:
> > >
> > > Thanks a lot for raising these issues.
> > >
> > > If I understand correctly, the major question we need to answer is:
> > >
> > > For the following example: (Jakub mentioned this in an early message)
> > >
> > > 1 struct S { int a; char b __attribute__((counted_by (a))) []; };
> > > 2 struct S s;
> > > 3 s.a = 5;
> > > 4 char *p = &s.b[2];
> > > 5 int i1 = __builtin_dynamic_object_size (p, 0);
> > > 6 s.a = 3;
> > > 7 int i2 = __builtin_dynamic_object_size (p, 0);
> > >
> > > Should the 2nd __bdos call (line 7) get
> > > A. the latest value of s.a (line 6) for it’s size?
> > > Or B. the value when the s.b was referenced (line 3, line 4)?
> > >
> > I personally think it should be (A). The user is specifically
> > indicating that the size has somehow changed, and the compiler should
> > behave accordingly.
>
>
> One potential problem for A apart from the potential impact on
> optimization is that the information may get lost more
> easily. Consider:
>
> char *p = &s.b[2];
> f(&s);
> int i = __bdos(p, 0);
>
> If the compiler can not see into 'f', the information is lost
> because f may have changed the size.
Why? It doesn't really matter. The options are
A. p is at &s.b[2] associated with &s.a and int type (or size of int
or whatever); .ACCESS_WITH_SIZE can't be pure, but sure, for aliasing
POV we can describe it with more detail that it doesn't modify anything
in the pointed structure, just escapes the pointer; __bdos can stay
leaf I believe; and when expanding __bdos later on, it would just
dereference the associated pointer at that point (note, __bdos is
pure, so it has vuse but not vdef and can load from memory); if
f changes s.a, no problem, __bdos will load the changed value in there
B. if .ACCESS_WITH_SIZE associates the pointer with the s.a value from that
point, .ACCESS_WITH_SIZE can be const, but obviously if f changes s.a,
__bdos later will use s.a value from the &s.b[2] spot
Jakub
next prev parent reply other threads:[~2023-11-03 6:23 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-31 16:26 Qing Zhao
2023-10-31 17:35 ` Siddhesh Poyarekar
2023-10-31 18:35 ` Qing Zhao
2023-10-31 22:14 ` Joseph Myers
2023-11-01 14:47 ` Qing Zhao
2023-11-01 15:00 ` Martin Uecker
2023-11-01 15:48 ` Qing Zhao
2023-11-02 7:57 ` Richard Biener
2023-11-02 8:27 ` Jakub Jelinek
2023-11-02 10:18 ` Richard Biener
2023-11-02 10:39 ` Jakub Jelinek
2023-11-02 11:52 ` Richard Biener
2023-11-02 12:09 ` Jakub Jelinek
2023-11-02 20:35 ` Qing Zhao
2023-11-03 0:28 ` Bill Wendling
2023-11-03 6:07 ` Martin Uecker
2023-11-03 6:22 ` Jakub Jelinek [this message]
2023-11-03 6:32 ` Martin Uecker
2023-11-03 16:20 ` Qing Zhao
2023-11-03 16:30 ` Jakub Jelinek
2023-11-03 16:36 ` Qing Zhao
2023-11-03 14:32 ` Qing Zhao
2023-11-03 14:46 ` Jakub Jelinek
2023-11-03 15:22 ` Qing Zhao
2023-11-03 19:33 ` Qing Zhao
2023-11-02 20:47 ` Qing Zhao
2023-11-02 20:45 ` Qing Zhao
2023-11-02 13:50 ` Qing Zhao
2023-11-02 13:54 ` Richard Biener
2023-11-02 14:26 ` Qing Zhao
2023-11-02 14:12 ` Martin Uecker
2023-11-02 15:41 ` Siddhesh Poyarekar
2023-11-03 0:13 ` Bill Wendling
2023-11-03 19:28 ` Qing Zhao
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=ZUSRqHuO28MKzg0g@tucnak \
--to=jakub@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=isanbard@gmail.com \
--cc=joseph@codesourcery.com \
--cc=keescook@chromium.org \
--cc=qing.zhao@oracle.com \
--cc=richard.guenther@gmail.com \
--cc=siddhesh@gotplt.org \
--cc=uecker@tugraz.at \
/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).