This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] fix ICE in generic_overlap (PR 84526)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Martin Sebor <msebor at gmail dot com>, Richard Sandiford <richard dot sandiford at arm dot com>
- Cc: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 23 Feb 2018 21:13:02 +0100
- Subject: Re: [PATCH] fix ICE in generic_overlap (PR 84526)
- Authentication-results: sourceware.org; auth=none
- References: <d6101f48-539d-2596-f85f-5281a7c15020@gmail.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot 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