From: Martin Sebor <msebor@gmail.com>
To: Richard Biener <richard.guenther@gmail.com>, Jeff Law <law@redhat.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] adjust object size computation for union accesses and PHIs (PR 92765)
Date: Wed, 05 Feb 2020 23:58:00 -0000 [thread overview]
Message-ID: <f4e9131f-01e3-bc54-09ee-b2a9b2ff701e@gmail.com> (raw)
In-Reply-To: <CAFiYyc0GeeqviRtj2UQ81GgNDcRr4a48bSpxSDR-04wQw4N8fA@mail.gmail.com>
On 2/4/20 7:35 AM, Richard Biener wrote:
>>
...
>> Jakub/Richi, comments on this hunk?
>
> + tree ref = TREE_OPERAND (TREE_OPERAND (arg, 0), 0);
> + tree off = TREE_OPERAND (arg, 1);
> + if ((TREE_CODE (ref) == PARM_DECL || VAR_P (ref))
> + && (!DECL_EXTERNAL (ref)
> + || !array_at_struct_end_p (arg)))
> + {
>
> I think you'd want decl_binds_to_current_def_p (ref) instead of !DECL_EXTERNAL.
I've made the change.
> Since 'arg' is originally a pointer array_at_struct_end_p is
> meaningless here since
> that's about the structure of a reference while the pointer is just a
> value.
array_at_struct_end_p handles MEM_REF by looking at the argument
(i.e., at the DECL when it is one), so its use here avoids DECLs
with flexible arrays but allows others. In other words, I don't
want to exclude MEM_REFs to a in:
extern char a[4];
just because a is extern.
> So if
> you're concerned the objects size might not be as it looks like then you have to
> rely on decl_binds_to_current_def_p only.
I'm only concerned about sizes of extern objects of struct types
with flexible array members. I believe others are handled fine.
> You also shouldn't use 'off' natively
> in the code below but use mem_ref_offset to access the embedded offset
> which is to be interpreted as signed integer (it's a pointer as you use it).
> You compare it against an unsigned size...
I've changed it in the latest revision of the patch.
Martin
next prev parent reply other threads:[~2020-02-05 23:58 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-15 13:25 Martin Sebor
2020-01-15 21:15 ` Jeff Law
2020-01-15 21:49 ` Jakub Jelinek
2020-01-16 13:26 ` Jakub Jelinek
2020-01-31 20:17 ` Martin Sebor
2020-02-03 18:44 ` Jeff Law
2020-02-04 14:35 ` Richard Biener
2020-02-05 23:58 ` Martin Sebor [this message]
2020-02-05 23:58 ` Martin Sebor
2020-02-06 13:01 ` Jeff Law
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=f4e9131f-01e3-bc54-09ee-b2a9b2ff701e@gmail.com \
--to=msebor@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=law@redhat.com \
--cc=richard.guenther@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).