public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Martin Sebor <msebor@gmail.com>
Cc: Jeff Law <law@redhat.com>,
	Richard Biener <richard.guenther@gmail.com>,
		Gcc Patch List <gcc-patches@gcc.gnu.org>
Subject: Re: [PING 2][PATCH] enhance -Wrestrict to handle string built-ins (PR 78918)
Date: Sun, 17 Dec 2017 13:32:00 -0000	[thread overview]
Message-ID: <CAMe9rOqp9Bu6cbM+9xrqFWNuO0hTWvLeeRW=iot7Ge8dWwpw+g@mail.gmail.com> (raw)
In-Reply-To: <6fedb302-439c-78a5-4772-454b31a0a4f8@gmail.com>

On Sat, Dec 16, 2017 at 4:01 PM, Martin Sebor <msebor@gmail.com> wrote:
> On 12/11/2017 03:27 PM, Jeff Law wrote:
>>
>> On 12/08/2017 12:19 PM, Martin Sebor wrote:
>>>
>>> Attached is revision 8 of the patch with the changes suggested
>>> and/or requested below.
>>
>>
>> [ Big snip. ]
>>
>>>
>>>
>>> gcc-78918.diff
>>>
>>>
>>> PR tree-optimization/78918 - missing -Wrestrict on memcpy copying over
>>> self
>>>
>>> gcc/c-family/ChangeLog:
>>>
>>>         PR tree-optimization/78918
>>>         * c-common.c (check_function_restrict): Avoid checking built-ins.
>>>         * c.opt (-Wrestrict): Include in -Wall.
>>>
>>> gcc/ChangeLog:
>>>
>>>         PR tree-optimization/78918
>>>         * Makefile.in (OBJS): Add gimple-ssa-warn-restrict.o.
>>>         * builtins.c (check_sizes): Rename...
>>>         (check_access): ...to this.  Rename function arguments for
>>> clarity.
>>>         (check_memop_sizes): Adjust names.
>>>         (expand_builtin_memchr, expand_builtin_memcpy): Same.
>>>         (expand_builtin_memmove, expand_builtin_mempcpy): Same.
>>>         (expand_builtin_strcat, expand_builtin_stpncpy): Same.
>>>         (check_strncat_sizes, expand_builtin_strncat): Same.
>>>         (expand_builtin_strncpy, expand_builtin_memset): Same.
>>>         (expand_builtin_bzero, expand_builtin_memcmp): Same.
>>>         (expand_builtin_memory_chk, maybe_emit_chk_warning): Same.
>>>         (maybe_emit_sprintf_chk_warning): Same.
>>>         (expand_builtin_strcpy): Adjust.
>>>         (expand_builtin_stpcpy): Same.
>>>         (expand_builtin_with_bounds): Detect out-of-bounds accesses
>>>         in pointer-checking forms of memcpy, memmove, and mempcpy.
>>>         (gcall_to_tree_minimal, max_object_size): Define new functions.
>>>         * builtins.h (max_object_size): Declare.
>>>         * calls.c (alloc_max_size): Call max_object_size instead of
>>>         hardcoding ssizetype limit.
>>>         (get_size_range): Handle new argument.
>>>         * calls.h (get_size_range): Add a new argument.
>>>         * cfgexpand.c (expand_call_stmt): Propagate no-warning bit.
>>>         * doc/invoke.texi (-Wrestrict): Adjust, add example.
>>>         * gimple-fold.c (gimple_fold_builtin_memory_op): Detect
>>> overlapping
>>>         operations.
>>>         (gimple_fold_builtin_memory_chk): Same.
>>>         (gimple_fold_builtin_stxcpy_chk): New function.
>>>         * gimple-ssa-warn-restrict.c: New source.
>>>         * gimple-ssa-warn-restrict.h: New header.
>>>         * gimple.c (gimple_build_call_from_tree): Propagate location.
>>>         * passes.def (pass_warn_restrict): Add new pass.
>>>         * tree-pass.h (make_pass_warn_restrict): Declare.
>>>         * tree-ssa-strlen.c (handle_builtin_strcpy): Detect overlapping
>>>         operations.
>>>         (handle_builtin_strcat): Same.
>>>         (strlen_optimize_stmt): Rename...
>>>         (strlen_check_and_optimize_stmt): ...to this.  Handle strncat,
>>>         stpncpy, strncpy, and their checking forms.
>>>
>>> gcc/testsuite/ChangeLog:
>>>
>>>         PR tree-optimization/78918
>>>         * c-c++-common/Warray-bounds.c: New test.
>>>         * c-c++-common/Warray-bounds-2.c: New test.
>>>         * c-c++-common/Warray-bounds-3.c: New test.
>>>         * c-c++-common/Wrestrict-2.c: New test.
>>>         * c-c++-common/Wrestrict.c: New test.
>>>         * c-c++-common/Wrestrict.s: New test.
>>>         * c-c++-common/Wsizeof-pointer-memaccess1.c: Adjust
>>>         * c-c++-common/Wsizeof-pointer-memaccess2.c: Same.
>>>         * g++.dg/torture/Wsizeof-pointer-memaccess1.C: Same.
>>>         * g++.dg/torture/Wsizeof-pointer-memaccess2.C: Same.
>>>         * gcc.dg/memcpy-6.c: New test.
>>>         * gcc.dg/pr69172.c: Adjust.
>>>         * gcc.dg/pr79223.c: Same.
>>>         * gcc.dg/Wrestrict-2.c: New test.
>>>         * gcc.dg/Wrestrict.c: New test.
>>>         * gcc.dg/Wsizeof-pointer-memaccess1.c
>>>         * gcc.target/i386/chkp-stropt-17.c: New test.
>>>         * gcc.dg/torture/Wsizeof-pointer-memaccess1.c: Adjust.
>>
>> OK.  Thanks for your patience.  I know this was a ton of work and even
>> more waiting.
>
>
> Thanks.  In more testing I uncovered a few minor glitches.  I've
> fixed those and committed r255755.  Attached is the committed patch
> for reference.
>
> Martin

This caused:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83446

-- 
H.J.

  reply	other threads:[~2017-12-17 13:32 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-16 23:47 [PATCH] " Martin Sebor
2017-07-20 20:46 ` Martin Sebor
2017-07-25  3:13   ` [PING] " Martin Sebor
2017-08-01  2:27     ` [PING #2] " Martin Sebor
2017-08-01  9:23       ` Richard Biener
2017-08-01  9:25         ` Richard Biener
2017-08-02 17:10           ` Jeff Law
2017-08-03  8:46             ` Richard Biener
2017-08-06 23:08               ` Martin Sebor
2017-08-08 13:08                 ` Richard Biener
2017-08-09 16:14                 ` Jeff Law
2017-08-22  2:04                   ` Martin Sebor
2017-08-22  9:17                     ` Richard Biener
2017-08-24 22:36                       ` Jeff Law
2017-08-29  3:42                         ` Martin Sebor
2017-09-01 15:15                           ` Jeff Law
2017-08-29  2:35                       ` Martin Sebor
2017-08-29 11:32                         ` Richard Biener
     [not found]                           ` <40984eff-b156-3315-7bb5-558e9e83bf6c@gmail.com>
2017-10-24  6:40                             ` Martin Sebor
2017-11-10  0:28                               ` [PING][PATCH] " Martin Sebor
2017-11-16 22:24                                 ` [PING 2][PATCH] " Martin Sebor
2017-11-23  0:16                                   ` Jeff Law
2017-11-26  9:12                                     ` Martin Sebor
2017-11-30  0:56                                       ` Martin Sebor
2017-12-07 21:14                                         ` Jeff Law
2017-12-07 21:28                                           ` Martin Sebor
2017-12-07 21:48                                             ` Jeff Law
2017-12-07 22:23                                         ` Jeff Law
2017-12-08  0:44                                           ` Martin Sebor
2017-12-08 19:19                                             ` Martin Sebor
2017-12-11 22:27                                               ` Jeff Law
2017-12-17  0:02                                                 ` Martin Sebor
2017-12-17 13:32                                                   ` H.J. Lu [this message]
2018-01-08  9:56                                                   ` Tom de Vries
2017-12-07 20:16                                       ` Jeff Law
2017-11-27 12:45                                   ` Richard Biener
2017-11-30  1:19                                     ` Martin Sebor
2017-12-07 20:20                                     ` Jeff Law
2017-08-09 16:09               ` [PING #2] [PATCH] " 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='CAMe9rOqp9Bu6cbM+9xrqFWNuO0hTWvLeeRW=iot7Ge8dWwpw+g@mail.gmail.com' \
    --to=hjl.tools@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=law@redhat.com \
    --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).