public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jan Hubicka <hubicka@ucw.cz>
To: Jeff Law <law@redhat.com>
Cc: Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>,
	gcc-patches@gcc.gnu.org, ro@CeBiTec.Uni-Bielefeld.DE,
	mikestump@comcast.net, hubicka@ucw.cz
Subject: Re: [Patch, testsuite] Skip addr_equal-1 if target keeps null pointer checks
Date: Wed, 30 Sep 2015 19:22:00 -0000	[thread overview]
Message-ID: <20150930190004.GA72459@kam.mff.cuni.cz> (raw)
In-Reply-To: <560C2E0B.4090705@redhat.com>

> On 09/29/2015 12:41 AM, Senthil Kumar Selvaraj wrote:
> >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?
> The only case I could think of would be weak symbols.

Yep, the check is there for weak symbols.  nonzero_address returns true for most
common symbols.
I tried to be simply conservative here about correctness, but I assume we would have
non-transitive equivalence because something like this would trigger abort

if (fn == NULL && var == NULL)
  assert (fn == var);

I assume one can before nonzero_address check something like

 if (TREE_CODE (decl) != TREE_CODE (s2->decl)
     && ((analyzed && DECL_EXTERNAL (decl)) || !DECL_WEAK (decl))
     && ((s2->analyzed && DECL_EXTERNAL (s2->decl)) || !DECL_WEAK (decl)))
   return 0;

before nonzero_address check as I see that if both fn and var are defined
they can't bind to same address. (basically the second part of conditional
copy nonzero_address with flag_delete_null_pointer_checks assumed to be true,
extra parameter to nonzero_address may do)

Honza
> 
> jeff

      reply	other threads:[~2015-09-30 19:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-28  8:26 Senthil Kumar Selvaraj
2015-09-28 19:38 ` Mike Stump
2015-09-28 21:20 ` Jeff Law
2015-09-29  8:18   ` Senthil Kumar Selvaraj
2015-09-30 18:59     ` Jeff Law
2015-09-30 19:22       ` Jan Hubicka [this message]

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=20150930190004.GA72459@kam.mff.cuni.cz \
    --to=hubicka@ucw.cz \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=law@redhat.com \
    --cc=mikestump@comcast.net \
    --cc=ro@CeBiTec.Uni-Bielefeld.DE \
    --cc=senthil_kumar.selvaraj@atmel.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).