public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <jeffreyalaw@gmail.com>
To: Martin Sebor <msebor@gmail.com>, gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH v2 1/5] fix up compute_objsize: move bndrng into access_data
Date: Wed, 8 Dec 2021 11:47:42 -0700	[thread overview]
Message-ID: <cdede4a7-fbf6-49b7-1cf7-7ed3378e83e1@gmail.com> (raw)
In-Reply-To: <c9b3a8f9-303f-5265-b199-13088198c131@gmail.com>



On 12/6/2021 10:31 AM, Martin Sebor wrote:
> Attached is the subset of the patch in part (1) below:  Move
> bndrng from access_ref to access_data.
>
> On 12/3/21 5:00 PM, Jeff Law wrote:
>>
>>
>> On 11/8/2021 7:34 PM, Martin Sebor via Gcc-patches wrote:
>>> The pointer-query code that implements compute_objsize() that's
>>> in turn used by most middle end access warnings now has a few
>>> warts in it and (at least) one bug.  With the exception of
>>> the bug the warts aren't behind any user-visible bugs that
>>> I know of but they do cause problems in new code I've been
>>> implementing on top of it.  Besides fixing the one bug (just
>>> a typo) the attached patch cleans up these latent issues:
>>>
>>> 1) It moves the bndrng member from the access_ref class to
>>>    access_data.  As a FIXME in the code notes, the member never
>>>    did belong in the former and only takes up space in the cache.
>>>
>>> 2) The compute_objsize_r() function is big, unwieldy, and tedious
>>>    to step through because of all the if statements that are better
>>>    coded as one switch statement.  This change factors out more
>>>    of its code into smaller handler functions as has been suggested
>>>    and done a few times before.
>>>
>>> 3) (2) exposed a few places where I fail to pass the current
>>>    GIMPLE statement down to ranger.  This leads to worse quality
>>>    range info, including possible false positives and negatives.
>>>    I just spotted these problems in code review but I haven't
>>>    taken the time to come up with test cases.  This change fixes
>>>    these oversights as well.
>>>
>>> 4) The handling of PHI statements is also in one big, hard-to-
>>>    follow function.  This change moves the handling of each PHI
>>>    argument into its own handler which merges it into the previous
>>>    argument.  This makes the code easier to work with and opens it
>>>    to reuse also for MIN_EXPR and MAX_EXPR.  (This is primarily
>>>    used to print informational notes after warnings.)
>>>
>>> 5) Finally, the patch factors code to dump each access_ref
>>>    cached by the pointer_query cache out of pointer_query::dump
>>>    and into access_ref::dump.  This helps with debugging.
>>>
>>> These changes should have no user-visible effect and other than
>>> a regression test for the typo (PR 103143) come with no tests.
>>> They've been tested on x86_64-linux.
>> Sigh.  You've identified 6 distinct changes above.  The 5 you've 
>> enumerated plus a typo fix somewhere.  There's no reason why they 
>> need to be a single patch and many reasons why they should be a 
>> series of independent patches.    Combining them into a single patch 
>> isn't how we do things and it hides the actual bugfix in here.
>>
>> Please send a fix for the typo first since that should be able to 
>> trivially go forward.  Then  a patch for item #1.  That should be 
>> trivial to review when it's pulled out from teh rest of the patch. 
>> Beyond that, your choice on ordering, but you need to break this down.
>>
>>
>>
>>
>> Jeff
>>
>
>
> gcc-pointer_query-refactor-1.diff
>
> commit 1062c1154beeeae26e86f053946ea733ffb5d136
> Author: Martin Sebor <msebor@redhat.com>
> Date:   Sat Dec 4 16:46:17 2021 -0700
>
>      Move bndrng from access_ref to access_data.
>      
>      gcc/ChangeLog:
>      
>              * gimple-ssa-warn-access.cc (check_access): Adjust to member name
>              change.
>              (pass_waccess::check_strncmp): Same.
>              * pointer-query.cc (access_ref::access_ref): Remove arguments.
>              Simpilfy.
>              (access_data::access_data): Define new ctors.
>              (access_data::set_bound): Define new member function.
>              (compute_objsize_r): Remove unnecessary code.
>              * pointer-query.h (struct access_ref): Remove ctor arguments.
>              (struct access_data): Declare ctor overloads.
>              (access_data::dst_bndrng): New member.
>              (access_data::src_bndrng): New member.
OK.  Thanks for breaking this out.

jeff


  reply	other threads:[~2021-12-08 18:47 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-09  2:34 [PATCH] fix up compute_objsize (including PR 103143) Martin Sebor
2021-11-15 16:49 ` PING " Martin Sebor
2021-11-22 16:41   ` PING 2 " Martin Sebor
2021-11-29 15:49     ` PING 3 " Martin Sebor
2021-12-04  0:00 ` Jeff Law
2021-12-06 17:31   ` [PATCH v2] fix PR 103143 Martin Sebor
2021-12-06 20:14     ` Jeff Law
2021-12-06 21:44       ` Martin Sebor
2021-12-06 17:31   ` [PATCH v2 1/5] fix up compute_objsize: move bndrng into access_data Martin Sebor
2021-12-08 18:47     ` Jeff Law [this message]
2021-12-06 17:31   ` [PATCH v2 2/5] fix up compute_objsize: pass GIMPLE statement to it Martin Sebor
2021-12-08 18:48     ` Jeff Law
2021-12-06 17:32   ` [PATCH v2 3/5] fix up compute_objsize: factor out PHI handling Martin Sebor
2021-12-08 20:08     ` Jeff Law
2021-12-09 16:57       ` Martin Sebor
2021-12-06 17:32   ` [PATCH v2 4/5] fix up compute_objsize: refactor it into helpers Martin Sebor
2021-12-08 19:12     ` Jeff Law
2021-12-06 17:32   ` [PATCH v2 5/5] fix up compute_objsize: add a dump function Martin Sebor
2021-12-08 19:15     ` 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=cdede4a7-fbf6-49b7-1cf7-7ed3378e83e1@gmail.com \
    --to=jeffreyalaw@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=msebor@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).