public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <law@redhat.com>
To: Andrew MacLeod <amacleod@redhat.com>,
	Richard Biener <richard.guenther@gmail.com>
Cc: GCC <gcc@gcc.gnu.org>, Aldy Hernandez <aldyh@redhat.com>
Subject: Re: On-Demand range technology [2/5] - Major Components : How it works
Date: Fri, 31 May 2019 22:00:00 -0000	[thread overview]
Message-ID: <3419951a-e092-b8b8-f17b-e60b9a14e981@redhat.com> (raw)
In-Reply-To: <507e5167-2e56-7559-fc63-526e1fe4130a@redhat.com>

On 5/31/19 2:26 PM, Andrew MacLeod wrote:
> On 5/31/19 2:16 PM, Jeff Law wrote:
>> On 5/31/19 9:40 AM, Andrew MacLeod wrote:
>>>> stmt-level tracking of ranges are sometimes important.  This is
>>>> something the machinery cannot provide - correct?  At least not
>>>> optimistically enough with ranges derived about uses.
>>> Maybe I'm the one missing something, but in the absence of statement
>>> level exception throwing via 'can_throw_non_call_exceptions' being true,
>>> any assertion made anywhere in the block to an ssa_name applies to the
>>> entire block does it not?   ie it doesn't matter if the deference
>>> happens first thing in the block or last thing, its not going to change
>>> its value within the block.. its going to be non-null throughout the
>>> entire block.
>> No, I don't think it can hold for the entire block.
>>
>> Consider
>>
>>    x = p ? 10 : 20;
>>    foo (x)
>>    *p = whatever
>>
>> We don't know p is non-null because foo might not return.  If by way of
>> the dereference we were to assert p is non-null for the entire block,
>> then we'd pass the wrong value to foo().
>>
>> Jeff
>>
> 
> Interesting.  I started wondering about calls when I was talking about
> non-call exceptions, but couldn't think of an example off the top of my
> head.
> 
> OK, so the statement holds true for any section of code without calls in
> it.  If the block is marked as having a non-null deref in it, I need to
> look at statement in between the relevant def and use to see if there is
> an impact rather than just checking the flag.  If the flag is false, we
> need to do nothing else.
What about in a multi-threaded application?   No calls here....

  x = p ? 10 : 20;
  sharedvar = x;
  [ bunch of straightline code]
  *p = <whatever>

Our thread gets preempted and for some reason never restarts?  Another
thread could read sharedvar and get the wrong value?

But one might argue we have similar problems in other places where we
"back propagate" non-nullness.  I'm thinking about cases where the
pointer is passed to a function in an argument slot marked as non-null.
 We mark the name as currently having a non-null value and it can get
back propagated around in rather surprising ways and we've been called
out on it.

Dunno...  Probably worth mulling over some more...
Jeff

  reply	other threads:[~2019-05-31 22:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-23  1:28 Andrew MacLeod
2019-05-23 12:55 ` Richard Biener
2019-05-24 15:50   ` Andrew MacLeod
2019-05-27 13:03     ` Richard Biener
2019-05-28 14:17       ` Andrew MacLeod
2019-05-29 11:16         ` Richard Biener
2019-05-31 15:40           ` Andrew MacLeod
2019-05-31 18:16             ` Jeff Law
2019-05-31 20:27               ` Andrew MacLeod
2019-05-31 22:00                 ` Jeff Law [this message]
2019-05-31 23:08                   ` Andrew MacLeod
2019-06-04 15:27             ` Richard Biener
2019-06-04 15:38               ` Richard Biener
2019-06-04 16:50                 ` Andrew MacLeod
2019-06-04 17:07                   ` Richard Biener
2019-06-04 19:55                     ` Andrew MacLeod
2019-06-05  9:59                       ` Richard Biener
2019-06-04 16:49               ` Andrew MacLeod
2019-06-04 20:04             ` Martin Sebor
2019-06-04 20:22               ` Marc Glisse
2019-06-04 21:40                 ` Andrew MacLeod

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=3419951a-e092-b8b8-f17b-e60b9a14e981@redhat.com \
    --to=law@redhat.com \
    --cc=aldyh@redhat.com \
    --cc=amacleod@redhat.com \
    --cc=gcc@gcc.gnu.org \
    --cc=richard.guenther@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).