public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Martin Sebor <msebor@gmail.com>,
	       Richard Sandiford <richard.sandiford@arm.com>
Cc: Gcc Patch List <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] fix ICE in generic_overlap (PR 84526)
Date: Fri, 23 Feb 2018 20:49:00 -0000	[thread overview]
Message-ID: <20180223201302.GJ5867@tucnak> (raw)
In-Reply-To: <d6101f48-539d-2596-f85f-5281a7c15020@gmail.com>

On Fri, Feb 23, 2018 at 12:57:14PM -0700, Martin Sebor wrote:
> +  /* get_inner_reference is not expected to return null.  */
> +  gcc_assert (base != NULL);
> +
>    poly_int64 bytepos = exact_div (bitpos, BITS_PER_UNIT);
>  
> -  HOST_WIDE_INT const_off;
> -  if (!base || !bytepos.is_constant (&const_off))
> -    {
> -      base = get_base_address (TREE_OPERAND (expr, 0));
> -      return;
> -    }
> -
> +  /* There is no conversion from poly_int64 to offset_int even
> +     though the latter is wider, so go through HOST_WIDE_INT.
> +     The offset is expected to always be constant.  */
> +  HOST_WIDE_INT const_off = bytepos.to_constant ();

The assert is ok, but removing the bytepos.is_constant (&const_off)
is wrong, I'm sure Richard S. can come up with some SVE testcase
where it will not be constant.  If it is not constant, you can handle
it like var_off (which as I said on IRC or in the PR also seems to be
incorrect, because if the base is not a decl the variable offset could be
negative).

>    offrange[0] += const_off;
>    offrange[1] += const_off;
>  
> @@ -923,7 +923,11 @@ builtin_access::generic_overlap ()
>        /* There's no way to distinguish an access to the same member
>  	 of a structure from one to two distinct members of the same
>  	 structure.  Give up to avoid excessive false positives.  */
> -      tree basetype = TREE_TYPE (TREE_TYPE (dstref->base));
> +      tree basetype = TREE_TYPE (dstref->base);
> +      if (POINTER_TYPE_P (basetype)
> +	  || TREE_CODE (basetype) == ARRAY_TYPE)
> +	basetype = TREE_TYPE (basetype);

This doesn't address any of my concerns that it is completely random
what {dst,src}ref->base is, apples and oranges; sometimes it is a pointer
(e.g. the argument of the function), sometimes the ADDR_EXPR operand,
sometimes the base of the reference, sometimes again address (if the
base of the reference is MEM_REF).  By the lack of consistency in what
it is, just deciding on its type whether you take TREE_TYPE or
TREE_TYPE (TREE_TYPE ()) of it also gives useless result.  You could e.g
call the memcpy etc. function with ADDR_EXPR of a VAR_DECL that has pointer
type, then if dstref->base is that VAR_DECL, POINTER_TYPE_P (basetype)
would be true.

	Jakub

  reply	other threads:[~2018-02-23 20:49 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-23 19:57 Martin Sebor
2018-02-23 20:49 ` Jakub Jelinek [this message]
2018-02-23 21:46   ` Martin Sebor
2018-02-24  9:32     ` Richard Sandiford
2018-02-24 14:45       ` Martin Sebor
2018-02-25 10:03         ` Richard Sandiford
2018-02-24 12:49     ` Jakub Jelinek
2018-02-23 23:25       ` Martin Sebor
2018-02-26 17:32     ` Martin Sebor
2018-02-26 20:49       ` Jakub Jelinek
2018-02-26 18:13         ` Martin Sebor
2018-03-07 15:17           ` Martin Sebor
2018-02-27 12:33       ` Richard Sandiford
2018-03-07 19:37       ` Jeff Law
2018-03-07 22:52         ` Martin Sebor
2018-03-07 23:04           ` Richard Sandiford
2018-03-07 23:59             ` Martin Sebor
2018-03-09 19:07           ` Jeff Law
2018-03-07 19:18     ` Jeff Law
2018-03-07 19:14   ` 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=20180223201302.GJ5867@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=msebor@gmail.com \
    --cc=richard.sandiford@arm.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).