diff mbox

[1/2] Revert m_classes_vec introduction.

Message ID 1bf4df91-5398-2c09-ab47-503d30bfc485@suse.cz
State New
Headers show

Commit Message

Martin Liška Jan. 9, 2017, 3:04 p.m. UTC
First patch removes basically what was installed by Jakub in r242910,
except formatting changes.

Martin
diff mbox

Patch

From 32f4ccb48dfd84e4f64fb38f5122f5dc61482f3b Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Fri, 6 Jan 2017 11:36:13 +0100
Subject: [PATCH 1/2] Revert m_classes_vec introduction.

gcc/ChangeLog:

2017-01-06  Martin Liska  <mliska@suse.cz>

	* ipa-icf.c (sem_item_optimizer::sem_item_optimizer): Remove
	usage of m_classes_vec.
	(sem_item_optimizer::~sem_item_optimizer):  Likewise.
	(sem_item_optimizer::get_group_by_hash): Likewise.
	(sem_item_optimizer::subdivide_classes_by_equality): Likewise.
	(sem_item_optimizer::subdivide_classes_by_sensitive_refs): Likewise.
	(sem_item_optimizer::verify_classes): Likewise.
	(sem_item_optimizer::process_cong_reduction): Likewise.
	(sem_item_optimizer::dump_cong_classes): Likewise.
	(sem_item_optimizer::merge_classes): Likewise.
	* ipa-icf.h (congruence_class_hash): Rename from
	congruence_class_group_hash.  Remove declaration of
	m_classes_vec.
---
 gcc/ipa-icf.c | 106 +++++++++++++++++++++++++++-------------------------------
 gcc/ipa-icf.h |   7 ++--
 2 files changed, 51 insertions(+), 62 deletions(-)

diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
index d3f2ca14eac..28de251c421 100644
--- a/gcc/ipa-icf.c
+++ b/gcc/ipa-icf.c
@@ -2288,7 +2288,6 @@  sem_item_optimizer::sem_item_optimizer ()
   m_varpool_node_hooks (NULL)
 {
   m_items.create (0);
-  m_classes_vec.create (0);
   bitmap_obstack_initialize (&m_bmstack);
 }
 
@@ -2297,19 +2296,18 @@  sem_item_optimizer::~sem_item_optimizer ()
   for (unsigned int i = 0; i < m_items.length (); i++)
     delete m_items[i];
 
-  unsigned int l;
-  congruence_class_group *it;
-  FOR_EACH_VEC_ELT (m_classes_vec, l, it)
+
+  for (hash_table<congruence_class_hash>::iterator it = m_classes.begin ();
+       it != m_classes.end (); ++it)
     {
-      for (unsigned int i = 0; i < it->classes.length (); i++)
-	delete it->classes[i];
+      for (unsigned int i = 0; i < (*it)->classes.length (); i++)
+	delete (*it)->classes[i];
 
-      it->classes.release ();
-      free (it);
+      (*it)->classes.release ();
+      free (*it);
     }
 
   m_items.release ();
-  m_classes_vec.release ();
 
   bitmap_obstack_release (&m_bmstack);
 }
@@ -2502,7 +2500,6 @@  sem_item_optimizer::get_group_by_hash (hashval_t hash, sem_item_type type)
   else
     {
       item->classes.create (1);
-      m_classes_vec.safe_push (item);
       *slot = item;
     }
 
@@ -2847,15 +2844,14 @@  sem_item_optimizer::parse_nonsingleton_classes (void)
 void
 sem_item_optimizer::subdivide_classes_by_equality (bool in_wpa)
 {
-  unsigned int l;
-  congruence_class_group *it;
-  FOR_EACH_VEC_ELT (m_classes_vec, l, it)
+  for (hash_table <congruence_class_hash>::iterator it = m_classes.begin ();
+       it != m_classes.end (); ++it)
     {
-      unsigned int class_count = it->classes.length ();
+      unsigned int class_count = (*it)->classes.length ();
 
       for (unsigned i = 0; i < class_count; i++)
 	{
-	  congruence_class *c = it->classes[i];
+	  congruence_class *c = (*it)->classes[i];
 
 	  if (c->members.length() > 1)
 	    {
@@ -2864,7 +2860,7 @@  sem_item_optimizer::subdivide_classes_by_equality (bool in_wpa)
 	      sem_item *first = c->members[0];
 	      new_vector.safe_push (first);
 
-	      unsigned class_split_first = it->classes.length ();
+	      unsigned class_split_first = (*it)->classes.length ();
 
 	      for (unsigned j = 1; j < c->members.length (); j++)
 		{
@@ -2881,9 +2877,9 @@  sem_item_optimizer::subdivide_classes_by_equality (bool in_wpa)
 		      bool integrated = false;
 
 		      for (unsigned k = class_split_first;
-			   k < it->classes.length (); k++)
+			   k < (*it)->classes.length (); k++)
 			{
-			  sem_item *x = it->classes[k]->members[0];
+			  sem_item *x = (*it)->classes[k]->members[0];
 			  bool equals
 			    = in_wpa ? x->equals_wpa (item, m_symtab_node_map)
 				     : x->equals (item, m_symtab_node_map);
@@ -2891,7 +2887,7 @@  sem_item_optimizer::subdivide_classes_by_equality (bool in_wpa)
 			  if (equals)
 			    {
 			      integrated = true;
-			      add_item_to_class (it->classes[k], item);
+			      add_item_to_class ((*it)->classes[k], item);
 
 			      break;
 			    }
@@ -2904,7 +2900,7 @@  sem_item_optimizer::subdivide_classes_by_equality (bool in_wpa)
 			  m_classes_count++;
 			  add_item_to_class (c, item);
 
-			  it->classes.safe_push (c);
+			  (*it)->classes.safe_push (c);
 			}
 		    }
 		}
@@ -2935,16 +2931,15 @@  sem_item_optimizer::subdivide_classes_by_sensitive_refs ()
 
   unsigned newly_created_classes = 0;
 
-  unsigned int l;
-  congruence_class_group *it;
-  FOR_EACH_VEC_ELT (m_classes_vec, l, it)
+  for (hash_table <congruence_class_hash>::iterator it = m_classes.begin ();
+       it != m_classes.end (); ++it)
     {
-      unsigned int class_count = it->classes.length ();
+      unsigned int class_count = (*it)->classes.length ();
       auto_vec<congruence_class *> new_classes;
 
       for (unsigned i = 0; i < class_count; i++)
 	{
-	  congruence_class *c = it->classes[i];
+	  congruence_class *c = (*it)->classes[i];
 
 	  if (c->members.length() > 1)
 	    {
@@ -2988,7 +2983,7 @@  sem_item_optimizer::subdivide_classes_by_sensitive_refs ()
 
 		      if (first_class)
 		        {
-			  it->classes[i] = new_cls;
+			  (*it)->classes[i] = new_cls;
 			  first_class = false;
 			}
 		      else
@@ -3010,7 +3005,7 @@  sem_item_optimizer::subdivide_classes_by_sensitive_refs ()
 	  }
 
 	for (unsigned i = 0; i < new_classes.length (); i++)
-	  it->classes.safe_push (new_classes[i]);
+	  (*it)->classes.safe_push (new_classes[i]);
     }
 
   return newly_created_classes;
@@ -3030,13 +3025,12 @@  sem_item_optimizer::checking_verify_classes (void)
 void
 sem_item_optimizer::verify_classes (void)
 {
-  unsigned int l;
-  congruence_class_group *it;
-  FOR_EACH_VEC_ELT (m_classes_vec, l, it)
+  for (hash_table<congruence_class_hash>::iterator it = m_classes.begin ();
+       it != m_classes.end (); ++it)
     {
-      for (unsigned int i = 0; i < it->classes.length (); i++)
+      for (unsigned int i = 0; i < (*it)->classes.length (); i++)
 	{
-	  congruence_class *cls = it->classes[i];
+	  congruence_class *cls = (*it)->classes[i];
 
 	  gcc_assert (cls);
 	  gcc_assert (cls->members.length () > 0);
@@ -3302,12 +3296,11 @@  sem_item_optimizer::worklist_pop (void)
 void
 sem_item_optimizer::process_cong_reduction (void)
 {
-  unsigned int l;
-  congruence_class_group *it;
-  FOR_EACH_VEC_ELT (m_classes_vec, l, it)
-    for (unsigned i = 0; i < it->classes.length (); i++)
-      if (it->classes[i]->is_class_used ())
-	worklist_push (it->classes[i]);
+  for (hash_table<congruence_class_hash>::iterator it = m_classes.begin ();
+       it != m_classes.end (); ++it)
+    for (unsigned i = 0; i < (*it)->classes.length (); i++)
+      if ((*it)->classes[i]->is_class_used ())
+	worklist_push ((*it)->classes[i]);
 
   if (dump_file)
     fprintf (dump_file, "Worklist has been filled with: %lu\n",
@@ -3347,12 +3340,11 @@  sem_item_optimizer::dump_cong_classes (void)
   unsigned int max_index = 0;
   unsigned int* histogram = XCNEWVEC (unsigned int, m_items.length () + 1);
 
-  unsigned int l;
-  congruence_class_group *it;
-  FOR_EACH_VEC_ELT (m_classes_vec, l, it)
-    for (unsigned i = 0; i < it->classes.length (); i++)
+  for (hash_table<congruence_class_hash>::iterator it = m_classes.begin ();
+       it != m_classes.end (); ++it)
+    for (unsigned i = 0; i < (*it)->classes.length (); i++)
       {
-	unsigned int c = it->classes[i]->members.length ();
+	unsigned int c = (*it)->classes[i]->members.length ();
 	histogram[c]++;
 
 	if (c > max_index)
@@ -3369,18 +3361,18 @@  sem_item_optimizer::dump_cong_classes (void)
 
   fprintf (dump_file, "\n\n");
 
-
   if (dump_flags & TDF_DETAILS)
-    FOR_EACH_VEC_ELT (m_classes_vec, l, it)
+  for (hash_table<congruence_class_hash>::iterator it = m_classes.begin ();
+       it != m_classes.end (); ++it)
       {
 	fprintf (dump_file, "  group: with %u classes:\n",
-		 it->classes.length ());
+		 (*it)->classes.length ());
 
-	for (unsigned i = 0; i < it->classes.length (); i++)
+	for (unsigned i = 0; i < (*it)->classes.length (); i++)
 	  {
-	    it->classes[i]->dump (dump_file, 4);
+	    (*it)->classes[i]->dump (dump_file, 4);
 
-	    if (i < it->classes.length () - 1)
+	    if (i < (*it)->classes.length () - 1)
 	      fprintf (dump_file, " ");
 	  }
       }
@@ -3405,12 +3397,11 @@  sem_item_optimizer::merge_classes (unsigned int prev_class_count)
 
   bool merged_p = false;
 
-  unsigned int l;
-  congruence_class_group *it;
-  FOR_EACH_VEC_ELT (m_classes_vec, l, it)
-    for (unsigned int i = 0; i < it->classes.length (); i++)
+  for (hash_table<congruence_class_hash>::iterator it = m_classes.begin ();
+       it != m_classes.end (); ++it)
+    for (unsigned int i = 0; i < (*it)->classes.length (); i++)
       {
-	congruence_class *c = it->classes[i];
+	congruence_class *c = (*it)->classes[i];
 	if (c->members.length () > 1)
 	  {
 	    non_singular_classes_count++;
@@ -3435,10 +3426,11 @@  sem_item_optimizer::merge_classes (unsigned int prev_class_count)
 	       item_count ? 100.0f * equal_items / item_count : 0.0f);
     }
 
-  FOR_EACH_VEC_ELT (m_classes_vec, l, it)
-    for (unsigned int i = 0; i < it->classes.length (); i++)
+  for (hash_table<congruence_class_hash>::iterator it = m_classes.begin ();
+       it != m_classes.end (); ++it)
+    for (unsigned int i = 0; i < (*it)->classes.length (); i++)
       {
-	congruence_class *c = it->classes[i];
+	congruence_class *c = (*it)->classes[i];
 
 	if (c->members.length () == 1)
 	  continue;
diff --git a/gcc/ipa-icf.h b/gcc/ipa-icf.h
index 05fe2a83dad..c57224c1517 100644
--- a/gcc/ipa-icf.h
+++ b/gcc/ipa-icf.h
@@ -442,7 +442,7 @@  struct congruence_class_group
 };
 
 /* Congruence class set structure.  */
-struct congruence_class_group_hash : nofree_ptr_hash <congruence_class_group>
+struct congruence_class_hash : nofree_ptr_hash <congruence_class_group>
 {
   static inline hashval_t hash (const congruence_class_group *item)
   {
@@ -610,10 +610,7 @@  private:
   hash_set <symtab_node *> m_removed_items_set;
 
   /* Hashtable of congruence classes.  */
-  hash_table <congruence_class_group_hash> m_classes;
-
-  /* Vector of congruence classes.  */
-  vec <congruence_class_group *> m_classes_vec;
+  hash_table <congruence_class_hash> m_classes;
 
   /* Count of congruence classes.  */
   unsigned int m_classes_count;
-- 
2.11.0