This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, testsuite] Skip addr_equal-1 if target keeps null pointer checks
- From: Senthil Kumar Selvaraj <senthil_kumar dot selvaraj at atmel dot com>
- To: Jeff Law <law at redhat dot com>
- Cc: <gcc-patches at gcc dot gnu dot org>, <ro at CeBiTec dot Uni-Bielefeld dot DE>, <mikestump at comcast dot net>, <hubicka at ucw dot cz>
- Date: Tue, 29 Sep 2015 12:11:09 +0530
- Subject: Re: [Patch, testsuite] Skip addr_equal-1 if target keeps null pointer checks
- Authentication-results: sourceware.org; auth=none
- References: <20150928081559 dot GB14913 at jaguar dot corp dot atmel dot com> <5609972A dot 2020001 at redhat dot com>
On Mon, Sep 28, 2015 at 01:38:18PM -0600, Jeff Law wrote:
> On 09/28/2015 02:15 AM, Senthil Kumar Selvaraj wrote:
> >Hi,
> >
> > The below patch skips gcc.dg/addr_equal-1.c if the target keeps null
> > pointer checks.
> >
> > The test fails for such targets (avr, in my case) because the address
> > comparison in the below code does not resolve to a constant, causing
> > builtin_constant_p to return false and fail the test.
> >
> > /* Variables and functions do not share same memory locations otherwise. */
> > if (!__builtin_constant_p ((void *)undef_fn0 == (void *)&undef_var0))
> > abort ();
> >
> > For targets that delete null pointer checks, the equality comparison expression
> > is optimized away to 0, as the code in match.pd knows they can only be
> > equal if they are both NULL, which cannot be true since
> > flag-delete-null-pointer-checks is on.
> >
> > For targets that keep null pointer checks, 0 is a valid address and the
> > comparison expression is left as is, and that causes a later pass to
> > fold the builtin_constant_p to a false value, resulting in the test failure.
> This sounds like a failing in the compiler itself, not a testsuite issue.
>
> Even on a target where objects can be at address 0, you can't have a
> variable and a function at the same address.
Hmm, symtab_node::equal_address_to, which is where the address equality
check happens, has a comment that contradicts
your statement, and the function variable overlap check is done after the
NULL possibility check. The current code looks like this
/* If both symbols may resolve to NULL, we can not really prove them different. */
if (!nonzero_address () && !s2->nonzero_address ())
return 2;
/* Except for NULL, functions and variables never overlap. */
if (TREE_CODE (decl) != TREE_CODE (s2->decl))
return 0;
Does anyone know why?
Regards
Senthil