From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 70551 invoked by alias); 22 Nov 2019 01:09:41 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 70542 invoked by uid 89); 22 Nov 2019 01:09:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.7 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-pl1-f196.google.com Received: from mail-pl1-f196.google.com (HELO mail-pl1-f196.google.com) (209.85.214.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 22 Nov 2019 01:09:39 +0000 Received: by mail-pl1-f196.google.com with SMTP id t8so2305215plr.8 for ; Thu, 21 Nov 2019 17:09:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=69cxINc1V7BXxovVnh8XcbjcyCbpAXZH9tdYYIljUbA=; b=TFTNZch4FZXIpJPPuErJReWBBTTeHeN2GXKPS0FFz8kgORQyjSCT0JzOn6h9pjK7gz U9UMd++Tma7sFjDiJRf1OhoOlztGx+1vA6LdEYtCFF4XFaTpjUEXKIGpTZhBfjMOXsPH D10EEQwKM91rrJDgTjwYEIsP3q8FJyajzJpSVyfjwdu21cUryC91zGjySItrMUjFBHPy FdCBgits7kkr8Bceqio3+Din+MOsFDYtB4wsf/+fH/EVnDhM0JeAANPTdOZNkshoF0sf V8Ke1JBU+sRllK/ac8/I4R2ojp9+dAMXetoBn/c5hGbbepPNHlHIRSfUtsmkHgW6JRh+ xHOQ== Return-Path: Received: from [192.168.0.41] (97-118-98-145.hlrn.qwest.net. [97.118.98.145]) by smtp.gmail.com with ESMTPSA id w15sm4904242pfi.168.2019.11.21.17.09.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 Nov 2019 17:09:36 -0800 (PST) Subject: Re: [PATCH v3] add object access attributes (PR 83859) To: Jeff Law , Richard Biener Cc: gcc-patches References: <056e2b5b-696c-ca69-9027-7d2369354b07@gmail.com> <3b148654-b12c-1e7c-32d2-78df9d6c70e7@gmail.com> <2d4cec52-3afa-227f-9f1d-e82b948003f9@gmail.com> <96a09235-ad6e-4ee4-8a7e-ac3fee688171@gmail.com> <07fde605-8a8e-b49e-793e-7fd92c569391@redhat.com> From: Martin Sebor Message-ID: <8d333632-6f51-6604-b7f9-57018997853f@gmail.com> Date: Fri, 22 Nov 2019 01:12:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <07fde605-8a8e-b49e-793e-7fd92c569391@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2019-11/txt/msg02169.txt.bz2 On 11/21/19 3:38 PM, Jeff Law wrote: > 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 >>  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 :-) It's intentional. I'll add it to the ChangeLog. >> 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? With the latest changes the include directives are no loner needed. (You did ask and I answered the question a couple of replies ago when they still were necessary: https://gcc.gnu.org/ml/gcc-patches/2019-11/msg01473.html) > > Otherwise it looks OK to me. Okay, I'll commit it tomorrow if Richard has no further suggestions for changes. Martin > > jeff >