diff mbox series

[02/14] Code refactoring for call_summary.

Message ID 25b65a35d1bf039397e89bfbbf92f19a4a20bb1f.1526551813.git.mliska@suse.cz
State New
Headers show
Series Finish transition of {symbol,call}_summary. | expand

Commit Message

Martin Liška April 19, 2018, 3:09 p.m. UTC
gcc/ChangeLog:

2018-04-24  Martin Liska  <mliska@suse.cz>

	* symbol-summary.h (release): Move definition out of class
	declaration.
	(symtab_removal): Likewise.
	(symtab_duplication): Likewise.
---
 gcc/symbol-summary.h | 123 +++++++++++++++++++++++++++++----------------------
 1 file changed, 70 insertions(+), 53 deletions(-)

Comments

Jan Hubicka June 7, 2018, 12:06 p.m. UTC | #1
> 
> gcc/ChangeLog:
> 
> 2018-04-24  Martin Liska  <mliska@suse.cz>
> 
> 	* symbol-summary.h (release): Move definition out of class
> 	declaration.
> 	(symtab_removal): Likewise.
> 	(symtab_duplication): Likewise.

OK,
Honza
diff mbox series

Patch

diff --git a/gcc/symbol-summary.h b/gcc/symbol-summary.h
index 13f8f04342a..a73472ef0ae 100644
--- a/gcc/symbol-summary.h
+++ b/gcc/symbol-summary.h
@@ -330,21 +330,7 @@  public:
   }
 
   /* Destruction method that can be called for GGT purpose.  */
-  void release ()
-  {
-    if (m_released)
-      return;
-
-    m_symtab->remove_edge_removal_hook (m_symtab_removal_hook);
-    m_symtab->remove_edge_duplication_hook (m_symtab_duplication_hook);
-
-    /* Release all summaries.  */
-    typedef typename hash_map <map_hash, T *>::iterator map_iterator;
-    for (map_iterator it = m_map.begin (); it != m_map.end (); ++it)
-      release ((*it).second);
-
-    m_released = true;
-  }
+  void release ();
 
   /* Traverses all summarys with a function F called with
      ARG as argument.  */
@@ -369,16 +355,7 @@  public:
   }
 
   /* Release an item that is stored within map.  */
-  void release (T *item)
-  {
-    if (m_ggc)
-      {
-	item->~T ();
-	ggc_free (item);
-      }
-    else
-      delete item;
-  }
+  void release (T *item);
 
   /* Getter for summary callgraph edge pointer.  */
   T* get (cgraph_edge *edge)
@@ -399,37 +376,11 @@  public:
   }
 
   /* Symbol removal hook that is registered to symbol table.  */
-  static void symtab_removal (cgraph_edge *edge, void *data)
-  {
-    call_summary *summary = (call_summary <T *> *) (data);
-
-    int h_uid = summary->hashable_uid (edge);
-    T **v = summary->m_map.get (h_uid);
-
-    if (v)
-      {
-	summary->remove (edge, *v);
-	summary->release (*v);
-	summary->m_map.remove (h_uid);
-      }
-  }
+  static void symtab_removal (cgraph_edge *edge, void *data);
 
   /* Symbol duplication hook that is registered to symbol table.  */
   static void symtab_duplication (cgraph_edge *edge1, cgraph_edge *edge2,
-				  void *data)
-  {
-    call_summary *summary = (call_summary <T *> *) (data);
-    T **v = summary->m_map.get (summary->hashable_uid (edge1));
-
-    if (v)
-      {
-	/* This load is necessary, because we insert a new value!  */
-	T *data = *v;
-	T *duplicate = summary->allocate_new ();
-	summary->m_map.put (summary->hashable_uid (edge2), duplicate);
-	summary->duplicate (edge1, edge2, data, duplicate);
-      }
-  }
+				  void *data);
 
 protected:
   /* Indication if we use ggc summary.  */
@@ -473,6 +424,72 @@  private:
       gt_pointer_operator, void *);
 };
 
+template <typename T>
+void
+call_summary<T *>::release ()
+{
+  if (m_released)
+    return;
+
+  m_symtab->remove_edge_removal_hook (m_symtab_removal_hook);
+  m_symtab->remove_edge_duplication_hook (m_symtab_duplication_hook);
+
+  /* Release all summaries.  */
+  typedef typename hash_map <map_hash, T *>::iterator map_iterator;
+  for (map_iterator it = m_map.begin (); it != m_map.end (); ++it)
+    release ((*it).second);
+
+  m_released = true;
+}
+
+template <typename T>
+void
+call_summary<T *>::release (T *item)
+{
+  if (m_ggc)
+    {
+      item->~T ();
+      ggc_free (item);
+    }
+  else
+    delete item;
+}
+
+template <typename T>
+void
+call_summary<T *>::symtab_removal (cgraph_edge *edge, void *data)
+{
+  call_summary *summary = (call_summary <T *> *) (data);
+
+  int h_uid = summary->hashable_uid (edge);
+  T **v = summary->m_map.get (h_uid);
+
+  if (v)
+    {
+      summary->remove (edge, *v);
+      summary->release (*v);
+      summary->m_map.remove (h_uid);
+    }
+}
+
+template <typename T>
+void
+call_summary<T *>::symtab_duplication (cgraph_edge *edge1,
+				       cgraph_edge *edge2, void *data)
+{
+  call_summary *summary = (call_summary <T *> *) (data);
+  T **v = summary->m_map.get (summary->hashable_uid (edge1));
+
+  if (v)
+    {
+      /* This load is necessary, because we insert a new value!  */
+      T *data = *v;
+      T *duplicate = summary->allocate_new ();
+      summary->m_map.put (summary->hashable_uid (edge2), duplicate);
+      summary->duplicate (edge1, edge2, data, duplicate);
+    }
+}
+
 template <typename T>
 void
 gt_ggc_mx(call_summary<T *>* const &summary)