From 8b547e44f727908791650e822f7de16ef79e02ca Mon Sep 17 00:00:00 2001
From: Jan Hubicka <jh@suse.cz>
Date: Sat, 18 Sep 2004 09:31:30 +0200
Subject: [PATCH] tree-into-ssa.c (rewrite_ssa_into_ssa): Expect ssa_name to
 return NULL.

	* tree-into-ssa.c (rewrite_ssa_into_ssa):  Expect ssa_name to return
	NULL.
	* tree-ssa-alias.c (init_alias_info): Likewise.
	* tree-ssa.c (verify_flow_sensitive_alias_info): Likewise.
	(verify_ssa): Likewise.
	* tree-ssanames.c (make_ssa_name): Clear out ssa_names arrays.

From-SVN: r87698
---
 gcc/ChangeLog        |  9 +++++++++
 gcc/tree-into-ssa.c  |  5 +++--
 gcc/tree-ssa-alias.c |  2 +-
 gcc/tree-ssa.c       | 44 ++++++++++++++++++++++++--------------------
 gcc/tree-ssanames.c  |  3 +++
 5 files changed, 40 insertions(+), 23 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 9fa0b9b7cede..a69ec4bb8166 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2004-09-18  Jan Hubicka  <jh@suse.cz>
+
+	* tree-into-ssa.c (rewrite_ssa_into_ssa):  Expect ssa_name to return
+	NULL.
+	* tree-ssa-alias.c (init_alias_info): Likewise.
+	* tree-ssa.c (verify_flow_sensitive_alias_info): Likewise.
+	(verify_ssa): Likewise.
+	* tree-ssanames.c (make_ssa_name): Clear out ssa_names arrays.
+
 2004-09-18  Jan Hubicka  <jh@suse.cz>
 
 	* i386.c (legitimize_pic_address): Fix splitting of PLUS with
diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c
index 5a49d7f7d09a..e71eb4745aaa 100644
--- a/gcc/tree-into-ssa.c
+++ b/gcc/tree-into-ssa.c
@@ -1623,7 +1623,8 @@ rewrite_ssa_into_ssa (void)
   sbitmap_free (mark_def_sites_global_data.kills);
 
   for (i = 1; i < num_ssa_names; i++)
-    set_current_def (ssa_name (i), NULL_TREE);
+    if (ssa_name (i))
+      set_current_def (ssa_name (i), NULL_TREE);
 
   /* Insert PHI nodes at dominance frontiers of definition blocks.  */
   insert_phi_nodes (dfs, to_rename);
@@ -1679,7 +1680,7 @@ rewrite_ssa_into_ssa (void)
   for (i = 1; i < num_ssa_names; i++)
     {
       name = ssa_name (i);
-      if (!SSA_NAME_AUX (name))
+      if (!name || !SSA_NAME_AUX (name))
 	continue;
 
       free (SSA_NAME_AUX (name));
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
index ae06ea0680bc..ff1dd7726aad 100644
--- a/gcc/tree-ssa-alias.c
+++ b/gcc/tree-ssa-alias.c
@@ -414,7 +414,7 @@ init_alias_info (void)
 	{
 	  tree name = ssa_name (i);
 
-	  if (!POINTER_TYPE_P (TREE_TYPE (name)))
+	  if (!name || !POINTER_TYPE_P (TREE_TYPE (name)))
 	    continue;
 
 	  if (SSA_NAME_PTR_INFO (name))
diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c
index 21dc59aac021..2c5cf5ab1601 100644
--- a/gcc/tree-ssa.c
+++ b/gcc/tree-ssa.c
@@ -419,6 +419,8 @@ verify_flow_sensitive_alias_info (void)
       struct ptr_info_def *pi;
 
       ptr = ssa_name (i);
+      if (!ptr)
+	continue;
       ann = var_ann (SSA_NAME_VAR (ptr));
       pi = SSA_NAME_PTR_INFO (ptr);
 
@@ -466,25 +468,26 @@ verify_flow_sensitive_alias_info (void)
 	  size_t j;
 
 	  for (j = i + 1; j < num_ssa_names; j++)
-	    {
-	      tree ptr2 = ssa_name (j);
-	      struct ptr_info_def *pi2 = SSA_NAME_PTR_INFO (ptr2);
-
-	      if (!TREE_VISITED (ptr2) || !POINTER_TYPE_P (TREE_TYPE (ptr2)))
-		continue;
-
-	      if (pi2
-		  && pi2->name_mem_tag
-		  && pi2->pt_vars
-		  && bitmap_first_set_bit (pi2->pt_vars) >= 0
-		  && pi->name_mem_tag != pi2->name_mem_tag
-		  && bitmap_equal_p (pi->pt_vars, pi2->pt_vars))
-		{
-		  error ("Two pointers with different name tags and identical points-to sets");
-		  debug_variable (ptr2);
-		  goto err;
-		}
-	    }
+	    if (ssa_name (j))
+	      {
+		tree ptr2 = ssa_name (j);
+		struct ptr_info_def *pi2 = SSA_NAME_PTR_INFO (ptr2);
+
+		if (!TREE_VISITED (ptr2) || !POINTER_TYPE_P (TREE_TYPE (ptr2)))
+		  continue;
+
+		if (pi2
+		    && pi2->name_mem_tag
+		    && pi2->pt_vars
+		    && bitmap_first_set_bit (pi2->pt_vars) >= 0
+		    && pi->name_mem_tag != pi2->name_mem_tag
+		    && bitmap_equal_p (pi->pt_vars, pi2->pt_vars))
+		  {
+		    error ("Two pointers with different name tags and identical points-to sets");
+		    debug_variable (ptr2);
+		    goto err;
+		  }
+	      }
 	}
     }
 
@@ -524,7 +527,8 @@ verify_ssa (void)
 
   /* Keep track of SSA names present in the IL.  */
   for (i = 1; i < num_ssa_names; i++)
-    TREE_VISITED (ssa_name (i)) = 0;
+    if (ssa_name (i))
+      TREE_VISITED (ssa_name (i)) = 0;
 
   calculate_dominance_info (CDI_DOMINATORS);
 
diff --git a/gcc/tree-ssanames.c b/gcc/tree-ssanames.c
index 55ba145c35ae..cc12f28d7d47 100644
--- a/gcc/tree-ssanames.c
+++ b/gcc/tree-ssanames.c
@@ -205,6 +205,8 @@ make_ssa_name (tree var, tree stmt)
       memset (t, 0, tree_size (t));
       TREE_SET_CODE (t, SSA_NAME);
       SSA_NAME_VERSION (t) = save_version;
+      gcc_assert (ssa_name (save_version) == NULL);
+      VARRAY_TREE (ssa_names, save_version) = t;
     }
   else
     {
@@ -260,6 +262,7 @@ release_ssa_name (tree var)
      defining statement.  */
   if (! SSA_NAME_IN_FREE_LIST (var))
     {
+      VARRAY_TREE (ssa_names, SSA_NAME_VERSION (var)) = NULL;
       SSA_NAME_IN_FREE_LIST (var) = 1;
       TREE_CHAIN (var) = free_ssanames;
       free_ssanames = var;
-- 
GitLab