This does a similar thing for inlining.   Currently, inlining bails if the type 
is POINTER.   This treats pointers just like normal ranges, except any local 
points to information is removed.  Rather than going through a prange, it 
efficiently goes through the prange storage that is in the global table.

Bootstraps on x86_64-pc-linux-gnu with no regressions.  OK?

Andrew




Now that prange is supported at the global level, we can inline it
as well, as long as we remove any local points to info.

        * tree-inline.cc (remap_ssa_name): Inline pointers after
        removing local points-to info.
        * tree-ssanames.cc (clear_function_local_points_to): New for
        global name.
        * tree-ssanames.h (clear_function_local_points_to): New prototype.
        * value-range-storage.cc (prange_storage::clear_local_points_to): New.
        * value-range-storage.h (prange_storage::clear_local_points_to): New
        prototype.
---
 gcc/tree-inline.cc         | 26 ++++++++++++++++----------
 gcc/tree-ssanames.cc       | 14 ++++++++++++++
 gcc/tree-ssanames.h        |  1 +
 gcc/value-range-storage.cc | 24 ++++++++++++++++++++++++
 gcc/value-range-storage.h  |  1 +
 5 files changed, 56 insertions(+), 10 deletions(-)

diff --git a/gcc/tree-inline.cc b/gcc/tree-inline.cc
index 7d73d595907..0f899430008 100644
--- a/gcc/tree-inline.cc
+++ b/gcc/tree-inline.cc
@@ -241,17 +241,20 @@ remap_ssa_name (tree name, copy_body_data *id)
       insert_decl_map (id, name, new_tree);
       SSA_NAME_OCCURS_IN_ABNORMAL_PHI (new_tree)
        = SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name);
-      /* At least IPA points-to info can be directly transferred.  */
+      /* Range-info can be transferred.  */
+      if (SSA_NAME_RANGE_INFO (name))
+       {
+         duplicate_ssa_name_range_info (new_tree, name);
+         /* If there is any local points to, clear it.  */
+         clear_function_local_points_to (new_tree);
+       }
+      /* IPA points-to info can be directly transferred.  */
       if (id->src_cfun->gimple_df
          && id->src_cfun->gimple_df->ipa_pta
          && POINTER_TYPE_P (TREE_TYPE (name))
          && (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))
-       duplicate_ssa_name_range_info (new_tree, name);
       return new_tree;
     }
 
@@ -275,17 +278,20 @@ remap_ssa_name (tree name, copy_body_data *id)
       insert_decl_map (id, name, new_tree);
       SSA_NAME_OCCURS_IN_ABNORMAL_PHI (new_tree)
        = SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name);
-      /* At least IPA points-to info can be directly transferred.  */
+      /* Range-info can be transferred.  */
+      if (SSA_NAME_RANGE_INFO (name))
+       {
+         duplicate_ssa_name_range_info (new_tree, name);
+         // If there is any local points to, clear it.
+         clear_function_local_points_to (new_tree);
+       }
+      /* IPA points-to info can be directly transferred.  */
       if (id->src_cfun->gimple_df
          && id->src_cfun->gimple_df->ipa_pta
          && POINTER_TYPE_P (TREE_TYPE (name))
          && (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))
-       duplicate_ssa_name_range_info (new_tree, name);
       if (SSA_NAME_IS_DEFAULT_DEF (name))
        {
          /* By inlining function having uninitialized variable, we might
diff --git a/gcc/tree-ssanames.cc b/gcc/tree-ssanames.cc
index b24cdc878ca..46ae07a49a9 100644
--- a/gcc/tree-ssanames.cc
+++ b/gcc/tree-ssanames.cc
@@ -978,6 +978,20 @@ clear_function_local_points_to (vrange &r)
   return false;
 }
 
+
+// If NAME is a pointer with local points_to information, clear it.
+// Return TRUE if it was changed.
+
+bool
+clear_function_local_points_to (tree name)
+{
+  prange_storage *s = ssa_name_prange_storage (name);
+  if (!s)
+    return false;
+  return s->clear_local_points_to ();
+}
+
+
 /* Copy any global range information from SRC to NAME.  */
 
 void
diff --git a/gcc/tree-ssanames.h b/gcc/tree-ssanames.h
index 219e11428a5..971fdce99c4 100644
--- a/gcc/tree-ssanames.h
+++ b/gcc/tree-ssanames.h
@@ -72,6 +72,7 @@ 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 bool clear_function_local_points_to (vrange &);
+extern bool clear_function_local_points_to (tree);
 extern void maybe_duplicate_ssa_info_at_copy (tree dest, tree src);
 extern void reset_flow_sensitive_info (tree);
 extern void reset_flow_sensitive_info_in_bb (basic_block);
diff --git a/gcc/value-range-storage.cc b/gcc/value-range-storage.cc
index b7b23e380e4..3f25c4c26dd 100644
--- a/gcc/value-range-storage.cc
+++ b/gcc/value-range-storage.cc
@@ -811,6 +811,30 @@ prange_storage::get_prange (prange &r, tree type) const
     r.verify_range ();
 }
 
+// If this prange contains any local points to infomration which
+// is not valid, clear it.
+
+bool
+prange_storage::clear_local_points_to ()
+{
+  switch (m_kind)
+    {
+      case PR_UNDEFINED:
+      case PR_VARYING:
+      case PR_ZERO:
+       return false;
+      default:
+       break;
+    }
+  if (m_pt && !is_gimple_ip_invariant (m_pt))
+    {
+      m_points_to_p = false;
+      m_pt = NULL;
+      return true;
+    }
+  return false;
+}
+
 bool
 prange_storage::equal_p (const prange &r) const
 {
diff --git a/gcc/value-range-storage.h b/gcc/value-range-storage.h
index d721961c6c2..b797cb83ce2 100644
--- a/gcc/value-range-storage.h
+++ b/gcc/value-range-storage.h
@@ -134,6 +134,7 @@ public:
   irange_bitmask get_bitmask (tree type) const;
   bool nonnull_p (tree type) const;
   void set_nonnull (tree type);
+  bool clear_local_points_to ();
   void dump () const;
 
   // The points-to solution for the SSA name is flow insensitive and is
-- 
2.56.0

Reply via email to