From fd73537b313ab678323c5ca392a5b4d00572b647 Mon Sep 17 00:00:00 2001
From: Richard Guenther <rguenther@suse.de>
Date: Wed, 11 Jun 2008 09:22:27 +0000
Subject: [PATCH] tree-flow.h (may_point_to_global_var): Declare.

2008-06-11  Richard Guenther  <rguenther@suse.de>

	* tree-flow.h (may_point_to_global_var): Declare.
	* tree-ssa-alias.c (may_point_to_global_var): New function.
	* tree-ssa-sink.c (is_hidden_global_store): Use it.

From-SVN: r136657
---
 gcc/ChangeLog        |  6 ++++++
 gcc/tree-flow.h      |  1 +
 gcc/tree-ssa-alias.c | 17 +++++++++++++++++
 gcc/tree-ssa-sink.c  | 15 +--------------
 4 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index dd9588ea1c45..0d84391d2d7a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2008-06-11  Richard Guenther  <rguenther@suse.de>
+
+	* tree-flow.h (may_point_to_global_var): Declare.
+	* tree-ssa-alias.c (may_point_to_global_var): New function.
+	* tree-ssa-sink.c (is_hidden_global_store): Use it.
+
 2008-06-10  Kazu Hirata  <kazu@codesourcery.com>
 
 	* configure.ac: Teach that fido supports .debug_line.
diff --git a/gcc/tree-flow.h b/gcc/tree-flow.h
index 94d5a69f69cc..45711ae3f124 100644
--- a/gcc/tree-flow.h
+++ b/gcc/tree-flow.h
@@ -853,6 +853,7 @@ extern void dump_points_to_info_for (FILE *, tree);
 extern void debug_points_to_info_for (tree);
 extern bool may_be_aliased (tree);
 extern struct ptr_info_def *get_ptr_info (tree);
+extern bool may_point_to_global_var (tree);
 extern void new_type_alias (tree, tree, tree);
 extern void count_uses_and_derefs (tree, tree, unsigned *, unsigned *,
 				   unsigned *);
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
index 05c123c0e99c..e89e73b9f598 100644
--- a/gcc/tree-ssa-alias.c
+++ b/gcc/tree-ssa-alias.c
@@ -2783,6 +2783,23 @@ may_alias_p (tree ptr, alias_set_type mem_alias_set,
   return true;
 }
 
+/* Return true, if PTR may point to a global variable.  */
+
+bool
+may_point_to_global_var (tree ptr)
+{
+  struct ptr_info_def *pi = SSA_NAME_PTR_INFO (ptr);
+
+  /* If we do not have points-to information for this variable,
+     we have to punt.  */
+  if (!pi
+      || !pi->name_mem_tag)
+    return true;
+
+  /* The name memory tag is marked as global variable if the points-to
+     set contains a global variable.  */
+  return is_global_var (pi->name_mem_tag);
+}
 
 /* Add ALIAS to the set of variables that may alias VAR.  */
 
diff --git a/gcc/tree-ssa-sink.c b/gcc/tree-ssa-sink.c
index 8945a6126634..ebf54e2070b8 100644
--- a/gcc/tree-ssa-sink.c
+++ b/gcc/tree-ssa-sink.c
@@ -189,20 +189,7 @@ is_hidden_global_store (tree stmt)
 
 	}
       else if (INDIRECT_REF_P (lhs))
-	{
-	  tree ptr = TREE_OPERAND (lhs, 0);
-	  struct ptr_info_def *pi = SSA_NAME_PTR_INFO (ptr);
-	  tree nmt = (pi) ? pi->name_mem_tag : NULL_TREE;
-	  tree smt = symbol_mem_tag (SSA_NAME_VAR (ptr));
-
-	  /* If either the name tag or the symbol tag for PTR is a
-	     global variable, then the store is necessary.  */
-	  if ((nmt && is_global_var (nmt))
-	      || (smt && is_global_var (smt)))
-	    {
-	      return true;
-	    }
-	}
+	return may_point_to_global_var (TREE_OPERAND (lhs, 0));
       else
 	gcc_unreachable ();
     }
-- 
GitLab