Set nonnull attribute to ptr_info_def based on VRP

Thu Oct 13 23:12:00 GMT 2016

Hi Richard,

On 13/10/16 20:44, Richard Biener wrote:
> On Thu, Oct 13, 2016 at 6:49 AM, kugan
> <> wrote:
>> Hi Richard,
>>> what does this try to do?  Preserve info VRP computed across PTA?
>>> I think we didn't yet sort out the nonlocal/escaped vs. null handling
>>> properly
>>> (or how PTA should handle get_ptr_nonnull).  The way you are using it
>>> asks for pt.null to be orthogonal to nonlocal/escaped and thus having
>>> nonlocal or escaped would also require setting ptr.null in PTA.  It then
>>> would be also more canonical to set it for pt.anything as well.  Which
>>> means conservatively handling it would be equivalent to flipping its
>>> semantic and changing its name to pt.nonnull.
>>> That said, you seem to be simply "reserving" the bit for VRP, keeping it
>>> conservatively true when "not computed".  I guess I'm fine with this for
>>> now
>>> but it should be documented in the header file that way.
>> Thanks for the comments.
>> To summarize, currently I am not relying on PTA analysis at all. Just saving
>> null from VRP (or rather nonnull) and preserving it across PTA. Primary
>> intention is to pass it for PARM_DECL SSA names (from ipa-vrp).
>> In this case, using  pt.anything/nonlocal/escaped will only make the result
>> more pessimistic.
>> Ideally, we should improve pt.null within PTA but for now as you said, I
>> will document it.
>> When we start using pt.null from PTA analysis, we would also have to take
>> into account pt.anything/nonlocal/escaped.
>> Does that make sense?
> Yes.

Here is the revised patch based on the review. I also had to adjust two 
testcases since we set pt.null conservatively and dumps that too.



2016-10-14  Kugan Vivekanandarajah  <>

	* tree-ssa-alias.h (pt_solution_singleton_or_null_p): Renamed from
	* tree-ssa-ccp.c (fold_builtin_alloca_with_align): Use renamed
	pt_solution_singleton_or_null_p from pt_solution_singleton_p.
	* tree-ssa-structalias.c (find_what_var_points_to): Conservatively set
	pt.null to 1.
	(find_what_p_points_to): Preserve pointer nonnull computed by VRP.
	(pt_solution_singleton_or_null_p): Renamed from
	* tree-ssanames.h (set_ptr_nonnull): Declare.
	(get_ptr_nonnull): Likewise.
	* tree-ssanames.c (set_ptr_nonnull): New.
	(get_ptr_nonnull): Likewise.
	* tree-vrp.c (vrp_finalize): Set ptr that are nonnull.
	(evrp_dom_walker::before_dom_children): Likewise.


2016-10-14  Kugan Vivekanandarajah  <>

	* gcc.dg/torture/pr39074-2.c: Adjust testcase.
	* gcc.dg/torture/pr39074.c: Likewise.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-nonnull-to-pointer-from-VRP.patch
Type: text/x-patch
Size: 8826 bytes
Desc: not available
URL: <>

More information about the Gcc-patches mailing list