public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Martin Sebor <msebor@gmail.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] add access warning pass
Date: Wed, 28 Jul 2021 16:09:39 -0600	[thread overview]
Message-ID: <57c10e50-49f8-7a09-270a-c7895c9c3340@gmail.com> (raw)
In-Reply-To: <CAFiYyc2oVOAEmADy3kCEh0WLVaO1vMWoXDJPUs7dOQo9VrVPtw@mail.gmail.com>

On 7/28/21 3:23 AM, Richard Biener wrote:
> On Fri, Jul 16, 2021 at 12:42 AM Martin Sebor via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
>>
>> A number of access warnings as well as their supporting
>> infrastructure (compute_objsize et al.) are implemented in
>> builtins.{c,h} where they  (mostly) operate on trees and run
>> just before RTL expansion.
>>
>> This setup may have made sense initially when the warnings were
>> very simple and didn't perform any CFG analysis, but it's becoming
>> a liability.  The code has grown both in size and in complexity,
>> might need to examine the CFG to improve detection, and in some
>> cases might achieve a better S/R ratio if run earlier.  Running
>> the warning code on trees is also slower because it doesn't
>> benefit from the SSA_NAME caching provided by the pointer_query
>> class.  Finally, having the code there is also an impediment to
>> maintainability as warnings and builtin expansion are unrelated
>> to each other and contributors to one area shouldn't need to wade
>> through unrelated code (similar for patch reviewers).
>>
>> The attached change introduces a new warning pass and a couple of
>> new source and headers and, as the first step, moves the warning
>> code from builtins.{c,h} there.  To keep the initial changes as
>> simple as possible the pass only runs a subset of existing
>> warnings: -Wfree-nonheap-object, -Wmismatched-dealloc, and
>> -Wmismatched-new-delete.  The others (-Wstringop-overflow and
>> -Wstringop-overread) still run on the tree representation and
>> are still invoked from builtins.c or elsewhere.
>>
>> The changes have no functional impact either on codegen or on
>> warnings.  I tested them on x86_64-linux.
>>
>> As the next step I plan to change the -Wstringop-overflow and
>> -Wstringop-overread code to run on the GIMPLE IL in the new pass
>> instead of on trees in builtins.c.
> 
> That's the maybe_warn_rdwr_sizes thing?

Among others, yes.  It includes most buffer overflow and overread
warnings.

> 
> +      gimple *stmt = gsi_stmt (si);
> +      if (!is_gimple_call (stmt))
> +       continue;
> +
> +      check (as_a <gcall *>(stmt));
> 
> 
>       if (gcall *call = dyn_cast <gcall *> (gsi_stmt (si)))
>         check (call);
> 
> might be more C++-ish.

Sure, I can do that.

> 
> The patch looks OK - I skimmed it as mostly moving things
> around plus adding a new pass.

Okay, thanks.  I have retested the updated change and pushed it in
r12-2581.  As a reminder, the git show output for builtins.c looks
considerably different from the patch I posted because of what I
mentioned below.

Martin

> 
> Thanks,
> Richard.
> 
>> Martin
>>
>> PS The builtins.c diff produced by git diff was much bigger than
>> the changes justify.  It seems that the code removal somehow
>> confused it.  To make review easy I replaced it with a plain
>> unified diff of builtins.c that doesn't suffer from the problem.


      reply	other threads:[~2021-07-28 22:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-15 22:39 Martin Sebor
2021-07-23 16:48 ` PING " Martin Sebor
2021-07-28  9:23 ` Richard Biener
2021-07-28 22:09   ` Martin Sebor [this message]

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=57c10e50-49f8-7a09-270a-c7895c9c3340@gmail.com \
    --to=msebor@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --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).