public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew MacLeod <amacleod@redhat.com>
To: Andrew Pinski <pinskia@gmail.com>,
	Aldy Hernandez <aldyh@redhat.com>,
	GCC Mailing List <gcc@gcc.gnu.org>
Subject: Re: get_range_query vs NULL argument
Date: Wed, 15 Feb 2023 17:30:12 -0500	[thread overview]
Message-ID: <009a0ac2-0626-c21c-c0f9-4d2e8daa66b3@redhat.com> (raw)
In-Reply-To: <CA+=Sn1ks16FXLch-tSqkZgKp6Tw-pckg1Hk2gRt+6cZyXiKdig@mail.gmail.com>


On 2/15/23 14:50, Andrew Pinski wrote:
> Hi,
>    While fixing PR 108354, I came across that
> ssa_name_has_boolean_range calls get_range_query with cfun as the
> argument but sometimes while in IPA passes cfun is currently nullptr.
> The question should we check the argument before calling
> get_range_query or is it a valid thing to call it with a nullptr (and
> have it return global_ranges in that case)?

That might be ok...  personally I see nothing wrong with:

diff --git a/gcc/value-query.h b/gcc/value-query.h
index 63878968118..2d7bf8fcf33 100644
--- a/gcc/value-query.h
+++ b/gcc/value-query.h
@@ -140,7 +140,7 @@ get_global_range_query ()
  ATTRIBUTE_RETURNS_NONNULL inline range_query *
  get_range_query (const struct function *fun)
  {
-  return fun->x_range_query ? fun->x_range_query : &global_ranges;
+  return (fun && fun->x_range_query) ? fun->x_range_query : &global_ranges;
  }

  // Query the global range of NAME in function F.  Default to cfun.


The client is probably going to do that anyway.

Aldy?



  reply	other threads:[~2023-02-15 22:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-15 19:50 Andrew Pinski
2023-02-15 22:30 ` Andrew MacLeod [this message]
2023-02-16  7:57   ` Richard Biener
2023-02-16  8:10     ` Aldy Hernandez
2023-02-17 17:13   ` Andrew Pinski

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=009a0ac2-0626-c21c-c0f9-4d2e8daa66b3@redhat.com \
    --to=amacleod@redhat.com \
    --cc=aldyh@redhat.com \
    --cc=gcc@gcc.gnu.org \
    --cc=pinskia@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).