From: Jeff Law <law@redhat.com>
To: Martin Sebor <msebor@gmail.com>,
Richard Biener <richard.guenther@gmail.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH v3] add object access attributes (PR 83859)
Date: Thu, 21 Nov 2019 22:40:00 -0000 [thread overview]
Message-ID: <07fde605-8a8e-b49e-793e-7fd92c569391@redhat.com> (raw)
In-Reply-To: <96a09235-ad6e-4ee4-8a7e-ac3fee688171@gmail.com>
On 11/21/19 10:11 AM, Martin Sebor wrote:
> Attached is another revision of this enhancement, this one
> incorporating Richard's request for a more efficient encoding
> of the attributes to enable faster parsing. There is just one
> attribute called access, with the rest being arguments. This
> is transformed to access (mode-string) where the mode-string
> is a STRING_CST describing the access mode (read/write/both)
> and the two positional arguments for the function type.
>
> I have also removed the attributes from the built-in functions
> since they're not used for anything yet, and added more argument
> validation.
>
> To test this a little more extensively, I annotated a few Glibc
> <unistd.h> functions with the new attribute and rebuilt it and
> its test suite. That exposed a problem with function pointers
> not being handled correctly so I fixed that by letting
> the access attribute apply to function pointers (and function
> pointer types in general).
>
> When this is finalized, if there's time I'm still hoping to get
> back to the parts of the patch that make use of the attribute
> for -Wunused and -Wuninitialized that I removed on Jeff's request
> for smaller, independent changes.
>
> In GCC 11 I'd like to look into tying this attribute in with
> _FORTIFY_SOURCE.
>
> Martin
>
> gcc-83859.diff
>
> PR middle-end/83859 - attributes to associate pointer arguments and sizes
>
> gcc/ChangeLog:
>
> PR middle-end/83859
> * attribs.h (struct attr_access): New.
> * attribs.c (decl_attributes): Add an informational note.
> * builtins.c (check_access): Make extern. Consistently set no-warning
> after issuing a warning. Handle calls through function pointers. Set
> no-warning.
> * builtins.h (check_access): Declare.
> * calls.c (rdwr_access_hash): New type.
> (rdwr_map): Same.
> (init_attr_rdwr_indices): New function.
> (maybe_warn_rdwr_sizes): Same.
> (initialize_argument_information): Call init_attr_rdwr_indices.
> Call maybe_warn_rdwr_sizes.
> * doc/extend.texi (attribute access): Document new attribute.
>
> gcc/c-family/ChangeLog:
>
> PR middle-end/83859
> * c-attribs.c (handle_access_attribute): New function.
> (c_common_attribute_table): Add new attribute.
> (get_argument_type): New function.
> (append_access_attrs): New function.
> (get_nonnull_operand): Rename...
> (get_attribute_operand): ...to this.
> * c-common.c (get_nonnull_operand): Rename...
> (get_attribute_operand): ...to this.
>
> gcc/testsuite/ChangeLog:
>
> PR middle-end/83859
> * c-c++-common/attr-nonstring-8.c: Adjust text of expected warning.
> * gcc.dg/Wstringop-overflow-22.c: New test.
> * gcc.dg/Wstringop-overflow-23.c: New test.
> * gcc.dg/attr-access-read-only.c: New test.
> * gcc.dg/attr-access-read-write.c: New test.
> * gcc.dg/attr-access-read-write-2.c: New test.
> * gcc.dg/attr-access-write-only.c: New test.
>
> diff --git a/gcc/calls.c b/gcc/calls.c
> index 62921351b11..15627abbd0d 100644
> --- a/gcc/calls.c
> +++ b/gcc/calls.c
> @@ -52,6 +52,8 @@ along with GCC; see the file COPYING3. If not see
> #include "tree-ssa-strlen.h"
> #include "intl.h"
> #include "stringpool.h"
> +#include "hash-map.h"
> +#include "hash-traits.h"
> #include "attribs.h"
> #include "builtins.h"
> #include "gimple-fold.h"
> @@ -1258,6 +1260,9 @@ alloc_max_size (void)
> bool
> get_size_range (tree exp, tree range[2], bool allow_zero /* = false */)
> {
> + if (!exp)
> + return false;
> +
> if (tree_fits_uhwi_p (exp))
> {
> /* EXP is a constant. */
This change isn't mentioned anywhere in the ChangeLog. If its
intentional, please mention it in the ChangeLog. If it's not
intentional, then drop it :-)
> diff --git a/gcc/gimple.h b/gcc/gimple.h
> index 5a190b1714d..10223386d04 100644
> --- a/gcc/gimple.h
> +++ b/gcc/gimple.h
> @@ -24,6 +24,8 @@ along with GCC; see the file COPYING3. If not see
>
> #include "tree-ssa-alias.h"
> #include "gimple-expr.h"
> +#include "function.h"
> +#include "basic-block.h"
I thought I asked before, can these be moved into the .c files where
they're actually needed?
Otherwise it looks OK to me.
jeff
next prev parent reply other threads:[~2019-11-21 22:39 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-29 19:52 [WIP PATCH] " Martin Sebor
2019-09-30 7:37 ` Richard Biener
2019-09-30 15:41 ` Martin Sebor
2019-09-30 21:34 ` Joseph Myers
2019-10-01 2:36 ` Martin Sebor
2019-10-17 16:44 ` [PING] " Martin Sebor
2019-10-24 14:42 ` [PING 2] " Martin Sebor
2019-10-27 17:37 ` Jeff Law
2019-10-28 10:18 ` Richard Biener
2019-11-15 21:41 ` Martin Sebor
2019-11-18 9:00 ` Richard Biener
2019-11-18 16:46 ` Martin Sebor
2019-11-19 8:57 ` Richard Biener
2019-11-21 17:12 ` [PATCH v3] " Martin Sebor
2019-11-21 22:40 ` Jeff Law [this message]
2019-11-22 1:12 ` Martin Sebor
2019-11-23 1:10 ` [PATCH] Fix attribute access issues Jakub Jelinek
2019-11-23 10:04 ` Richard Biener
2019-11-25 2:24 ` Martin Sebor
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=07fde605-8a8e-b49e-793e-7fd92c569391@redhat.com \
--to=law@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=msebor@gmail.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).