Re: [RFC] Isolate & simplify paths with undefined behaviour

2013-10-24 Thread Jeff Law
On 10/23/13 07:05, Richard Biener wrote: Btw, -ftree-isolate-paths sounds a bit generic for isolating paths leading to undefined behavior, maybe -fisolate-errorneous-paths? (please drop 'tree-' from new options, 'tree' isn't meaningful to GCC users) Seems reasonable, particularly since I think t

Re: [RFC] Isolate & simplify paths with undefined behaviour

2013-10-23 Thread Jeff Law
On 10/23/13 01:58, Florian Weimer wrote: Could you keep in mind that there is considerable interest in a check_nonnull attribute which marks values (parameters, return values, maybe even struct fields) that can be NULL and need to be checked explictly prior to dereference? GCC would then warn if

Re: [RFC] Isolate & simplify paths with undefined behaviour

2013-10-23 Thread Richard Biener
On Mon, Oct 21, 2013 at 7:27 PM, Jeff Law wrote: > On 10/21/13 06:19, Richard Biener wrote: > >> >> I wonder why this isn't part of the regular jump-threading code - after >> all the opportunity is to thead to __builtin_unreachable () ;) Otherwise >> the question is always where you'd place this

Re: [RFC] Isolate & simplify paths with undefined behaviour

2013-10-23 Thread Florian Weimer
On 10/22/2013 09:00 PM, Jeff Law wrote: So I was poking at this a bit. It's trival to use infer_nonnull_range and to teach infer_nonnull_range to use the returns_nonnull attribute to pick up that return x in an appropriately decorated function implies that x is non-null. We'll need a better pl

Re: [RFC] Isolate & simplify paths with undefined behaviour

2013-10-22 Thread Jeff Law
On 10/18/13 14:31, Marc Glisse wrote: On Fri, 18 Oct 2013, Jeff Law wrote: On 10/18/13 12:47, Marc Glisse wrote: * tree-vrp has a function infer_nonnull_range, do you think we could share it? We now store the VRP ranges for integers, but not for pointers. If we did (or maybe just a non-null bi

Re: [RFC] Isolate & simplify paths with undefined behaviour

2013-10-21 Thread Jeff Law
On 10/21/13 06:19, Richard Biener wrote: I wonder why this isn't part of the regular jump-threading code - after all the opportunity is to thead to __builtin_unreachable () ;) Otherwise the question is always where you'd place this pass and whether it enables jump threading or CSE opportunitie

Re: [RFC] Isolate & simplify paths with undefined behaviour

2013-10-21 Thread Richard Biener
On Fri, Oct 18, 2013 at 7:12 PM, Jeff Law wrote: > > > Back in 2011 I wrote code to detect cases when traversing a particular path > could be proven to trigger undefined behaviour (such as a null pointer > dereference). That original patch would find the control dependent edges > leading to the d

Re: [RFC] Isolate & simplify paths with undefined behaviour

2013-10-18 Thread Jeff Law
On 10/18/13 15:15, Marc Glisse wrote: On Fri, 18 Oct 2013, Jeff Law wrote: On 10/18/13 14:31, Marc Glisse wrote: But once you have that pointer defined by a PHI containing a zero, you look at all its uses, trying to find one that proves the pointer is non-zero What are you going to do with t

Re: [RFC] Isolate & simplify paths with undefined behaviour

2013-10-18 Thread Marc Glisse
On Fri, 18 Oct 2013, Jeff Law wrote: On 10/18/13 14:31, Marc Glisse wrote: But once you have that pointer defined by a PHI containing a zero, you look at all its uses, trying to find one that proves the pointer is non-zero What are you going to do with that information? Uh? I must have been

Re: [RFC] Isolate & simplify paths with undefined behaviour

2013-10-18 Thread Jeff Law
On 10/18/13 14:31, Marc Glisse wrote: But once you have that pointer defined by a PHI containing a zero, you look at all its uses, trying to find one that proves the pointer is non-zero What are you going to do with that information? The only use I can see for this pass would be discovering mo

Re: [RFC] Isolate & simplify paths with undefined behaviour

2013-10-18 Thread Marc Glisse
On Fri, 18 Oct 2013, Jeff Law wrote: On 10/18/13 12:47, Marc Glisse wrote: * tree-vrp has a function infer_nonnull_range, do you think we could share it? We now store the VRP ranges for integers, but not for pointers. If we did (or maybe just a non-null bit), the pass could just test that bit o

Re: [RFC] Isolate & simplify paths with undefined behaviour

2013-10-18 Thread Jeff Law
On 10/18/13 12:47, Marc Glisse wrote: Maybe a new -fretroactive-undefined-behavior? (for later, obviously) Something like that -- haven't thought much about the name. * should cfg_altered be static (or a member of the pass class)? At the minimum it should be static. Into the pass class woul

Re: [RFC] Isolate & simplify paths with undefined behaviour

2013-10-18 Thread Marc Glisse
On Fri, 18 Oct 2013, Jeff Law wrote: Back in 2011 I wrote code to detect cases when traversing a particular path could be proven to trigger undefined behaviour (such as a null pointer dereference). That original patch would find the control dependent edges leading to the dereference and elimi

[RFC] Isolate & simplify paths with undefined behaviour

2013-10-18 Thread Jeff Law
Back in 2011 I wrote code to detect cases when traversing a particular path could be proven to trigger undefined behaviour (such as a null pointer dereference). That original patch would find the control dependent edges leading to the dereference and eliminate those edges. The result being