public inbox for jit@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@redhat.com>
To: Andrew MacLeod <amacleod@redhat.com>,
	gcc-patches <gcc-patches@gcc.gnu.org>
Cc: jit@gcc.gnu.org
Subject: Re: [COMMITTED] Remove pass counting in VRP.
Date: Tue, 03 Oct 2023 13:02:56 -0400	[thread overview]
Message-ID: <32f0b8a98304dcce002b38c94de951b49cc5b8fe.camel@redhat.com> (raw)
In-Reply-To: <248800ec-0e0e-6cae-5aaa-a9c69cd5f46a@redhat.com>

On Tue, 2023-10-03 at 10:32 -0400, Andrew MacLeod wrote:
> Pass counting in VRP is used to decide when to call early VRP, pass
> the 
> flag to enable warnings, and when the final pass is.
> 
> If you try to add additional passes, this becomes quite fragile. This
> patch simply chooses the pass based on the data pointer passed in,
> and 
> remove the pass counter.   The first FULL VRP pass invokes the
> warning 
> code, and the flag passed in now represents the FINAL pass of VRP.  
> There is no longer a global flag which, as it turns out, wasn't
> working 
> well with the JIT compiler, but when undetected.  (Thanks to dmalcolm
> for helping me sort out what was going on there)
> 
> 
> Bootstraps  on x86_64-pc-linux-gnu with no regressions.   Pushed.

[CCing jit mailing list]

I'm worried that this patch may have "papered over" an issue with
libgccjit.  Specifically:

[...snip...]

> diff --git a/gcc/tree-vrp.cc b/gcc/tree-vrp.cc
> index d7b194f5904..05266dfe34a 100644
> --- a/gcc/tree-vrp.cc
> +++ b/gcc/tree-vrp.cc
> @@ -1120,36 +1120,44 @@ const pass_data pass_data_early_vrp =
>    ( TODO_cleanup_cfg | TODO_update_ssa | TODO_verify_all ),
>  };
>  
> -static int vrp_pass_num = 0;
> +static bool run_warning_pass = true;

I see the global variable "run_warning_pass" starts out true here

>  class pass_vrp : public gimple_opt_pass
>  {
>  public:
>    pass_vrp (gcc::context *ctxt, const pass_data &data_)
> -    : gimple_opt_pass (data_, ctxt), data (data_), warn_array_bounds_p (false),
> -      my_pass (vrp_pass_num++)
> -  {}
> +    : gimple_opt_pass (data_, ctxt), data (data_),
> +      warn_array_bounds_p (false), final_p (false)
> +  {
> +    // Only the frst VRP pass should run warnings.
> +    if (&data == &pass_data_vrp)
> +      {
> +	warn_array_bounds_p = run_warning_pass;
> +	run_warning_pass = false;

...and run_warning_pass affects the member data
pass_vrp::warn_array_bounds_p here, and then becomes false, but nothing
seems to ever reset run_warning_pass back to true.

It seems that with this patch, if libgccjit compiles more than one
gcc_jit_context in the same process, the first context compilation will
warn, whereas subsequent ones in that process won't.

Or did I miss something?

[...snip...]

Thoughts?
Dave


       reply	other threads:[~2023-10-03 17:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <248800ec-0e0e-6cae-5aaa-a9c69cd5f46a@redhat.com>
2023-10-03 17:02 ` David Malcolm [this message]
2023-10-03 17:11   ` Andrew MacLeod
2023-10-03 17:27     ` David Malcolm

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=32f0b8a98304dcce002b38c94de951b49cc5b8fe.camel@redhat.com \
    --to=dmalcolm@redhat.com \
    --cc=amacleod@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jit@gcc.gnu.org \
    /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).