On Tue, 3 Nov 2026, Filip Kastl wrote: > On Mon 2026-11-02 12:52:25, Andrew MacLeod wrote: > > Thre is only one place (!!!!) that actually sets pt.null to 0 (meaning the > > range is nonnull) It is in tree-ssa-structalias.cc find_what_p_points_to() > > and it determines nonnullness based on : > > > > get_range_query (DECL_STRUCT_FUNCTION (fndecl))->range_of_expr (vr, p); > > bool nonnull = !vr.contains_zero_p (); > > <..> > > if (nonnull) > > set_ptr_nonnull (p); > > It's actually not true, that this is the only place that sets pt.null to 0 -- > find_what_var_points_to() can also produce pt_solution pt with pt.null = 0 > (when it creates the structure, it zero-initializes it by memset). Yes, in > find_what_pt_points_to() that gets overriden to whatever ranger thinks about > null-ness of a pointer. But that's not the only place > find_what_var_points_to() is called. > > On the other hand, when you look at the other calls to > find_what_var_points_to(), you see that those are only used to compute the > (IPA) escaped, escaped_return, IPA clobbers and IPA uses. I didn't check > as thoroughly as I'd like to, but I don't think that GCC ever makes use of > pt_solution.null for those PT sets. > > In case it really doesn't, I think we could not only remove pt_solution.null, > but also remove the NULL artificial variable from the PT constraints. That > would save a little bit of solving time. For my Steensgaard solver, that > could also be a significant boon in terms of precision.
The PTA solver does not conservatively enough track NULL-ness (it's a bit of a misfit to try to track a NULL "object" and keep that distinct from an empty points-to set), and as we now make use of pt->null as "range" from the middle-end (see for example ptrs_compare_unequal), what PTA computes is thrown away and replaced with what we get from range-info. So pt_solution.null was only "limited range storage for pointers" (as SSA_NAME_RANGE_INFO was integer type only). So - removing pt_solution.null is good and will clean up this odd thing from PTA. Yay. (no longer need to track 'NULL', aka nothing_id, but simply use an empty set!) Richard. > Cheers, > Filip Kastl > -- Richard Biener <[email protected]> SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri; (HRB 36809, AG Nuernberg)
