https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84658

--- Comment #12 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Martin Liška from comment #11)
> (In reply to Jakub Jelinek from comment #10)
> > If ICF needs to adjust all points-to if it makes any variable aliases,
> > perhaps it should as well adjust the code to use the variables rather than
> > their aliases.
> 
> Similar to what we do in sanopt.c:rewrite_usage_of_param? If so, I can do
> that.

But that doesn't help - you'll have points-to sets mentioning both DECLs.

static decls without TREE_ADDRESSABLE set are fine to merge, those won't
ever appear in points-to sets.  For all others you really need to adjust
points-to sets.

Note the issue is "new" since we optimize address comparisons since the
idea was that for memory references aliasing doesn't really matter since
all decls we merge are readonly(?).  That's of course a bit of a fishy
view...

Given ptrs_compare_unequal is as restricted as it is now we could work
around this issue there by doing instead of

      if (VAR_P (obj1)
          && (TREE_STATIC (obj1) || DECL_EXTERNAL (obj1)))
        {
          varpool_node *node = varpool_node::get (obj1);
          /* If obj1 may bind to NULL give up (see below).  */
          if (! node
              || ! node->nonzero_address ()
              || ! decl_binds_to_current_def_p (obj1))
            return false;
        }

sth like

      if (VAR_P (obj1)
          && (TREE_STATIC (obj1) || DECL_EXTERNAL (obj1)))
        {
          varpool_node *node = varpool_node::get (obj1);
          /* If obj1 may bind to NULL give up (see below).  */
          if (! node
              || ! node->nonzero_address ()
              || ! decl_binds_to_current_def_p (obj1))
            return false;
          FOR_EACH_ALIAS (node, ...)
            {
              tree obj1_alias = ...;
              unsigned saved_pt_uid = DECL_PT_UID (obj1_alias);
              DECL_PT_UID (obj1_alias) = DECL_UID (obj1_alias);
              bool aliases = pt_solution_includes (&pi->pt, obj1_alias);
              DECL_PT_UID (obj_alias) = saved_pt_uid;
            }
         }

with the code walking over aliases adjusted accordingly.

Of course if we ever try to compare two pointers and thus have just
two points-to sets to intersect we're still lost.

Reply via email to