https://gcc.gnu.org/g:5100739419bf43df11a91a39412e600ea1301727

commit r17-5685-g5100739419bf43df11a91a39412e600ea1301727
Author: Andrew MacLeod <[email protected]>
Date:   Wed Oct 21 20:53:20 2026 -0400

    constify and abstract pt_solution API.
    
    This abstracts the pt_solution API for ssa_names such that the
    pt_solution field is only accessed though a const pointer, acquired
    through ssa_name_pt_solution(), or set via set_ssa_name_pt_solution.
    
    It removes all reference to the ptr_info_def structyure which is slated
    to be removed.  This facilitates making the pt_solution a direct member
    of a prange_storage.
    
    DR_PTR_INFO is adjusted to take pt_solution object directly instead of a
    ptr_info_def structure.
    
    duplicate_ssa_name_ptr_info is also adjusted to no longer copy alignment
    info as every caller was then clearing the alignment info from a 
ptr_info_def.
    
    Assisted-by: Claude Opus 5
    
            * cfgexpand.cc (add_partitioned_vars_to_ptset): Adjust parameter.
            (update_alias_info_with_stack_vars): Adjust to new API.
            * gimple-pretty-print.cc (dump_ssaname_info): Likewise, and
            segregate alignment printing from pt_solution presence.
            * gimple-range.cc: Adjust comment.
            * ipa-icf.cc (sem_item_optimizer::fixup_pt_set): Adjust to new API.
            * ipa-icf.h (fixup_pt_set): Adjust parameter in protoype.
            * targhooks.cc (default_ref_may_alias_errno): Adjust to new API.
            * tree-core.h: Adjust comment.
            * tree-data-ref.cc (dr_analyze_alias): Adjust to new API.
            (dr_may_alias_p): Likewise.
            * tree-data-ref.h (struct dr_alias:ptr_info): Change type to
            pt_solution pointer.
            * tree-if-conv.cc (predicate_load_or_store): Adjust to new API.
            * tree-inline.cc (remap_ssa_name): Likewise.
            * tree-ssa-address.cc (copy_ref_info): Likewise.
            * tree-ssa-alias.cc (ptr_deref_may_alias_global_p): Likewise.
            (ptr_deref_may_alias_auto_p): Likewise.
            (ptr_deref_may_alias_decl_p ): Likewise.
            (ptr_derefs_may_alias_p): Likewise.
            (ptrs_compare_unequal): Likewise.
            (dump_alias_info): Likewise.
            (dump_points_to_solution): Change parameter type.
            (dump_points_to_info_for): Change to new API.
            (ref_maybe_used_by_call_p_1): Likewise.
            (call_may_clobber_ref_p_1): Likewise.
            (same_addr_size_stores_p): Likewise.
            * tree-ssa-alias.h (dump_points_to_solution): Adjust parameters.
            (pt_solution_singleton_or_null_p): Likewise.
            (pt_solution_includes_global): Likewise.
            (pt_solution_includes_auto): Likewise.
            (pt_solution_includes): Likewise.
            (pt_solution_includes_const_pool): Likewise.
            (pt_solutions_intersect): Likewise.
            * tree-ssa-ccp.cc (fold_builtin_alloca_with_align): Adjust to new 
API.
            * tree-ssa-loop-ivopts.cc (rewrite_use_nonlinear_expr): Likewise.
            * tree-ssa-loop-prefetch.cc (issue_prefetch_ref): Likewise.
            * tree-ssa-structalias.cc (find_what_p_points_to): Likewise.
            (pt_solution_singleton_or_null_p): Parameter constification.
            (pt_solution_includes_global): Likewise.
            (pt_solution_includes_auto): Likewise.
            (pt_solution_includes_1): Likewise.
            (pt_solution_includes): Likewise.
            (pt_solution_includes_const_pool): Likewise.
            (pt_solutions_intersect_1): Likewise.
            (pt_solutions_intersect): Likewise.
            * tree-ssa.cc (verify_ssa): Adjust to new API.
            * tree-ssanames.cc (ssa_name_ptr_info) Make static inline.
            (ssa_name_pt_solution): New.
            (set_ssa_name_pt_solution): New.
            (range_info_set_range): Adjust to new API.
            (get_ptr_info_alignment): Likewise.
            (mark_ptr_info_alignment_unknown): Likewise.
            (get_ptr_info): Make static.
            (duplicate_ssa_name_ptr_info): Adjust to new API.  Do not copy
            alignment info.
            (duplicate_ssa_name_range_info): Adjust to new API and copy 
alignment
            info.
            (reset_flow_sensitive_info): Likewise.
            (flow_sensitive_info_storage::save): Likewise.
            (flow_sensitive_info_storage::restore): Likewise.
            * tree-ssanames.h (ssa_name_ptr_info): Remove.
            (ssa_name_pt_solution): New prototype.
            (set_ssa_name_pt_solution): New prototype.
            (get_ptr_info): Remove.
            (duplicate_ssa_name_ptr_info): Adjust parameters.
            * tree-vect-data-refs.cc (vect_duplicate_ssa_name_ptr_info): Adjust
            to new API.
            (vect_create_addr_base_for_vector_ref): Likewise.
            (bump_vector_ptr): Likewise.
            * value-query.cc (get_ssa_name_ptr_info_nonnull): Likewise.
            * value-range-storage.h: Adjust comment.

Diff:
---
 gcc/cfgexpand.cc              |  15 +++---
 gcc/gimple-pretty-print.cc    |  19 ++++----
 gcc/gimple-range.cc           |   2 +-
 gcc/ipa-icf.cc                |   6 +--
 gcc/ipa-icf.h                 |   2 +-
 gcc/targhooks.cc              |   4 +-
 gcc/tree-core.h               |   2 +-
 gcc/tree-data-ref.cc          |  11 ++---
 gcc/tree-data-ref.h           |   6 +--
 gcc/tree-if-conv.cc           |   2 +-
 gcc/tree-inline.cc            |  22 +++------
 gcc/tree-ssa-address.cc       |  13 ++---
 gcc/tree-ssa-alias.cc         | 110 +++++++++++++++++++++---------------------
 gcc/tree-ssa-alias.h          |  14 +++---
 gcc/tree-ssa-ccp.cc           |   8 +--
 gcc/tree-ssa-loop-ivopts.cc   |   7 +--
 gcc/tree-ssa-loop-prefetch.cc |   7 +--
 gcc/tree-ssa-structalias.cc   |  25 +++++-----
 gcc/tree-ssa.cc               |   6 +--
 gcc/tree-ssanames.cc          |  85 +++++++++++++++++++++++---------
 gcc/tree-ssanames.h           |  13 +++--
 gcc/tree-vect-data-refs.cc    |  16 +++---
 gcc/value-query.cc            |   8 +--
 gcc/value-range-storage.h     |   3 +-
 24 files changed, 214 insertions(+), 192 deletions(-)

diff --git a/gcc/cfgexpand.cc b/gcc/cfgexpand.cc
index 32bc7bef4c8f..dad4393b3e5b 100644
--- a/gcc/cfgexpand.cc
+++ b/gcc/cfgexpand.cc
@@ -1070,7 +1070,7 @@ typedef hash_map<unsigned, bitmap, part_traits> 
part_hashmap;
    variables bitmap.  */
 
 static void
-add_partitioned_vars_to_ptset (struct pt_solution *pt,
+add_partitioned_vars_to_ptset (const pt_solution *pt,
                               part_hashmap *decls_to_partitions,
                               hash_set<bitmap> *visited, bitmap temp)
 {
@@ -1121,7 +1121,6 @@ update_alias_info_with_stack_vars (void)
     {
       bitmap part = NULL;
       tree name;
-      struct ptr_info_def *pi;
 
       /* Not interested in partitions with single variable.  */
       if (stack_vars[i].representative != i
@@ -1156,8 +1155,9 @@ update_alias_info_with_stack_vars (void)
        }
 
       /* Make the SSA name point to all partition members.  */
-      pi = get_ptr_info (name);
-      pt_solution_set (&pi->pt, part, false);
+      pt_solution pt;
+      pt_solution_set (&pt, part, false);
+      set_ssa_name_pt_solution (name, pt);
     }
 
   /* Make all points-to sets that contain one member of a partition
@@ -1171,11 +1171,10 @@ update_alias_info_with_stack_vars (void)
 
       FOR_EACH_SSA_NAME (i, name, cfun)
        {
-         struct ptr_info_def *pi;
+         const pt_solution *pt = ssa_name_pt_solution (name);
 
-         if (POINTER_TYPE_P (TREE_TYPE (name))
-             && ((pi = SSA_NAME_PTR_INFO (name)) != NULL))
-           add_partitioned_vars_to_ptset (&pi->pt, decls_to_partitions,
+         if (pt)
+           add_partitioned_vars_to_ptset (pt, decls_to_partitions,
                                           &visited, temp);
        }
 
diff --git a/gcc/gimple-pretty-print.cc b/gcc/gimple-pretty-print.cc
index ae7fdb2d7525..69148dd5cbd3 100644
--- a/gcc/gimple-pretty-print.cc
+++ b/gcc/gimple-pretty-print.cc
@@ -2400,19 +2400,18 @@ dump_ssaname_info (pretty_printer *pp, tree node, int 
spc)
   if (TREE_CODE (node) != SSA_NAME)
     return;
 
-  if (POINTER_TYPE_P (TREE_TYPE (node))
-      && SSA_NAME_PTR_INFO (node))
+  if (const pt_solution *pt = ssa_name_pt_solution (node))
     {
-      unsigned int align, misalign;
-      struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node);
       pp_string (pp, "# PT = ");
-      pp_points_to_solution (pp, &pi->pt);
+      pp_points_to_solution (pp, pt);
+      newline_and_indent (pp, spc);
+    }
+
+  unsigned int align, misalign;
+  if (get_ptr_info_alignment (node, &align, &misalign))
+    {
+      pp_printf (pp, "# ALIGN = %u, MISALIGN = %u", align, misalign);
       newline_and_indent (pp, spc);
-      if (get_ptr_info_alignment (node, &align, &misalign))
-       {
-         pp_printf (pp, "# ALIGN = %u, MISALIGN = %u", align, misalign);
-         newline_and_indent (pp, spc);
-       }
     }
 
   if (SSA_NAME_RANGE_INFO (node))
diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc
index 8fb248729fe5..6f6a46f6179f 100644
--- a/gcc/gimple-range.cc
+++ b/gcc/gimple-range.cc
@@ -616,7 +616,7 @@ gimple_ranger::reset_range_info (tree name)
 }
 
 // This routine will export whatever global ranges are known to GCC
-// SSA_RANGE_NAME_INFO and SSA_NAME_PTR_INFO fields.
+// SSA_NAME_RANGE_INFO field.
 
 void
 gimple_ranger::export_global_ranges ()
diff --git a/gcc/ipa-icf.cc b/gcc/ipa-icf.cc
index c421f676b27c..3a7e99da378a 100644
--- a/gcc/ipa-icf.cc
+++ b/gcc/ipa-icf.cc
@@ -3526,7 +3526,7 @@ sem_item_optimizer::merge_classes (unsigned int 
prev_class_count,
 /* Fixup points to set PT.  */
 
 void
-sem_item_optimizer::fixup_pt_set (struct pt_solution *pt)
+sem_item_optimizer::fixup_pt_set (const pt_solution *pt)
 {
   if (pt->vars == NULL)
     return;
@@ -3573,8 +3573,8 @@ sem_item_optimizer::fixup_points_to_sets (void)
 
       FOR_EACH_SSA_NAME (i, name, fn)
        if (POINTER_TYPE_P (TREE_TYPE (name))
-           && SSA_NAME_PTR_INFO (name))
-         fixup_pt_set (&SSA_NAME_PTR_INFO (name)->pt);
+           && ssa_name_pt_solution (name))
+         fixup_pt_set (ssa_name_pt_solution (name));
       fixup_pt_set (&fn->gimple_df->escaped);
       fixup_pt_set (&fn->gimple_df->escaped_return);
 
diff --git a/gcc/ipa-icf.h b/gcc/ipa-icf.h
index 4135ad3eb9c8..b1ccd00af1be 100644
--- a/gcc/ipa-icf.h
+++ b/gcc/ipa-icf.h
@@ -589,7 +589,7 @@ private:
   void fixup_points_to_sets (void);
 
   /* Fixup points to set PT.  */
-  void fixup_pt_set (struct pt_solution *pt);
+  void fixup_pt_set (const pt_solution *pt);
 
   /* Adds a newly created congruence class CLS to worklist.  */
   void worklist_push (congruence_class *cls);
diff --git a/gcc/targhooks.cc b/gcc/targhooks.cc
index 21cbfda48018..88582e4fa516 100644
--- a/gcc/targhooks.cc
+++ b/gcc/targhooks.cc
@@ -1699,8 +1699,8 @@ default_ref_may_alias_errno (ao_ref *ref)
   else if (TREE_CODE (base) == MEM_REF
           && TREE_CODE (TREE_OPERAND (base, 0)) == SSA_NAME)
     {
-      struct ptr_info_def *pi = SSA_NAME_PTR_INFO (TREE_OPERAND (base, 0));
-      return !pi || pi->pt.anything || pi->pt.nonlocal;
+      const pt_solution *pt = ssa_name_pt_solution (TREE_OPERAND (base, 0));
+      return !pt || pt->anything || pt->nonlocal;
     }
   return false;
 }
diff --git a/gcc/tree-core.h b/gcc/tree-core.h
index 80d0540c7632..6bab44f3c6d6 100644
--- a/gcc/tree-core.h
+++ b/gcc/tree-core.h
@@ -1739,7 +1739,7 @@ struct GTY(()) tree_ssa_name {
 
   /* Value range information for every type of SSA name.
      The aliasing information for a prange is stored in prange_storage.
-     See SSA_NAME_PTR_INFO in tree-ssanames.h.  */
+     See ssa_name_pt_solution in tree-ssanames.h.  */
   struct GTY (()) vrange_storage *range_info;
   /* Immediate uses list for this SSA_NAME.  */
   struct ssa_use_operand_t imm_uses;
diff --git a/gcc/tree-data-ref.cc b/gcc/tree-data-ref.cc
index 400a405792bb..9358023c4ad7 100644
--- a/gcc/tree-data-ref.cc
+++ b/gcc/tree-data-ref.cc
@@ -1508,7 +1508,7 @@ dr_analyze_alias (struct data_reference *dr)
     {
       addr = TREE_OPERAND (base, 0);
       if (TREE_CODE (addr) == SSA_NAME)
-       DR_PTR_INFO (dr) = SSA_NAME_PTR_INFO (addr);
+       DR_PTR_INFO (dr) = ssa_name_pt_solution (addr);
     }
 }
 
@@ -3109,13 +3109,12 @@ dr_may_alias_p (const struct data_reference *a, const 
struct data_reference *b,
   /* Try the points-to information recorded for the base pointers the
      references were originally analyzed from.  DR_BASE_OBJECT can be less
      precise, rooting at another SSA name or at one created after points-to
-     information was computed and thus without SSA_NAME_PTR_INFO.  A
+     information was computed and thus without points-to info.  A
      recorded solution is not revalidated.  It covers every dynamic value
      of its SSA name, so it holds for cross-iteration queries as well.  */
-  struct ptr_info_def *pi_a = DR_PTR_INFO (a);
-  struct ptr_info_def *pi_b = DR_PTR_INFO (b);
-  if (pi_a && pi_b
-      && !pt_solutions_intersect (&pi_a->pt, &pi_b->pt))
+  const pt_solution *pt_a = DR_PTR_INFO (a);
+  const pt_solution *pt_b = DR_PTR_INFO (b);
+  if (pt_a && pt_b && !pt_solutions_intersect (pt_a, pt_b))
     return false;
 
   if ((TREE_CODE (addr_a) == MEM_REF || TREE_CODE (addr_a) == TARGET_MEM_REF)
diff --git a/gcc/tree-data-ref.h b/gcc/tree-data-ref.h
index ba901a5f6cee..af9ad3cdc557 100644
--- a/gcc/tree-data-ref.h
+++ b/gcc/tree-data-ref.h
@@ -129,9 +129,9 @@ struct indices
 
 struct dr_alias
 {
-  /* The alias information that should be used for new pointers to this
-     location.  */
-  struct ptr_info_def *ptr_info;
+  /* The base pointer whose points-to information should be used for new
+     pointers to this location or NULL.  */
+  const pt_solution *ptr_info;
 };
 
 /* An integer vector.  A vector formally consists of an element of a vector
diff --git a/gcc/tree-if-conv.cc b/gcc/tree-if-conv.cc
index da8d0d20aca8..b44b96ff7968 100644
--- a/gcc/tree-if-conv.cc
+++ b/gcc/tree-if-conv.cc
@@ -2754,7 +2754,7 @@ predicate_load_or_store (gimple_stmt_iterator *gsi, 
gassign *stmt, tree mask)
   tree ptr = build_int_cst (reference_alias_ptr_type (ref),
                            get_object_alignment (ref));
   /* Copy points-to info if possible.  */
-  if (TREE_CODE (addr) == SSA_NAME && !SSA_NAME_PTR_INFO (addr))
+  if (TREE_CODE (addr) == SSA_NAME && !ssa_name_pt_solution (addr))
     copy_ref_info (build2 (MEM_REF, TREE_TYPE (ref), addr, ptr),
                   ref);
   if (TREE_CODE (lhs) == SSA_NAME)
diff --git a/gcc/tree-inline.cc b/gcc/tree-inline.cc
index 01d66537d42a..7d73d5959073 100644
--- a/gcc/tree-inline.cc
+++ b/gcc/tree-inline.cc
@@ -234,7 +234,7 @@ remap_ssa_name (tree name, copy_body_data *id)
          && DECL_IGNORED_P (var)
          && !DECL_NAME (var)))
     {
-      struct ptr_info_def *pi;
+      const pt_solution *pt;
       new_tree = make_ssa_name (remap_type (TREE_TYPE (name), id));
       if (!var && SSA_NAME_IDENTIFIER (name))
        SET_SSA_NAME_VAR_OR_IDENTIFIER (new_tree, SSA_NAME_IDENTIFIER (name));
@@ -245,12 +245,9 @@ remap_ssa_name (tree name, copy_body_data *id)
       if (id->src_cfun->gimple_df
          && id->src_cfun->gimple_df->ipa_pta
          && POINTER_TYPE_P (TREE_TYPE (name))
-         && (pi = SSA_NAME_PTR_INFO (name))
-         && !pi->pt.anything)
-       {
-         struct ptr_info_def *new_pi = get_ptr_info (new_tree);
-         new_pi->pt = pi->pt;
-       }
+         && (pt = ssa_name_pt_solution (name))
+         && !pt->anything)
+       set_ssa_name_pt_solution (new_tree, *pt);
       /* So can range-info.  */
       if (!POINTER_TYPE_P (TREE_TYPE (name))
          && SSA_NAME_RANGE_INFO (name))
@@ -273,7 +270,7 @@ remap_ssa_name (tree name, copy_body_data *id)
          || TREE_CODE (SSA_NAME_VAR (name)) != RESULT_DECL
          || !id->transform_return_to_modify))
     {
-      struct ptr_info_def *pi;
+      const pt_solution *pt;
       new_tree = make_ssa_name (new_tree);
       insert_decl_map (id, name, new_tree);
       SSA_NAME_OCCURS_IN_ABNORMAL_PHI (new_tree)
@@ -282,12 +279,9 @@ remap_ssa_name (tree name, copy_body_data *id)
       if (id->src_cfun->gimple_df
          && id->src_cfun->gimple_df->ipa_pta
          && POINTER_TYPE_P (TREE_TYPE (name))
-         && (pi = SSA_NAME_PTR_INFO (name))
-         && !pi->pt.anything)
-       {
-         struct ptr_info_def *new_pi = get_ptr_info (new_tree);
-         new_pi->pt = pi->pt;
-       }
+         && (pt = ssa_name_pt_solution (name))
+         && !pt->anything)
+       set_ssa_name_pt_solution (new_tree, *pt);
       /* So can range-info.  */
       if (!POINTER_TYPE_P (TREE_TYPE (name))
          && SSA_NAME_RANGE_INFO (name))
diff --git a/gcc/tree-ssa-address.cc b/gcc/tree-ssa-address.cc
index 30baf81d7892..22af52be8a23 100644
--- a/gcc/tree-ssa-address.cc
+++ b/gcc/tree-ssa-address.cc
@@ -1026,23 +1026,24 @@ copy_ref_info (tree new_ref, tree old_ref)
      or decl base to the new one.  */
   if (new_ptr_base
       && TREE_CODE (new_ptr_base) == SSA_NAME
-      && !SSA_NAME_PTR_INFO (new_ptr_base))
+      && !ssa_name_pt_solution (new_ptr_base))
     {
       if ((TREE_CODE (base) == MEM_REF
           || TREE_CODE (base) == TARGET_MEM_REF)
          && TREE_CODE (TREE_OPERAND (base, 0)) == SSA_NAME
-         && SSA_NAME_PTR_INFO (TREE_OPERAND (base, 0)))
+         && ssa_name_pt_solution (TREE_OPERAND (base, 0)))
        {
-         duplicate_ssa_name_ptr_info
-           (new_ptr_base, SSA_NAME_PTR_INFO (TREE_OPERAND (base, 0)));
+         duplicate_ssa_name_ptr_info (new_ptr_base,
+                                      TREE_OPERAND (base, 0));
          reset_flow_sensitive_info (new_ptr_base);
        }
       else if (VAR_P (base)
               || TREE_CODE (base) == PARM_DECL
               || TREE_CODE (base) == RESULT_DECL)
        {
-         struct ptr_info_def *pi = get_ptr_info (new_ptr_base);
-         pt_solution_set_var (&pi->pt, base);
+         pt_solution pt;
+         pt_solution_set_var (&pt, base);
+         set_ssa_name_pt_solution (new_ptr_base, pt);
        }
     }
 
diff --git a/gcc/tree-ssa-alias.cc b/gcc/tree-ssa-alias.cc
index a8196d116355..23490c07ecdd 100644
--- a/gcc/tree-ssa-alias.cc
+++ b/gcc/tree-ssa-alias.cc
@@ -60,7 +60,7 @@ along with GCC; see the file COPYING3.  If not see
    a generation count for memory references.
 
    SSA_NAME pointers may have associated points-to information
-   accessible via the SSA_NAME_PTR_INFO macro.  Flow-insensitive
+   accessible via ssa_name_pt_solution.  Flow-insensitive
    points-to information is (re-)computed by the TODO_rebuild_alias
    pass manager todo.  Points-to information is also used for more
    precise tracking of call-clobbered and call-used variables and
@@ -220,22 +220,22 @@ dump_alias_stats (FILE *s)
 bool
 ptr_deref_may_alias_global_p (tree ptr, bool escaped_local_p)
 {
-  struct ptr_info_def *pi;
+  const pt_solution *pt;
 
   /* If we end up with a pointer constant here that may point
      to global memory.  */
   if (TREE_CODE (ptr) != SSA_NAME || !POINTER_TYPE_P (TREE_TYPE (ptr)))
     return true;
 
-  pi = SSA_NAME_PTR_INFO (ptr);
+  pt = ssa_name_pt_solution (ptr);
 
   /* If we do not have points-to information for this variable,
      we have to punt.  */
-  if (!pi)
+  if (!pt)
     return true;
 
   /* ???  This does not use TBAA to prune globals ptr may not access.  */
-  return pt_solution_includes_global (&pi->pt, escaped_local_p);
+  return pt_solution_includes_global (pt, escaped_local_p);
 }
 
 /* Return true, if dereferencing PTR may alias with a local automatic
@@ -244,21 +244,21 @@ ptr_deref_may_alias_global_p (tree ptr, bool 
escaped_local_p)
 bool
 ptr_deref_may_alias_auto_p (tree ptr)
 {
-  struct ptr_info_def *pi;
+  const pt_solution *pt;
 
   /* If we end up with a pointer constant here that may point
      to local stack memory.  */
   if (TREE_CODE (ptr) != SSA_NAME || !POINTER_TYPE_P (TREE_TYPE (ptr)))
     return true;
 
-  pi = SSA_NAME_PTR_INFO (ptr);
+  pt = ssa_name_pt_solution (ptr);
 
   /* If we do not have points-to information for this variable,
      we have to punt.  */
-  if (!pi)
+  if (!pt)
     return true;
 
-  return pt_solution_includes_auto (&pi->pt);
+  return pt_solution_includes_auto (pt);
 }
 
 
@@ -269,7 +269,7 @@ ptr_deref_may_alias_auto_p (tree ptr)
 static bool
 ptr_deref_may_alias_decl_p (tree ptr, tree decl)
 {
-  struct ptr_info_def *pi;
+  const pt_solution *pt;
 
   /* Conversions are irrelevant for points-to information and
      data-dependence analysis can feed us those.  */
@@ -326,11 +326,11 @@ ptr_deref_may_alias_decl_p (tree ptr, tree decl)
 
   /* If we do not have useful points-to information for this pointer
      we cannot disambiguate anything else.  */
-  pi = SSA_NAME_PTR_INFO (ptr);
-  if (!pi)
+  pt = ssa_name_pt_solution (ptr);
+  if (!pt)
     return true;
 
-  return pt_solution_includes (&pi->pt, decl);
+  return pt_solution_includes (pt, decl);
 }
 
 /* Return true if dereferenced PTR1 and PTR2 may alias.
@@ -340,7 +340,7 @@ ptr_deref_may_alias_decl_p (tree ptr, tree decl)
 bool
 ptr_derefs_may_alias_p (tree ptr1, tree ptr2)
 {
-  struct ptr_info_def *pi1, *pi2;
+  const pt_solution *pt1, *pt2;
 
   /* Conversions are irrelevant for points-to information and
      data-dependence analysis can feed us those.  */
@@ -413,14 +413,14 @@ ptr_derefs_may_alias_p (tree ptr1, tree ptr2)
 
   /* If we do not have useful points-to information for either pointer
      we cannot disambiguate anything else.  */
-  pi1 = SSA_NAME_PTR_INFO (ptr1);
-  pi2 = SSA_NAME_PTR_INFO (ptr2);
-  if (!pi1 || !pi2)
+  pt1 = ssa_name_pt_solution (ptr1);
+  pt2 = ssa_name_pt_solution (ptr2);
+  if (!pt1 || !pt2)
     return true;
 
   /* ???  This does not use TBAA to prune decls from the intersection
      that not both pointers may access.  */
-  return pt_solutions_intersect (&pi1->pt, &pi2->pt);
+  return pt_solutions_intersect (pt1, pt2);
 }
 
 /* Return true if dereferencing PTR may alias *REF.
@@ -489,13 +489,13 @@ ptrs_compare_unequal (tree ptr1, tree ptr2)
     /* Other code handles this correctly, no need to duplicate it here.  */;
   else if (obj1 && TREE_CODE (ptr2) == SSA_NAME)
     {
-      struct ptr_info_def *pi = SSA_NAME_PTR_INFO (ptr2);
+      const pt_solution *pt = ssa_name_pt_solution (ptr2);
       /* We may not use restrict to optimize pointer comparisons.
          See PR71062.  So we have to assume that restrict-pointed-to
         may be in fact obj1.  */
-      if (!pi
-         || pi->pt.vars_contains_restrict
-         || pi->pt.vars_contains_interposable)
+      if (!pt
+         || pt->vars_contains_restrict
+         || pt->vars_contains_interposable)
        return false;
       if (VAR_P (obj1)
          && (TREE_STATIC (obj1) || DECL_EXTERNAL (obj1)))
@@ -507,34 +507,34 @@ ptrs_compare_unequal (tree ptr1, tree ptr2)
              || ! decl_binds_to_current_def_p (obj1))
            return false;
        }
-      return !pt_solution_includes (&pi->pt, obj1);
+      return !pt_solution_includes (pt, obj1);
     }
   else if (TREE_CODE (ptr1) == SSA_NAME)
     {
-      struct ptr_info_def *pi1 = SSA_NAME_PTR_INFO (ptr1);
-      if (!pi1
-         || pi1->pt.vars_contains_restrict
-         || pi1->pt.vars_contains_interposable)
+      const pt_solution *pt1 = ssa_name_pt_solution (ptr1);
+      if (!pt1
+         || pt1->vars_contains_restrict
+         || pt1->vars_contains_interposable)
        return false;
-      if (integer_zerop (ptr2) && !pi1->pt.null)
+      if (integer_zerop (ptr2) && !pt1->null)
        return true;
       if (TREE_CODE (ptr2) == SSA_NAME)
        {
-         struct ptr_info_def *pi2 = SSA_NAME_PTR_INFO (ptr2);
-         if (!pi2
-             || pi2->pt.vars_contains_restrict
-             || pi2->pt.vars_contains_interposable)
+         const pt_solution *pt2 = ssa_name_pt_solution (ptr2);
+         if (!pt2
+             || pt2->vars_contains_restrict
+             || pt2->vars_contains_interposable)
            return false;
-         if ((!pi1->pt.null || !pi2->pt.null)
+         if ((!pt1->null || !pt2->null)
              /* ???  We do not represent FUNCTION_DECL and LABEL_DECL
                 in pt.vars but only set pt.vars_contains_nonlocal.  This
                 makes compares involving those and other nonlocals
                 imprecise.  */
-             && (!pi1->pt.vars_contains_nonlocal
-                 || !pi2->pt.vars_contains_nonlocal)
-             && (!pt_solution_includes_const_pool (&pi1->pt)
-                 || !pt_solution_includes_const_pool (&pi2->pt)))
-           return !pt_solutions_intersect (&pi1->pt, &pi2->pt);
+             && (!pt1->vars_contains_nonlocal
+                 || !pt2->vars_contains_nonlocal)
+             && (!pt_solution_includes_const_pool (pt1)
+                 || !pt_solution_includes_const_pool (pt2)))
+           return !pt_solutions_intersect (pt1, pt2);
        }
     }
 
@@ -642,14 +642,14 @@ dump_alias_info (FILE *file)
 
   FOR_EACH_SSA_NAME (i, ptr, cfun)
     {
-      struct ptr_info_def *pi;
+      const pt_solution *pt;
 
       if (!POINTER_TYPE_P (TREE_TYPE (ptr))
          || SSA_NAME_IN_FREE_LIST (ptr))
        continue;
 
-      pi = SSA_NAME_PTR_INFO (ptr);
-      if (pi)
+      pt = ssa_name_pt_solution (ptr);
+      if (pt)
        dump_points_to_info_for (file, ptr);
     }
 
@@ -669,7 +669,7 @@ debug_alias_info (void)
 /* Dump the points-to set *PT into FILE.  */
 
 void
-dump_points_to_solution (FILE *file, struct pt_solution *pt)
+dump_points_to_solution (FILE *file, const pt_solution *pt)
 {
   if (pt->anything)
     fprintf (file, ", points-to anything");
@@ -752,12 +752,12 @@ debug (pt_solution *ptr)
 void
 dump_points_to_info_for (FILE *file, tree ptr)
 {
-  struct ptr_info_def *pi = SSA_NAME_PTR_INFO (ptr);
+  const pt_solution *pt = ssa_name_pt_solution (ptr);
 
   print_generic_expr (file, ptr, dump_flags);
 
-  if (pi)
-    dump_points_to_solution (file, &pi->pt);
+  if (pt)
+    dump_points_to_solution (file, pt);
   else
     fprintf (file, ", points-to anything");
 
@@ -3006,11 +3006,11 @@ ref_maybe_used_by_call_p_1 (gcall *call, ao_ref *ref, 
bool tbaa_p)
            || TREE_CODE (base) == TARGET_MEM_REF)
           && TREE_CODE (TREE_OPERAND (base, 0)) == SSA_NAME)
     {
-      struct ptr_info_def *pi = SSA_NAME_PTR_INFO (TREE_OPERAND (base, 0));
-      if (!pi)
+      const pt_solution *pt = ssa_name_pt_solution (TREE_OPERAND (base, 0));
+      if (!pt)
        return true;
 
-      if (pt_solutions_intersect (gimple_call_use_set (call), &pi->pt))
+      if (pt_solutions_intersect (gimple_call_use_set (call), pt))
        return true;
     }
   else
@@ -3266,11 +3266,11 @@ call_may_clobber_ref_p_1 (gcall *call, ao_ref *ref, 
bool tbaa_p)
            || TREE_CODE (base) == TARGET_MEM_REF)
           && TREE_CODE (TREE_OPERAND (base, 0)) == SSA_NAME)
     {
-      struct ptr_info_def *pi = SSA_NAME_PTR_INFO (TREE_OPERAND (base, 0));
-      if (!pi)
+      const pt_solution *pt = ssa_name_pt_solution (TREE_OPERAND (base, 0));
+      if (!pt)
        return true;
 
-      return pt_solutions_intersect (gimple_call_clobber_set (call), &pi->pt);
+      return pt_solutions_intersect (gimple_call_clobber_set (call), pt);
     }
 
   return true;
@@ -3391,15 +3391,15 @@ same_addr_size_stores_p (tree base1, poly_int64 
offset1, poly_int64 size1,
   tree ptr = TREE_OPERAND (memref, 0);
   if (TREE_CODE (ptr) != SSA_NAME)
     return false;
-  struct ptr_info_def *pi = SSA_NAME_PTR_INFO (ptr);
+  const pt_solution *pt = ssa_name_pt_solution (ptr);
   unsigned int pt_uid;
-  if (pi == NULL
-      || !pt_solution_singleton_or_null_p (&pi->pt, &pt_uid))
+  if (pt == NULL
+      || !pt_solution_singleton_or_null_p (pt, &pt_uid))
     return false;
 
   /* Be conservative with non-call exceptions when the address might
      be NULL.  */
-  if (cfun->can_throw_non_call_exceptions && pi->pt.null)
+  if (cfun->can_throw_non_call_exceptions && pt->null)
     return false;
 
   /* Check that ptr points relative to obj.  */
diff --git a/gcc/tree-ssa-alias.h b/gcc/tree-ssa-alias.h
index ac88b86df348..2e6344a0b6ee 100644
--- a/gcc/tree-ssa-alias.h
+++ b/gcc/tree-ssa-alias.h
@@ -172,7 +172,7 @@ extern int walk_aliased_vdefs (ao_ref *, tree,
                               unsigned int limit = 0);
 extern void dump_alias_info (FILE *);
 extern void debug_alias_info (void);
-extern void dump_points_to_solution (FILE *, struct pt_solution *);
+extern void dump_points_to_solution (FILE *, const pt_solution *);
 extern void debug (pt_solution &ref);
 extern void debug (pt_solution *ptr);
 extern void dump_points_to_info_for (FILE *, tree);
@@ -183,12 +183,12 @@ extern void dump_alias_stats (FILE *);
 /* In tree-ssa-structalias.cc  */
 extern unsigned int compute_may_aliases (void);
 extern bool pt_solution_empty_p (const pt_solution *);
-extern bool pt_solution_singleton_or_null_p (struct pt_solution *, unsigned *);
-extern bool pt_solution_includes_global (struct pt_solution *, bool);
-extern bool pt_solution_includes_auto (struct pt_solution *);
-extern bool pt_solution_includes (struct pt_solution *, const_tree);
-extern bool pt_solution_includes_const_pool (struct pt_solution *);
-extern bool pt_solutions_intersect (struct pt_solution *, struct pt_solution 
*);
+extern bool pt_solution_singleton_or_null_p (const pt_solution *, unsigned *);
+extern bool pt_solution_includes_global (const pt_solution *, bool);
+extern bool pt_solution_includes_auto (const pt_solution *);
+extern bool pt_solution_includes (const pt_solution *, const_tree);
+extern bool pt_solution_includes_const_pool (const pt_solution *);
+extern bool pt_solutions_intersect (const pt_solution *, const pt_solution *);
 extern void pt_solution_reset (struct pt_solution *);
 extern void pt_solution_set (struct pt_solution *, bitmap, bool);
 extern void pt_solution_set_var (struct pt_solution *, tree);
diff --git a/gcc/tree-ssa-ccp.cc b/gcc/tree-ssa-ccp.cc
index 089c6ae3bf76..9bd288db99cf 100644
--- a/gcc/tree-ssa-ccp.cc
+++ b/gcc/tree-ssa-ccp.cc
@@ -2717,11 +2717,11 @@ fold_builtin_alloca_with_align (gimple *stmt)
      as it might need to handle more than one instance being
      live at the same time.  Instead of trying to detect this case
      (using the first UID would be OK) just give up for now.  */
-  struct ptr_info_def *pi = SSA_NAME_PTR_INFO (lhs);
+  const pt_solution *pt = ssa_name_pt_solution (lhs);
   unsigned uid = 0;
-  if (pi != NULL
-      && !pi->pt.anything
-      && !pt_solution_singleton_or_null_p (&pi->pt, &uid))
+  if (pt != NULL
+      && !pt->anything
+      && !pt_solution_singleton_or_null_p (pt, &uid))
     return NULL_TREE;
 
   /* Declare array.  */
diff --git a/gcc/tree-ssa-loop-ivopts.cc b/gcc/tree-ssa-loop-ivopts.cc
index 1a51c7046fbd..afc85d9009e1 100644
--- a/gcc/tree-ssa-loop-ivopts.cc
+++ b/gcc/tree-ssa-loop-ivopts.cc
@@ -7543,12 +7543,7 @@ rewrite_use_nonlinear_expr (struct ivopts_data *data,
       comp = force_gimple_operand (comp, &seq, true, NULL);
       gimple_seq_add_seq (&stmt_list, seq);
       if (POINTER_TYPE_P (TREE_TYPE (tgt)))
-       {
-         duplicate_ssa_name_ptr_info (comp, SSA_NAME_PTR_INFO (tgt));
-         /* As this isn't a plain copy we have to reset alignment
-            information.  */
-         mark_ptr_info_alignment_unknown (comp);
-       }
+       duplicate_ssa_name_ptr_info (comp, tgt);
     }
 
   gsi_insert_seq_before (&bsi, stmt_list, GSI_SAME_STMT);
diff --git a/gcc/tree-ssa-loop-prefetch.cc b/gcc/tree-ssa-loop-prefetch.cc
index 16f3c02d7f91..4152e505dcf4 100644
--- a/gcc/tree-ssa-loop-prefetch.cc
+++ b/gcc/tree-ssa-loop-prefetch.cc
@@ -1210,12 +1210,7 @@ issue_prefetch_ref (struct mem_ref *ref, unsigned 
unroll_factor, unsigned ahead)
       if (addr_base != addr
          && TREE_CODE (addr_base) == SSA_NAME
          && TREE_CODE (addr) == SSA_NAME)
-       {
-         duplicate_ssa_name_ptr_info (addr, SSA_NAME_PTR_INFO (addr_base));
-         /* As this isn't a plain copy we have to reset alignment
-            information.  */
-         mark_ptr_info_alignment_unknown (addr);
-       }
+       duplicate_ssa_name_ptr_info (addr, addr_base);
 
       /* Create the prefetch instruction.  */
       prefetch = gimple_build_call (builtin_decl_explicit (BUILT_IN_PREFETCH),
diff --git a/gcc/tree-ssa-structalias.cc b/gcc/tree-ssa-structalias.cc
index 76fb3600e748..1db7c69be657 100644
--- a/gcc/tree-ssa-structalias.cc
+++ b/gcc/tree-ssa-structalias.cc
@@ -868,7 +868,7 @@ find_what_var_points_to (tree fndecl, varinfo_t orig_vi)
   *slot = pt = XOBNEW (&final_solutions_obstack, struct pt_solution);
   memset (pt, 0, sizeof (struct pt_solution));
 
-  /* Translate artificial variables into SSA_NAME_PTR_INFO
+  /* Translate artificial variables into points-to info
      attributes.  */
   EXECUTE_IF_SET_IN_BITMAP (vi->solution, 0, i, bi)
     {
@@ -929,7 +929,6 @@ find_what_var_points_to (tree fndecl, varinfo_t orig_vi)
 static void
 find_what_p_points_to (tree fndecl, tree p)
 {
-  struct ptr_info_def *pi;
   tree lookup_p = p;
   varinfo_t vi;
   prange vr;
@@ -948,10 +947,10 @@ find_what_p_points_to (tree fndecl, tree p)
   if (!vi)
     return;
 
-  pi = get_ptr_info (p);
-  pi->pt = find_what_var_points_to (fndecl, vi);
+  pt_solution pt = find_what_var_points_to (fndecl, vi);
   /* Conservatively set to NULL from PTA (to true). */
-  pi->pt.null = 1;
+  pt.null = 1;
+  set_ssa_name_pt_solution (p, pt);
   /* Preserve pointer nonnull globally computed.  */
   if (nonnull)
     set_ptr_nonnull (p);
@@ -1090,7 +1089,7 @@ pt_solution_empty_p (const pt_solution *pt)
    return the var uid in *UID.  */
 
 bool
-pt_solution_singleton_or_null_p (struct pt_solution *pt, unsigned *uid)
+pt_solution_singleton_or_null_p (const pt_solution *pt, unsigned *uid)
 {
   if (pt->anything || pt->nonlocal || pt->escaped || pt->ipa_escaped
       || pt->vars == NULL
@@ -1106,7 +1105,7 @@ pt_solution_singleton_or_null_p (struct pt_solution *pt, 
unsigned *uid)
    considered global.  */
 
 bool
-pt_solution_includes_global (struct pt_solution *pt, bool escaped_local_p)
+pt_solution_includes_global (const pt_solution *pt, bool escaped_local_p)
 {
   if (pt->anything
       || pt->nonlocal
@@ -1136,7 +1135,7 @@ pt_solution_includes_global (struct pt_solution *pt, bool 
escaped_local_p)
    storage.  */
 
 bool
-pt_solution_includes_auto (struct pt_solution *pt)
+pt_solution_includes_auto (const pt_solution *pt)
 {
   if (pt->anything
       || pt->vars_contains_auto)
@@ -1157,7 +1156,7 @@ pt_solution_includes_auto (struct pt_solution *pt)
    declaration DECL.  */
 
 static bool
-pt_solution_includes_1 (struct pt_solution *pt, const_tree decl)
+pt_solution_includes_1 (const pt_solution *pt, const_tree decl)
 {
   if (pt->anything)
     return true;
@@ -1184,7 +1183,7 @@ pt_solution_includes_1 (struct pt_solution *pt, 
const_tree decl)
 }
 
 bool
-pt_solution_includes (struct pt_solution *pt, const_tree decl)
+pt_solution_includes (const pt_solution *pt, const_tree decl)
 {
   bool res = pt_solution_includes_1 (pt, decl);
   if (res)
@@ -1198,7 +1197,7 @@ pt_solution_includes (struct pt_solution *pt, const_tree 
decl)
    constant pool entry.  */
 
 bool
-pt_solution_includes_const_pool (struct pt_solution *pt)
+pt_solution_includes_const_pool (const pt_solution *pt)
 {
   return (pt->const_pool
          || pt->nonlocal
@@ -1210,7 +1209,7 @@ pt_solution_includes_const_pool (struct pt_solution *pt)
    intersection.  */
 
 static bool
-pt_solutions_intersect_1 (struct pt_solution *pt1, struct pt_solution *pt2)
+pt_solutions_intersect_1 (const pt_solution *pt1, const pt_solution *pt2)
 {
   if (pt1->anything || pt2->anything)
     return true;
@@ -1259,7 +1258,7 @@ pt_solutions_intersect_1 (struct pt_solution *pt1, struct 
pt_solution *pt2)
 }
 
 bool
-pt_solutions_intersect (struct pt_solution *pt1, struct pt_solution *pt2)
+pt_solutions_intersect (const pt_solution *pt1, const pt_solution *pt2)
 {
   bool res = pt_solutions_intersect_1 (pt1, pt2);
   if (res)
diff --git a/gcc/tree-ssa.cc b/gcc/tree-ssa.cc
index b0cd2aa1b43b..1be5290c85f1 100644
--- a/gcc/tree-ssa.cc
+++ b/gcc/tree-ssa.cc
@@ -1075,7 +1075,7 @@ verify_ssa (bool check_modified_stmt, bool 
check_ssa_operands)
       /* Keep track of SSA names present in the IL.  */
       size_t i;
       tree name;
-      hash_map <void *, tree> ssa_info;
+      hash_map <const void *, tree> ssa_info;
 
       FOR_EACH_SSA_NAME (i, name, cfun)
        {
@@ -1093,9 +1093,9 @@ verify_ssa (bool check_modified_stmt, bool 
check_ssa_operands)
                goto err;
            }
 
-         void *info = NULL;
+         const void *info = NULL;
          if (POINTER_TYPE_P (TREE_TYPE (name)))
-           info = SSA_NAME_PTR_INFO (name);
+           info = ssa_name_pt_solution (name);
          else if (INTEGRAL_TYPE_P (TREE_TYPE (name)))
            info = SSA_NAME_RANGE_INFO (name);
          if (info)
diff --git a/gcc/tree-ssanames.cc b/gcc/tree-ssanames.cc
index 5ab3f156e0c5..0660c6177677 100644
--- a/gcc/tree-ssanames.cc
+++ b/gcc/tree-ssanames.cc
@@ -114,7 +114,7 @@ range_info_free (tree name)
 /* Return the aliasing information for ssa-name NAME, or NULL if there
    is none.  Return NULL for non pointer types.  */
 
-struct ptr_info_def *
+static inline struct ptr_info_def *
 ssa_name_ptr_info (const_tree name)
 {
   vrange_storage *mem = SSA_NAME_RANGE_INFO (name);
@@ -123,6 +123,28 @@ ssa_name_ptr_info (const_tree name)
   return static_cast <prange_storage *> (mem)->ptr_info;
 }
 
+/* Defined below.  */
+static struct ptr_info_def *get_ptr_info (tree);
+
+/* Return the points-to solution for ssa-name NAME.  Return NULL if it has
+   none or is a non pointer types.  */
+
+const pt_solution *
+ssa_name_pt_solution (const_tree name)
+{
+  struct ptr_info_def *pi = ssa_name_ptr_info (name);
+  return pi ? &pi->pt : NULL;
+}
+
+/* Make PT the points-to solution for NAME, which must have pointer type.  */
+
+void
+set_ssa_name_pt_solution (tree name, const pt_solution &pt)
+{
+  /* get_ptr_info asserts NAME is a pointer type.  */
+  get_ptr_info (name)->pt = pt;
+}
+
 /* Return the global range for NAME in R.  */
 
 inline void
@@ -142,7 +164,7 @@ range_info_set_range (tree name, const vrange &r)
       // Aliasing info belongs to NAME, not to the prange storage object which
       // might get reallocated.  ptr_info_def addresses may be cached
       // elsewhere, so save and copy it back after any reallocation.
-      ptr_info_def *pi = SSA_NAME_PTR_INFO (name);
+      ptr_info_def *pi = ssa_name_ptr_info (name);
       if (range_info_p (name))
        range_info_free (name);
 
@@ -754,7 +776,7 @@ bool
 get_ptr_info_alignment (const_tree name, unsigned int *alignp,
                        unsigned int *misalignp)
 {
-  struct ptr_info_def *pi = SSA_NAME_PTR_INFO (name);
+  struct ptr_info_def *pi = ssa_name_ptr_info (name);
 
   if (pi && pi->align)
     {
@@ -773,7 +795,7 @@ get_ptr_info_alignment (const_tree name, unsigned int 
*alignp,
 void
 mark_ptr_info_alignment_unknown (tree name)
 {
-  struct ptr_info_def *pi = SSA_NAME_PTR_INFO (name);
+  struct ptr_info_def *pi = ssa_name_ptr_info (name);
 
   if (pi)
     {
@@ -817,14 +839,14 @@ set_ssa_name_ptr_info (tree name, struct ptr_info_def *pi)
 /* Return the alias information associated with pointer T.  It creates a
    new instance if none existed.  */
 
-struct ptr_info_def *
+static struct ptr_info_def *
 get_ptr_info (tree t)
 {
   struct ptr_info_def *pi;
 
   gcc_assert (POINTER_TYPE_P (TREE_TYPE (t)));
 
-  pi = SSA_NAME_PTR_INFO (t);
+  pi = ssa_name_ptr_info (t);
   if (pi == NULL)
     {
       // The cleared allocation leaves align and misalign zero, which is
@@ -857,25 +879,40 @@ copy_ssa_name_fn (struct function *fn, tree name, gimple 
*stmt)
   return new_name;
 }
 
-
-/* Creates a duplicate of the ptr_info_def at PTR_INFO for use by
-   the SSA name NAME.  */
+/* Give DEST its own copy of the points-to and alignment information of
+   the SSA name SRC.  SRC may be NULL_TREE or carry no information, in
+   which case DEST is left alone.  */
 
 void
-duplicate_ssa_name_ptr_info (tree name, struct ptr_info_def *ptr_info)
+duplicate_ssa_name_ptr_info (tree dest, const pt_solution* pt)
 {
-  struct ptr_info_def *new_ptr_info;
+  gcc_assert (POINTER_TYPE_P (TREE_TYPE (dest)));
+  gcc_assert (!ssa_name_ptr_info (dest));
 
-  gcc_assert (POINTER_TYPE_P (TREE_TYPE (name)));
-  gcc_assert (!SSA_NAME_PTR_INFO (name));
+  if (!pt)
+    return;
+
+  struct ptr_info_def *new_ptr_info = ggc_alloc<ptr_info_def> ();
+  new_ptr_info->pt = *pt;
+
+  // Alignment info is not copied, so its set to zero.
+  new_ptr_info->align = 0;
+  new_ptr_info->misalign = 0;
+  set_ssa_name_ptr_info (dest, new_ptr_info);
+}
 
+/* Give DEST its own copy of the points-to and alignment information of
+   the SSA name SRC.  SRC may be NULL_TREE or carry no information, in
+   which case DEST is left alone.  */
+
+void
+duplicate_ssa_name_ptr_info (tree dest, tree src)
+{
+  struct ptr_info_def *ptr_info = (src ? ssa_name_ptr_info (src) : NULL);
   if (!ptr_info)
     return;
 
-  new_ptr_info = ggc_alloc<ptr_info_def> ();
-  *new_ptr_info = *ptr_info;
-
-  set_ssa_name_ptr_info (name, new_ptr_info);
+  duplicate_ssa_name_ptr_info (dest, &(ptr_info->pt));
 }
 
 /* Copy any global range and aliasing information from SRC to NAME.  */
@@ -895,7 +932,11 @@ duplicate_ssa_name_range_info (tree name, tree src)
   /* For a pointer the aliasing info lives in the storage just created,
      so it has to be copied as part of the same operation.  */
   if (POINTER_TYPE_P (TREE_TYPE (src)))
-    duplicate_ssa_name_ptr_info (name, SSA_NAME_PTR_INFO (src));
+    duplicate_ssa_name_ptr_info (name, src);
+
+  unsigned align, misalign;
+  if (get_ptr_info_alignment (src, &align, &misalign))
+     set_ptr_info_alignment (name, align, misalign);
 }
 
 /* For a SSA copy DEST = SRC duplicate SSA info present on DEST to SRC
@@ -937,7 +978,7 @@ void
 reset_flow_sensitive_info (tree name)
 {
   /* Aliasing info is not flow sensitive, so preserve it if present.  */
-  ptr_info_def *pi = SSA_NAME_PTR_INFO (name);
+  ptr_info_def *pi = ssa_name_ptr_info (name);
   SSA_NAME_RANGE_INFO (name) = NULL;
   if (pi)
     {
@@ -1101,7 +1142,7 @@ flow_sensitive_info_storage::save (tree name)
       align = 0;
       misalign = 0;
     }
-  auto ptr_info = SSA_NAME_PTR_INFO (name);
+  auto ptr_info = ssa_name_ptr_info (name);
   null = ptr_info ? ptr_info->pt.null : true;
 }
 
@@ -1118,7 +1159,7 @@ flow_sensitive_info_storage::restore (tree name)
       return;
     }
   gcc_assert (state == -1);
-  auto ptr_info = SSA_NAME_PTR_INFO (name);
+  auto ptr_info = ssa_name_ptr_info (name);
   /* If there was no flow sensitive info on the pointer
      just return, there is nothing to restore to.  */
   if (!ptr_info)
@@ -1127,7 +1168,7 @@ flow_sensitive_info_storage::restore (tree name)
     set_ptr_info_alignment (name, align, misalign);
   else
     mark_ptr_info_alignment_unknown (name);
-  SSA_NAME_PTR_INFO (name)->pt.null = null;
+  ssa_name_ptr_info (name)->pt.null = null;
 }
 
 /* Save off the flow sensitive info from NAME.
diff --git a/gcc/tree-ssanames.h b/gcc/tree-ssanames.h
index 311c4c2a1617..28fd467dc874 100644
--- a/gcc/tree-ssanames.h
+++ b/gcc/tree-ssanames.h
@@ -46,9 +46,12 @@ struct GTY(()) ptr_info_def
   unsigned int misalign;
 };
 
-/* Aliasing attributes for SSA_NAMEs for pointer-type variables.  */
-struct ptr_info_def *ssa_name_ptr_info (const_tree name);
-#define SSA_NAME_PTR_INFO(N) (ssa_name_ptr_info (N))
+/* Return NAME's points-to solution, or NULL if it has none.  Returns NULL
+   for a non pointer type.  */
+extern const pt_solution *ssa_name_pt_solution (const_tree name);
+
+/* Make PT the points-to solution for NAME, which must have pointer type.  */
+extern void set_ssa_name_pt_solution (tree name, const pt_solution &pt);
 
 #define SSANAMES(fun) (fun)->gimple_df->ssa_names
 #define DEFAULT_DEFS(fun) (fun)->gimple_df->default_defs
@@ -78,12 +81,12 @@ extern bool get_ptr_info_alignment (const_tree, unsigned 
int *,
                                    unsigned int *);
 extern void mark_ptr_info_alignment_unknown (tree);
 extern void set_ptr_info_alignment (tree, unsigned int, unsigned int);
-extern struct ptr_info_def *get_ptr_info (tree);
 extern void set_ptr_nonnull (tree);
 
 extern tree copy_ssa_name_fn (struct function *, tree, gimple *);
 extern tree duplicate_ssa_name_fn (struct function *, tree, gimple *);
-extern void duplicate_ssa_name_ptr_info (tree, struct ptr_info_def *);
+extern void duplicate_ssa_name_ptr_info (tree dest, const pt_solution *);
+extern void duplicate_ssa_name_ptr_info (tree dest, tree src);
 extern void duplicate_ssa_name_range_info (tree dest, tree src);
 extern void maybe_duplicate_ssa_info_at_copy (tree dest, tree src);
 extern void reset_flow_sensitive_info (tree);
diff --git a/gcc/tree-vect-data-refs.cc b/gcc/tree-vect-data-refs.cc
index 38889b734910..e65059081e71 100644
--- a/gcc/tree-vect-data-refs.cc
+++ b/gcc/tree-vect-data-refs.cc
@@ -5550,21 +5550,17 @@ static void
 vect_duplicate_ssa_name_ptr_info (tree name, dr_vec_info *dr_info)
 {
   if (DR_PTR_INFO (dr_info->dr))
-    {
-      duplicate_ssa_name_ptr_info (name, DR_PTR_INFO (dr_info->dr));
-      /* DR_PTR_INFO is for a base SSA name, not including constant or
-        variable offsets in the ref so its alignment info does not apply.  */
-      mark_ptr_info_alignment_unknown (name);
-    }
-  else if (!SSA_NAME_PTR_INFO (name))
+    duplicate_ssa_name_ptr_info (name, DR_PTR_INFO (dr_info->dr));
+  else if (!ssa_name_pt_solution (name))
     {
       tree base = get_base_address (dr_info->dr->ref);
       if (VAR_P (base)
          || TREE_CODE (base) == PARM_DECL
          || TREE_CODE (base) == RESULT_DECL)
        {
-         struct ptr_info_def *pi = get_ptr_info (name);
-         pt_solution_set_var (&pi->pt, base);
+         pt_solution pt;
+         pt_solution_set_var (&pt, base);
+         set_ssa_name_pt_solution (name, pt);
        }
     }
 }
@@ -5687,7 +5683,7 @@ vect_create_addr_base_for_vector_ref (vec_info *vinfo, 
stmt_vec_info stmt_info,
       /* We should only duplicate pointer info to newly created SSA names.  */
       && SSA_NAME_VAR (addr_base) == dest)
     {
-      gcc_assert (!SSA_NAME_PTR_INFO (addr_base));
+      gcc_assert (!ssa_name_pt_solution (addr_base));
       vect_duplicate_ssa_name_ptr_info (addr_base, dr_info);
     }
 
diff --git a/gcc/value-query.cc b/gcc/value-query.cc
index 3e64f431fd2c..e52900752438 100644
--- a/gcc/value-query.cc
+++ b/gcc/value-query.cc
@@ -592,14 +592,14 @@ get_ssa_name_range_info (vrange &r, const_tree name)
     r.set_varying (type);
 }
 
-// Return nonnull attribute of pointer NAME from SSA_NAME_PTR_INFO.
+// Return nonnull attribute of pointer NAME from its points-to solution.
 
 static inline bool
 get_ssa_name_ptr_info_nonnull (const_tree name)
 {
   gcc_assert (POINTER_TYPE_P (TREE_TYPE (name)));
-  struct ptr_info_def *pi = SSA_NAME_PTR_INFO (name);
-  if (pi == NULL)
+  const pt_solution *pt = ssa_name_pt_solution (name);
+  if (pt == NULL)
     return false;
   /* TODO Now pt->null is conservatively set to true in PTA
      analysis. vrp is the only pass (including ipa-vrp)
@@ -609,7 +609,7 @@ get_ssa_name_ptr_info_nonnull (const_tree name)
      When PTA analysis is improved, pt.anything, pt.nonlocal
      and pt.escaped may also has to be considered before
      deciding that pointer cannot point to NULL.  */
-  return !pi->pt.null;
+  return !pt->null;
 }
 
 // Update the global range for NAME into the SSA_RANGE_NAME_INFO and
diff --git a/gcc/value-range-storage.h b/gcc/value-range-storage.h
index 9eb03fc8e736..46e98684360c 100644
--- a/gcc/value-range-storage.h
+++ b/gcc/value-range-storage.h
@@ -126,7 +126,8 @@ public:
   bool fits_p (const prange &r) const;
   void dump () const;
 
-  // Pointer aliasing information.  Managed seperately via SSA_NAME_PTR_INFO.
+  // Pointer aliasing information.  Managed separately, and reached only
+  // through the accessors in tree-ssanames.h.
   struct ptr_info_def *ptr_info;
 
 private:

Reply via email to