On Tue, 30 Jun 2026, Filip Kastl wrote:

> It's already pushed but FWIW looks straightforward and ok to me.  Just one
> question out of curiosity...
> 
> On Tue 2026-06-30 14:41:24, Richard Biener wrote:
> > The following records whether a points-to solution contains any
> > local automatic variables, not including parameters or result storage.
> > 
> > Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
> > 
> > This was requested by HJ (or rather suggested by me).
> > 
> > Richard.
> > 
> >     * tree-ssa-alias.h (pt_solution::vars_contains_auto): New.
> >     (ptr_deref_may_alias_auto_p): Declare.
> >     (pt_solution_includes_auto): Likewise.
> >     * tree-ssa-structalias.cc (set_uids_in_ptset): Record auto
> >     variables.
> >     (pt_solution_includes_auto): New function.
> >     (ipa_escaped_pt): Adjust.
> >     * tree-ssa-alias.cc (ptr_deref_may_alias_auto_p): New function.
> > ---
> >  gcc/tree-ssa-alias.cc       | 24 ++++++++++++++++++++++++
> >  gcc/tree-ssa-alias.h        |  4 ++++
> >  gcc/tree-ssa-structalias.cc | 30 +++++++++++++++++++++++++++++-
> >  3 files changed, 57 insertions(+), 1 deletion(-)
> > 
> > diff --git a/gcc/tree-ssa-alias.cc b/gcc/tree-ssa-alias.cc
> > index 467ef1c215f..1d10f6dbd97 100644
> > --- a/gcc/tree-ssa-alias.cc
> > +++ b/gcc/tree-ssa-alias.cc
> > @@ -238,6 +238,30 @@ ptr_deref_may_alias_global_p (tree ptr, bool 
> > escaped_local_p)
> >    return pt_solution_includes_global (&pi->pt, escaped_local_p);
> >  }
> >  
> > +/* Return true, if dereferencing PTR may alias with a local automatic
> > +   variable.  */
> > +
> > +bool
> > +ptr_deref_may_alias_auto_p (tree ptr)
> > +{
> > +  struct ptr_info_def *pi;
> > +
> > +  /* If we end up with a pointer constant here that may point
> > +     to local stack memory.  */
> > +  if (TREE_CODE (ptr) != SSA_NAME)
> > +    return true;
> 
> ... In this context ptr can only be an SSA name or a constant?  Cannot it be
> some global variable?  Or am I reading the comment wrong?

It could be &local_var or whatever the caller passes us.  We basically
say what we can handle here (see other ptr_deref_may_alias_* routines).
Both ptr_deref_may_alias_global_p and this could in theory handle
a bit more, like ptr_deref_may_alias_decl_p does.

Richard.

> 
> Cheers,
> Filip
> 

-- 
Richard Biener <[email protected]>
SUSE Software Solutions Germany GmbH,
Frankenstrasse 146, 90461 Nuernberg, Germany;
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)

Reply via email to