public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 1/2] Convert symtab, cgraph and varpool nodes into a real class hierarchy
  2013-08-16  0:58 [PATCH 0/2] Port symtab/cgraph/varpool nodes to use C++ inheritance David Malcolm
  2013-08-16  0:58 ` [PATCH 2/2] Autogenerated fixes of "->symbol." to "->" David Malcolm
@ 2013-08-16  0:58 ` David Malcolm
  2013-08-20 21:26   ` Jan Hubicka
  2013-08-27 11:10   ` Richard Biener
  2013-08-20 21:06 ` [PATCH 0/2] Port symtab/cgraph/varpool nodes to use C++ inheritance Jan Hubicka
  2 siblings, 2 replies; 39+ messages in thread
From: David Malcolm @ 2013-08-16  0:58 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jan Hubicka, David Malcolm

This patch is the handwritten part of the conversion of these types
to C++; it requires the followup patch, which is autogenerated.

It converts:
  struct GTY(()) symtab_node_base
to:
  class GTY((user)) symtab_node_base

and converts:
  struct GTY(()) cgraph_node
to:
  struct GTY((user)) cgraph_node : public symtab_node_base

and:
  struct GTY(()) varpool_node
to:
  class GTY((user)) varpool_node : public symtab_node_base

dropping the symtab_node_def union.

Since gengtype is unable to cope with inheritance, we have to mark the
types with GTY((user)), and handcode the gty field-visiting functions.
Given the simple hierarchy, we don't need virtual functions for this.

Unfortunately doing so runs into various bugs in gengtype's handling
of GTY((user)), so the patch also includes workarounds for these bugs.

gengtype walks the graph of the *types* in the code, and produces
functions in gtype-desc.[ch] for all types that are reachable from a
GTY root.

However, it ignores the contents of GTY((user)) types when walking
this graph.

Hence if you have a subgraph of types that are only reachable
via fields in GTY((user)) types, gengtype won't generate helper code
for those types.

Ideally there would be some way to mark a GTY((user)) type to say
which types it references, to avoid having to mark these types as
GTY((user)).

For now, work around this issue by providing explicit roots of the
missing types, of dummy variables (see the bottom of cgraph.c)

gcc/

	* cgraph.c (gt_ggc_mx): New.
	(gt_pch_nx (symtab_node_base *)): New.
	(gt_pch_nx (symtab_node_base *, gt_pointer_operator, void *)): New.
	(dummy_call_site_hash): New.
	(dummy_ipa_ref_list): New.
	(dummy_cgraph_clone_info): New.
	(dummy_ipa_replace_map_pointer): New.
	(dummy_varpool_node_ptr): New.

	* cgraph.h (symtab_node_base): Convert to a class;
	add GTY((user)).
	(gt_ggc_mx): New.
	(gt_pch_nx (symtab_node_base *p)): New.
	(gt_pch_nx (symtab_node_base *p, gt_pointer_operator op,
	void *cookie)): New.
	(cgraph_node): Inherit from symtab_node; convert to GTY((user)).
	(varpool_node): Likewise.
	(symtab_node_def): Remove.
	(is_a_helper <cgraph_node>::test (symtab_node_def *)): Convert to...
	(is_a_helper <cgraph_node>::test (symtab_node_base *)): ...this.
	(is_a_helper <varpool_node>::test (symtab_node_def *)): Convert to...
	(is_a_helper <varpool_node>::test (symtab_node_base *)): ...this.

	* ipa-ref.h (symtab_node_def): Drop.
	(symtab_node): Change underlying type from symtab_node_def to
	symtab_node_base.
	(const_symtab_node): Likwise.

	* is-a.h: Update examples in comment.

	* symtab.c (symtab_hash): Change symtab_node_def to symtab_node_base.
	(assembler_name_hash): Likewise.
---
 gcc/cgraph.c  | 218 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gcc/cgraph.h  |  48 ++++++-------
 gcc/ipa-ref.h |   6 +-
 gcc/is-a.h    |   6 +-
 gcc/symtab.c  |   4 +-
 5 files changed, 247 insertions(+), 35 deletions(-)

diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index 50d13ab..5cb6a31 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -3035,4 +3035,222 @@ cgraph_get_body (struct cgraph_node *node)
   return true;
 }
 
+/* GTY((user)) hooks for symtab_node_base (and its subclasses).
+   We could use virtual functions for this, but given the presence of the
+   "type" field and the trivial size of the class hierarchy, switches are
+   perhaps simpler and faster.  */
+
+void gt_ggc_mx (symtab_node_base *x)
+{
+  /* Hand-written equivalent of the chain_next/chain_prev machinery, to
+     avoid deep call-stacks.
+
+     Locate the neighbors of x (within the linked-list) that haven't been
+     marked yet, so that x through xlimit give a range suitable for marking.
+     Note that x (on entry) itself has already been marked by the
+     gtype-desc.c code, so we first try its successor.
+  */
+  symtab_node_base * xlimit = x ? x->next : NULL;
+  while (ggc_test_and_set_mark (xlimit))
+   xlimit = xlimit->next;
+  if (x != xlimit)
+    for (;;)
+      {
+        symtab_node_base * const xprev = x->previous;
+        if (xprev == NULL) break;
+        x = xprev;
+        (void) ggc_test_and_set_mark (xprev);
+      }
+  while (x != xlimit)
+    {
+      /* Code common to all symtab nodes. */
+      gt_ggc_m_9tree_node (x->decl);
+      gt_ggc_mx_symtab_node_base (x->next);
+      gt_ggc_mx_symtab_node_base (x->previous);
+      gt_ggc_mx_symtab_node_base (x->next_sharing_asm_name);
+      gt_ggc_mx_symtab_node_base (x->previous_sharing_asm_name);
+      gt_ggc_mx_symtab_node_base (x->same_comdat_group);
+      gt_ggc_m_20vec_ipa_ref_t_va_gc_ (x->ref_list.references);
+      gt_ggc_m_9tree_node (x->alias_target);
+      gt_ggc_m_18lto_file_decl_data (x->lto_file_data);
+
+      /* Extra code, per subclass. */
+      switch (x->type)
+        {
+        case SYMTAB_FUNCTION:
+          {
+            cgraph_node *cgn = static_cast <cgraph_node *> (x);
+            gt_ggc_m_11cgraph_edge (cgn->callees);
+            gt_ggc_m_11cgraph_edge (cgn->callers);
+            gt_ggc_m_11cgraph_edge (cgn->indirect_calls);
+            gt_ggc_m_11cgraph_node (cgn->origin);
+            gt_ggc_m_11cgraph_node (cgn->nested);
+            gt_ggc_m_11cgraph_node (cgn->next_nested);
+            gt_ggc_m_11cgraph_node (cgn->next_sibling_clone);
+            gt_ggc_m_11cgraph_node (cgn->prev_sibling_clone);
+            gt_ggc_m_11cgraph_node (cgn->clones);
+            gt_ggc_m_11cgraph_node (cgn->clone_of);
+            gt_ggc_m_P11cgraph_edge4htab (cgn->call_site_hash);
+            gt_ggc_m_9tree_node (cgn->former_clone_of);
+            gt_ggc_m_11cgraph_node (cgn->global.inlined_to);
+            gt_ggc_m_28vec_ipa_replace_map_p_va_gc_ (cgn->clone.tree_map);
+            gt_ggc_m_15bitmap_head_def (cgn->clone.args_to_skip);
+            gt_ggc_m_15bitmap_head_def (cgn->clone.combined_args_to_skip);
+            gt_ggc_m_9tree_node (cgn->thunk.alias);
+          }
+          break;
+        default:
+          break;
+        }
+      x = x->next;
+    }
+}
+
+void gt_pch_nx (symtab_node_base *x)
+{
+  symtab_node_base * xlimit = x ? x->next : NULL;
+  while (gt_pch_note_object (xlimit, xlimit, gt_pch_p_16symtab_node_base))
+   xlimit = xlimit->next;
+  if (x != xlimit)
+    for (;;)
+      {
+        symtab_node_base * const xprev = x->previous;
+        if (xprev == NULL) break;
+        x = xprev;
+        (void) gt_pch_note_object (xprev, xprev,
+                                   gt_pch_p_16symtab_node_base);
+      }
+  while (x != xlimit)
+    {
+      /* Code common to all symtab nodes. */
+      gt_pch_n_9tree_node (x->decl);
+      gt_pch_nx_symtab_node_base (x->next);
+      gt_pch_nx_symtab_node_base (x->previous);
+      gt_pch_nx_symtab_node_base (x->next_sharing_asm_name);
+      gt_pch_nx_symtab_node_base (x->previous_sharing_asm_name);
+      gt_pch_nx_symtab_node_base (x->same_comdat_group);
+      gt_pch_n_20vec_ipa_ref_t_va_gc_ (x->ref_list.references);
+      gt_pch_n_9tree_node (x->alias_target);
+      gt_pch_n_18lto_file_decl_data (x->lto_file_data);
+
+      /* Extra code, per subclass. */
+      switch (x->type)
+        {
+        case SYMTAB_FUNCTION:
+          {
+            cgraph_node *cgn = static_cast <cgraph_node *> (x);
+            gt_pch_n_11cgraph_edge (cgn->callees);
+            gt_pch_n_11cgraph_edge (cgn->callers);
+            gt_pch_n_11cgraph_edge (cgn->indirect_calls);
+            gt_pch_n_11cgraph_node (cgn->origin);
+            gt_pch_n_11cgraph_node (cgn->nested);
+            gt_pch_n_11cgraph_node (cgn->next_nested);
+            gt_pch_n_11cgraph_node (cgn->next_sibling_clone);
+            gt_pch_n_11cgraph_node (cgn->prev_sibling_clone);
+            gt_pch_n_11cgraph_node (cgn->clones);
+            gt_pch_n_11cgraph_node (cgn->clone_of);
+            gt_pch_n_P11cgraph_edge4htab (cgn->call_site_hash);
+            gt_pch_n_9tree_node (cgn->former_clone_of);
+            gt_pch_n_11cgraph_node (cgn->global.inlined_to);
+            gt_pch_n_28vec_ipa_replace_map_p_va_gc_ (cgn->clone.tree_map);
+            gt_pch_n_15bitmap_head_def (cgn->clone.args_to_skip);
+            gt_pch_n_15bitmap_head_def (cgn->clone.combined_args_to_skip);
+            gt_pch_n_9tree_node (cgn->thunk.alias);
+          }
+          break;
+        default:
+          break;
+        }
+      x = x->next;
+    }
+}
+
+void gt_pch_nx (symtab_node_base *p, gt_pointer_operator op, void *cookie)
+{
+  /* Code common to all symtab nodes. */
+  op (&(p->decl), cookie);
+  op (&(p->next), cookie);
+  op (&(p->previous), cookie);
+  op (&(p->next_sharing_asm_name), cookie);
+  op (&(p->previous_sharing_asm_name), cookie);
+  op (&(p->same_comdat_group), cookie);
+  op (&(p->ref_list.references), cookie);
+  op (&(p->alias_target), cookie);
+  op (&(p->lto_file_data), cookie);
+
+  /* Extra code, per subclass. */
+  switch (p->type)
+    {
+    case SYMTAB_FUNCTION:
+      {
+        cgraph_node *cgn = static_cast <cgraph_node *> (p);
+        op (&(cgn->callees), cookie);
+        op (&(cgn->callers), cookie);
+        op (&(cgn->indirect_calls), cookie);
+        op (&(cgn->origin), cookie);
+        op (&(cgn->nested), cookie);
+        op (&(cgn->next_nested), cookie);
+        op (&(cgn->next_sibling_clone), cookie);
+        op (&(cgn->prev_sibling_clone), cookie);
+        op (&(cgn->clones), cookie);
+        op (&(cgn->clone_of), cookie);
+        op (&(cgn->call_site_hash), cookie);
+        op (&(cgn->former_clone_of), cookie);
+        op (&(cgn->global.inlined_to), cookie);
+        op (&(cgn->clone.tree_map), cookie);
+        op (&(cgn->clone.args_to_skip), cookie);
+        op (&(cgn->clone.combined_args_to_skip), cookie);
+        op (&(cgn->thunk.alias), cookie);
+      }
+      break;
+    default:
+      break;
+    }
+}
+
+/* Workarounds for deficiencies in gengtype's handling of GTY((user)).
+
+   gengtype walks the graph of the *types* in the code, and produces
+   functions in gtype-desc.[ch] for all types that are reachable from a
+   GTY root.
+
+   However, it ignores the contents of GTY((user)) types when walking
+   this graph.
+
+   Hence if you have a subgraph of types that are only reachable
+   via fields in GTY((user)) types, gengtype won't generate helper code
+   for those types.
+
+   Ideally there would be some way to mark a GTY((user)) type to say
+   which types it references, to avoid having to mark these types as
+   GTY((user)).
+
+   For now, work around this issue by providing explicit roots of the
+   missing types, of dummy variables.  */
+
+/* Force gengtype into providing GTY hooks for the type of this field:
+     htab_t GTY((param_is (struct cgraph_edge))) call_site_hash;
+   within cgraph_node.  */
+static GTY(()) htab_t GTY((param_is (struct cgraph_edge))) dummy_call_site_hash;
+
+/* Similarly for this field of symtab_node_base:
+     struct ipa_ref_list ref_list;
+ */
+static GTY((deletable)) struct ipa_ref_list *dummy_ipa_ref_list;
+
+/* Similarly for this field of cgraph_node:
+     struct cgraph_clone_info clone;
+*/
+static GTY((deletable)) struct cgraph_clone_info *dummy_cgraph_clone_info;
+
+/* Non-existent pointer, to trick gengtype into (correctly) realizing that
+   ipa_replace_map is indeed used in the code, and thus should have ggc_alloc_*
+   routines.  */
+static GTY((deletable)) struct ipa_replace_map *dummy_ipa_replace_map_pointer;
+
+/* Non-existent pointer, to trick gengtype into (correctly) realizing that
+   varpool_node is indeed used in the code, and thus should have ggc_alloc_*
+   routines.  */
+static GTY((deletable)) varpool_node *dummy_varpool_node_ptr;
+
 #include "gt-cgraph.h"
diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index e430533..412b5bb 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -40,8 +40,9 @@ enum symtab_type
 
 /* Base of all entries in the symbol table.
    The symtab_node is inherited by cgraph and varpol nodes.  */
-struct GTY(()) symtab_node_base
+class GTY((user)) symtab_node_base
 {
+public:
   /* Type of the symbol.  */
   ENUM_BITFIELD (symtab_type) type : 8;
 
@@ -143,6 +144,16 @@ struct GTY(()) symtab_node_base
   PTR GTY ((skip)) aux;
 };
 
+/* These user-provided hooks are called by code in gtype-desc.c
+   autogenerated by gengtype.c.
+
+   They are called the first time that the given object is visited
+   within a GC/PCH traversal.
+*/
+extern void gt_ggc_mx (symtab_node_base *p);
+extern void gt_pch_nx (symtab_node_base *p);
+extern void gt_pch_nx (symtab_node_base *p, gt_pointer_operator op, void *cookie);
+
 enum availability
 {
   /* Not yet set by cgraph_function_body_availability.  */
@@ -252,25 +263,19 @@ struct GTY(()) cgraph_clone_info
 /* The cgraph data structure.
    Each function decl has assigned cgraph_node listing callees and callers.  */
 
-struct GTY(()) cgraph_node {
-  struct symtab_node_base symbol;
+struct GTY((user)) cgraph_node : public symtab_node_base {
+public:
   struct cgraph_edge *callees;
   struct cgraph_edge *callers;
   /* List of edges representing indirect calls with a yet undetermined
      callee.  */
   struct cgraph_edge *indirect_calls;
   /* For nested functions points to function the node is nested in.  */
-  struct cgraph_node *
-    GTY ((nested_ptr (union symtab_node_def, "(struct cgraph_node *)(%h)", "(symtab_node)%h")))
-    origin;
+  struct cgraph_node *origin;
   /* Points to first nested function, if any.  */
-  struct cgraph_node *
-    GTY ((nested_ptr (union symtab_node_def, "(struct cgraph_node *)(%h)", "(symtab_node)%h")))
-    nested;
+  struct cgraph_node *nested;
   /* Pointer to the next function with same origin, if any.  */
-  struct cgraph_node *
-    GTY ((nested_ptr (union symtab_node_def, "(struct cgraph_node *)(%h)", "(symtab_node)%h")))
-    next_nested;
+  struct cgraph_node *next_nested;
   /* Pointer to the next clone.  */
   struct cgraph_node *next_sibling_clone;
   struct cgraph_node *prev_sibling_clone;
@@ -518,9 +523,8 @@ typedef struct cgraph_edge *cgraph_edge_p;
 /* The varpool data structure.
    Each static variable decl has assigned varpool_node.  */
 
-struct GTY(()) varpool_node {
-  struct symtab_node_base symbol;
-
+class GTY((user)) varpool_node : public symtab_node_base {
+public:
   /* Set when variable is scheduled to be assembled.  */
   unsigned output : 1;
 };
@@ -536,22 +540,12 @@ struct GTY(()) asm_node {
   int order;
 };
 
-/* Symbol table entry.  */
-union GTY((desc ("%h.symbol.type"), chain_next ("%h.symbol.next"),
-	   chain_prev ("%h.symbol.previous"))) symtab_node_def {
-  struct symtab_node_base GTY ((tag ("SYMTAB_SYMBOL"))) symbol;
-  /* To access the following fields,
-     use the use dyn_cast or as_a to obtain the concrete type.  */
-  struct cgraph_node GTY ((tag ("SYMTAB_FUNCTION"))) x_function;
-  struct varpool_node GTY ((tag ("SYMTAB_VARIABLE"))) x_variable;
-};
-
 /* Report whether or not THIS symtab node is a function, aka cgraph_node.  */
 
 template <>
 template <>
 inline bool
-is_a_helper <cgraph_node>::test (symtab_node_def *p)
+is_a_helper <cgraph_node>::test (symtab_node_base *p)
 {
   return p->symbol.type == SYMTAB_FUNCTION;
 }
@@ -561,7 +555,7 @@ is_a_helper <cgraph_node>::test (symtab_node_def *p)
 template <>
 template <>
 inline bool
-is_a_helper <varpool_node>::test (symtab_node_def *p)
+is_a_helper <varpool_node>::test (symtab_node_base *p)
 {
   return p->symbol.type == SYMTAB_VARIABLE;
 }
diff --git a/gcc/ipa-ref.h b/gcc/ipa-ref.h
index e0553bb..dc6e238 100644
--- a/gcc/ipa-ref.h
+++ b/gcc/ipa-ref.h
@@ -20,9 +20,9 @@ along with GCC; see the file COPYING3.  If not see
 
 struct cgraph_node;
 struct varpool_node;
-union symtab_node_def;
-typedef union symtab_node_def *symtab_node;
-typedef const union symtab_node_def *const_symtab_node;
+class symtab_node_base;
+typedef symtab_node_base *symtab_node;
+typedef const symtab_node_base *const_symtab_node;
 
 
 /* How the reference is done.  */
diff --git a/gcc/is-a.h b/gcc/is-a.h
index b5ee854..ccf12be 100644
--- a/gcc/is-a.h
+++ b/gcc/is-a.h
@@ -31,7 +31,7 @@ bool is_a <TYPE> (pointer)
 
     Tests whether the pointer actually points to a more derived TYPE.
 
-    Suppose you have a symtab_node_def *ptr, AKA symtab_node ptr.  You can test
+    Suppose you have a symtab_node_base *ptr, AKA symtab_node ptr.  You can test
     whether it points to a 'derived' cgraph_node as follows.
 
       if (is_a <cgraph_node> (ptr))
@@ -110,7 +110,7 @@ example,
   template <>
   template <>
   inline bool
-  is_a_helper <cgraph_node>::test (symtab_node_def *p)
+  is_a_helper <cgraph_node>::test (symtab_node_base *p)
   {
     return p->symbol.type == SYMTAB_FUNCTION;
   }
@@ -122,7 +122,7 @@ when needed may result in a crash.  For example,
   template <>
   template <>
   inline bool
-  is_a_helper <cgraph_node>::cast (symtab_node_def *p)
+  is_a_helper <cgraph_node>::cast (symtab_node_base *p)
   {
     return &p->x_function;
   }
diff --git a/gcc/symtab.c b/gcc/symtab.c
index a86bf6b..ba41f89 100644
--- a/gcc/symtab.c
+++ b/gcc/symtab.c
@@ -48,9 +48,9 @@ const char * const ld_plugin_symbol_resolution_names[]=
 };
 
 /* Hash table used to convert declarations into nodes.  */
-static GTY((param_is (union symtab_node_def))) htab_t symtab_hash;
+static GTY((param_is (symtab_node_base))) htab_t symtab_hash;
 /* Hash table used to convert assembler names into nodes.  */
-static GTY((param_is (union symtab_node_def))) htab_t assembler_name_hash;
+static GTY((param_is (symtab_node_base))) htab_t assembler_name_hash;
 
 /* Linked list of symbol table nodes.  */
 symtab_node symtab_nodes;
-- 
1.7.11.7

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH 0/2] Port symtab/cgraph/varpool nodes to use C++ inheritance
@ 2013-08-16  0:58 David Malcolm
  2013-08-16  0:58 ` [PATCH 2/2] Autogenerated fixes of "->symbol." to "->" David Malcolm
                   ` (2 more replies)
  0 siblings, 3 replies; 39+ messages in thread
From: David Malcolm @ 2013-08-16  0:58 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jan Hubicka, David Malcolm

Honza: following up from our IRC chat, I've ported the symtab, cgraph
and varpool nodes from the current hand-coded inheritance-in-C scheme
to being a C+ class hierarchy.

I know you're in the middle of making lots of other changes to this code,
so I've written a script to automate the parts of the conversion where
appropriate - see below.

In summary,
  struct GTY(()) symtab_node_base
becomes:
  class GTY((user)) symtab_node_base

and the subclasses:
  struct GTY(()) cgraph_node
and:
  struct GTY(()) varpool_node

become (respectively):
  struct GTY((user)) cgraph_node : public symtab_node_base
and:
  class GTY((user)) varpool_node : public symtab_node_base

The symtab_node_def union goes away, as do the "symbol" fields at the
top of the two subclasses.

I kept the existing names for things, and the "struct" for cgraph_node
since it is often referred to as "struct cgraph_node".

The patch is in three parts; all three are needed.

  * a fix for a bug in gengtype:
      http://gcc.gnu.org/ml/gcc-patches/2013-08/msg00882.html
    This is needed to avoid generating a malfunctioning gtype-desc.c
    *some* of the time - in capriciously changing ways as the sources
    change... :(   I sent it separately since I'm running into this
    issue with other changes I'm trying out; it "randomly" appears
    when trying to use GTY((user)).

  * Patch 1 of the 2 in this series is the hand-written part of the
    conversion.  This makes the changes above, plus various workarounds
    for dealing with yet more issues in how gengtype handles
    GTY((user)).

  * Patch 2 of the 2 in this series is the autogenerated part.
    Currently to access the base symtab fields of a cgraph or varpool
    node, the code has e.g.

       node->symbol.decl

    whereas with C++ inheritance, the "symbol" field is no more, and we
    directly use the base-class field:

       node->decl
    
    The script that makes the patch is for Python (2.7), and is in:
       https://github.com/davidmalcolm/gcc-refactoring-scripts
    as refactor_symtab.py and there's a test suite in
    test_refactor_symtab.py.   It's basically a glorified sed, but it
    also autogenerates the ChangeLog entries.  It expects the gcc
    checkout to be in a sister directory named "src".

Successfully bootstrapped and regtested on x86_64-unknown-linux-gnu
(using all three patches together, showing same results as an unpatched
source tree).

How does this look?  Are there other automated changes you'd like me
to make?   How should I go about getting this into trunk, given that you
have many other changes to this code on the way?

Thanks; hope this is helpful
Dave

David Malcolm (2):
  Convert symtab, cgraph and varpool nodes into a real class hierarchy
  Autogenerated fixes of "->symbol." to "->"

 gcc/ada/gcc-interface/trans.c |   2 +-
 gcc/ada/gcc-interface/utils.c |   2 +-
 gcc/asan.c                    |  10 +-
 gcc/c-family/c-gimplify.c     |   2 +-
 gcc/c-family/c-pragma.c       |   2 +-
 gcc/cfgexpand.c               |   2 +-
 gcc/cgraph.c                  | 480 ++++++++++++++++++++++++++++++------------
 gcc/cgraph.h                  | 150 +++++++------
 gcc/cgraphbuild.c             |  10 +-
 gcc/cgraphclones.c            |  84 ++++----
 gcc/cgraphunit.c              | 260 +++++++++++------------
 gcc/config/i386/i386.c        |  18 +-
 gcc/coverage.c                |   4 +-
 gcc/cp/call.c                 |   2 +-
 gcc/cp/decl2.c                |  24 +--
 gcc/cp/tree.c                 |   4 +-
 gcc/dbxout.c                  |   2 +-
 gcc/dwarf2out.c               |   4 +-
 gcc/gimple-fold.c             |   8 +-
 gcc/gimplify.c                |   4 +-
 gcc/ipa-cp.c                  |  66 +++---
 gcc/ipa-inline-analysis.c     |  48 ++---
 gcc/ipa-inline-transform.c    |  46 ++--
 gcc/ipa-inline.c              | 166 +++++++--------
 gcc/ipa-prop.c                |  56 ++---
 gcc/ipa-pure-const.c          |  54 ++---
 gcc/ipa-ref-inline.h          |   4 +-
 gcc/ipa-ref.c                 |  14 +-
 gcc/ipa-ref.h                 |   6 +-
 gcc/ipa-reference.c           |  60 +++---
 gcc/ipa-split.c               |  26 +--
 gcc/ipa-utils.c               |  46 ++--
 gcc/ipa.c                     | 410 ++++++++++++++++++------------------
 gcc/is-a.h                    |   8 +-
 gcc/java/decl.c               |   2 +-
 gcc/lto-cgraph.c              | 224 ++++++++++----------
 gcc/lto-streamer-in.c         |   4 +-
 gcc/lto-streamer-out.c        |  38 ++--
 gcc/lto-symtab.c              | 198 ++++++++---------
 gcc/lto/lto-partition.c       | 126 +++++------
 gcc/lto/lto.c                 |  26 +--
 gcc/passes.c                  |  28 +--
 gcc/symtab.c                  | 372 ++++++++++++++++----------------
 gcc/toplev.c                  |   6 +-
 gcc/trans-mem.c               |  94 ++++-----
 gcc/tree-eh.c                 |   4 +-
 gcc/tree-emutls.c             |  38 ++--
 gcc/tree-inline.c             |  36 ++--
 gcc/tree-nested.c             |  10 +-
 gcc/tree-pretty-print.c       |   2 +-
 gcc/tree-profile.c            |  20 +-
 gcc/tree-sra.c                |  20 +-
 gcc/tree-ssa-structalias.c    |  40 ++--
 gcc/tree-vectorizer.c         |   2 +-
 gcc/tree.c                    |  10 +-
 gcc/value-prof.c              |  18 +-
 gcc/varasm.c                  |  30 +--
 gcc/varpool.c                 | 118 +++++------
 58 files changed, 1881 insertions(+), 1669 deletions(-)

-- 
1.7.11.7

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH 2/2] Autogenerated fixes of "->symbol." to "->"
  2013-08-16  0:58 [PATCH 0/2] Port symtab/cgraph/varpool nodes to use C++ inheritance David Malcolm
@ 2013-08-16  0:58 ` David Malcolm
  2013-08-16  0:58 ` [PATCH 1/2] Convert symtab, cgraph and varpool nodes into a real class hierarchy David Malcolm
  2013-08-20 21:06 ` [PATCH 0/2] Port symtab/cgraph/varpool nodes to use C++ inheritance Jan Hubicka
  2 siblings, 0 replies; 39+ messages in thread
From: David Malcolm @ 2013-08-16  0:58 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jan Hubicka, David Malcolm

This patch is 384KB in size, so to avoid exceeding mailing list limits
I've uploaded it to:

http://dmalcolm.fedorapeople.org/gcc/large-patches/6a680b99445e0a734f9270150534bb5b2bd77cdf-0002-Autogenerated-fixes-of-symbol.-to.patch

The following is just the proposed ChangeLog entry and the diffstat.

gcc/

	Patch autogenerated by refactor_symtab.py from
	https://github.com/davidmalcolm/gcc-refactoring-scripts
	revision e1f5fb89719e99ffa17cdd15e77e90790572acf3

	* asan.c (asan_finish_file): Update for conversion of symtab types to
	a true class hierarchy.
	* cfgexpand.c (estimated_stack_frame_size): Likewise.
	* cgraph.c (record_function_versions): Likewise.
	(cgraph_create_empty_node): Likewise.
	(cgraph_create_node): Likewise.
	(cgraph_create_function_alias): Likewise.
	(cgraph_same_body_alias): Likewise.
	(cgraph_add_thunk): Likewise.
	(cgraph_node_for_asm): Likewise.
	(cgraph_set_call_stmt): Likewise.
	(cgraph_create_edge_1): Likewise.
	(cgraph_turn_edge_to_speculative): Likewise.
	(cgraph_speculative_call_info): Likewise.
	(cgraph_resolve_speculation): Likewise.
	(cgraph_make_edge_direct): Likewise.
	(cgraph_redirect_edge_call_stmt_to_callee): Likewise.
	(cgraph_update_edges_for_call_stmt_node): Likewise.
	(cgraph_release_function_body): Likewise.
	(cgraph_remove_node): Likewise.
	(cgraph_mark_address_taken_node): Likewise.
	(cgraph_rtl_info): Likewise.
	(dump_cgraph_node): Likewise.
	(cgraph_function_body_availability): Likewise.
	(cgraph_node_cannot_be_local_p_1): Likewise.
	(cgraph_node_can_be_local_p): Likewise.
	(cgraph_for_node_thunks_and_aliases): Likewise.
	(cgraph_for_node_and_aliases): Likewise.
	(cgraph_make_node_local_1): Likewise.
	(cgraph_set_nothrow_flag_1): Likewise.
	(cgraph_set_const_flag_1): Likewise.
	(cgraph_set_pure_flag_1): Likewise.
	(cgraph_propagate_frequency_1): Likewise.
	(cgraph_propagate_frequency): Likewise.
	(cgraph_node_cannot_return): Likewise.
	(cgraph_can_remove_if_no_direct_calls_and_refs_p): Likewise.
	(cgraph_can_remove_if_no_direct_calls_p): Likewise.
	(cgraph_will_be_removed_from_program_if_no_direct_calls): Likewise.
	(verify_edge_count_and_frequency): Likewise.
	(verify_edge_corresponds_to_fndecl): Likewise.
	(verify_cgraph_node): Likewise.
	(cgraph_get_create_real_symbol_node): Likewise.
	(cgraph_get_body): Likewise.
	* cgraph.h (None): Likewise.
	(cgraph_turn_edge_to_speculative): Likewise.
	(varpool): Likewise.
	(cgraph_node_asm_name): Likewise.
	(varpool_first_variable): Likewise.
	(varpool_next_variable): Likewise.
	(varpool_first_static_initializer): Likewise.
	(varpool_next_static_initializer): Likewise.
	(varpool_first_defined_variable): Likewise.
	(varpool_next_defined_variable): Likewise.
	(cgraph_first_defined_function): Likewise.
	(cgraph_next_defined_function): Likewise.
	(cgraph_first_function): Likewise.
	(cgraph_next_function): Likewise.
	(cgraph_function_with_gimple_body_p): Likewise.
	(cgraph_first_function_with_gimple_body): Likewise.
	(cgraph_next_function_with_gimple_body): Likewise.
	(cgraph_only_called_directly_or_aliased_p): Likewise.
	(varpool_can_remove_if_no_refs): Likewise.
	(varpool_all_refs_explicit_p): Likewise.
	(symtab_alias_target): Likewise.
	(cgraph_edge_recursive_p): Likewise.
	(cgraph_mark_force_output_node): Likewise.
	(symtab_real_symbol_p): Likewise.
	* cgraphbuild.c (record_eh_tables): Likewise.
	(rebuild_cgraph_edges): Likewise.
	(cgraph_rebuild_references): Likewise.
	(remove_cgraph_callee_edges): Likewise.
	* cgraphclones.c (cgraph_clone_node): Likewise.
	(cgraph_create_virtual_clone): Likewise.
	(cgraph_find_replacement_node): Likewise.
	(update_call_expr): Likewise.
	(cgraph_copy_node_for_versioning): Likewise.
	(cgraph_materialize_clone): Likewise.
	(cgraph_materialize_all_clones): Likewise.
	* cgraphunit.c (decide_is_symbol_needed): Likewise.
	(enqueue_node): Likewise.
	(cgraph_process_new_functions): Likewise.
	(cgraph_reset_node): Likewise.
	(referred_to_p): Likewise.
	(cgraph_finalize_function): Likewise.
	(cgraph_add_new_function): Likewise.
	(analyze_function): Likewise.
	(cgraph_process_same_body_aliases): Likewise.
	(process_function_and_variable_attributes): Likewise.
	(varpool_finalize_decl): Likewise.
	(analyze_functions): Likewise.
	(handle_alias_pairs): Likewise.
	(mark_functions_to_output): Likewise.
	(expand_thunk): Likewise.
	(assemble_thunks_and_aliases): Likewise.
	(expand_function): Likewise.
	(output_in_order): Likewise.
	(output_weakrefs): Likewise.
	(compile): Likewise.
	* coverage.c (coverage_compute_profile_id): Likewise.
	* dbxout.c (dbxout_expand_expr): Likewise.
	* dwarf2out.c (reference_to_unused): Likewise.
	(premark_types_used_by_global_vars_helper): Likewise.
	* gimple-fold.c (can_refer_decl_in_current_unit_p): Likewise.
	* gimplify.c (unshare_body): Likewise.
	(unvisit_body): Likewise.
	* ipa-cp.c (edge_within_scc): Likewise.
	(print_lattice): Likewise.
	(print_all_lattices): Likewise.
	(determine_versionability): Likewise.
	(ipcp_cloning_candidate_p): Likewise.
	(initialize_node_lattices): Likewise.
	(propagate_constants_accross_call): Likewise.
	(devirtualization_time_bonus): Likewise.
	(good_cloning_opportunity_p): Likewise.
	(estimate_local_effects): Likewise.
	(propagate_constants_topo): Likewise.
	(ipcp_propagate_stage): Likewise.
	(update_profiling_info): Likewise.
	(create_specialized_node): Likewise.
	(perhaps_add_new_callers): Likewise.
	(decide_about_value): Likewise.
	(decide_whether_version_node): Likewise.
	(identify_dead_nodes): Likewise.
	(ipcp_decision_stage): Likewise.
	(ipcp_generate_summary): Likewise.
	* ipa-inline-analysis.c (dump_inline_edge_summary): Likewise.
	(dump_inline_summary): Likewise.
	(initialize_inline_failed): Likewise.
	(compute_bb_predicates): Likewise.
	(estimate_function_body_sizes): Likewise.
	(compute_inline_parameters): Likewise.
	(estimate_edge_devirt_benefit): Likewise.
	(estimate_node_size_and_time): Likewise.
	(simple_edge_hints): Likewise.
	(do_estimate_growth): Likewise.
	(inline_analyze_function): Likewise.
	(inline_generate_summary): Likewise.
	(inline_write_summary): Likewise.
	* ipa-inline-transform.c (can_remove_node_now_p_1): Likewise.
	(can_remove_node_now_p): Likewise.
	(clone_inlined_nodes): Likewise.
	(inline_call): Likewise.
	(save_inline_function_body): Likewise.
	(preserve_function_body_p): Likewise.
	(inline_transform): Likewise.
	* ipa-inline.c (report_inline_failed_reason): Likewise.
	(can_inline_edge_p): Likewise.
	(can_early_inline_edge_p): Likewise.
	(num_calls): Likewise.
	(want_early_inline_function_p): Likewise.
	(want_inline_small_function_p): Likewise.
	(want_inline_self_recursive_call_p): Likewise.
	(relative_time_benefit): Likewise.
	(edge_badness): Likewise.
	(update_edge_key): Likewise.
	(reset_edge_caches): Likewise.
	(update_caller_keys): Likewise.
	(recursive_inlining): Likewise.
	(inline_small_functions): Likewise.
	(flatten_function): Likewise.
	(ipa_inline): Likewise.
	(inline_always_inline_functions): Likewise.
	(early_inline_small_functions): Likewise.
	(early_inliner): Likewise.
	* ipa-prop.c (ipa_func_spec_opts_forbid_analysis_p): Likewise.
	(ipa_populate_param_decls): Likewise.
	(ipa_initialize_node_params): Likewise.
	(ipa_print_node_jump_functions): Likewise.
	(ipa_compute_jump_functions): Likewise.
	(ipa_analyze_params_uses): Likewise.
	(ipa_analyze_node): Likewise.
	(ipa_make_edge_direct_to_target): Likewise.
	(remove_described_reference): Likewise.
	(update_indirect_edges_after_inlining): Likewise.
	(propagate_controlled_uses): Likewise.
	(ipa_print_node_params): Likewise.
	(ipa_modify_call_arguments): Likewise.
	(ipa_prop_read_section): Likewise.
	(read_replacements_section): Likewise.
	(ipcp_transform_function): Likewise.
	* ipa-pure-const.c (analyze_function): Likewise.
	(pure_const_write_summary): Likewise.
	(pure_const_read_summary): Likewise.
	(propagate_pure_const): Likewise.
	(propagate_nothrow): Likewise.
	* ipa-ref-inline.h (ipa_ref_referring_ref_list): Likewise.
	(ipa_ref_referred_ref_list): Likewise.
	* ipa-ref.c (ipa_record_reference): Likewise.
	(ipa_dump_references): Likewise.
	(ipa_dump_referring): Likewise.
	(ipa_find_reference): Likewise.
	(ipa_remove_stmt_references): Likewise.
	(ipa_clear_stmts_in_references): Likewise.
	* ipa-reference.c (ipa_reference_get_not_read_global): Likewise.
	(ipa_reference_get_not_written_global): Likewise.
	(propagate_bits): Likewise.
	(analyze_function): Likewise.
	(generate_summary): Likewise.
	(read_write_all_from_decl): Likewise.
	(propagate): Likewise.
	(write_node_summary_p): Likewise.
	(ipa_reference_write_optimization_summary): Likewise.
	(ipa_reference_read_optimization_summary): Likewise.
	* ipa-split.c (split_function): Likewise.
	(execute_split_functions): Likewise.
	* ipa-utils.c (searchc): Likewise.
	(ipa_reduced_postorder): Likewise.
	(ipa_free_postorder_info): Likewise.
	(ipa_get_nodes_in_cycle): Likewise.
	(ipa_reverse_postorder): Likewise.
	(dump_cgraph_node_set): Likewise.
	* ipa.c (cgraph_non_local_node_p_1): Likewise.
	(has_addr_references_p): Likewise.
	(enqueue_node): Likewise.
	(process_references): Likewise.
	(symtab_remove_unreachable_nodes): Likewise.
	(ipa_discover_readonly_nonaddressable_vars): Likewise.
	(address_taken_from_non_vtable_p): Likewise.
	(comdat_can_be_unshared_p_1): Likewise.
	(comdat_can_be_unshared_p): Likewise.
	(cgraph_externally_visible_p): Likewise.
	(varpool_externally_visible_p): Likewise.
	(can_replace_by_local_alias): Likewise.
	(function_and_variable_visibility): Likewise.
	(ipa_profile_generate_summary): Likewise.
	(ipa_profile): Likewise.
	(record_cdtor_fn): Likewise.
	(ipa_cdtor_merge): Likewise.
	* is-a.h (None): Likewise.
	* lto-cgraph.c (lto_output_edge): Likewise.
	(referenced_from_other_partition_p): Likewise.
	(reachable_from_other_partition_p): Likewise.
	(lto_output_node): Likewise.
	(lto_output_varpool_node): Likewise.
	(output_refs): Likewise.
	(compute_ltrans_boundary): Likewise.
	(input_overwrite_node): Likewise.
	(input_node): Likewise.
	(input_varpool_node): Likewise.
	(input_edge): Likewise.
	(input_cgraph_1): Likewise.
	(merge_profile_summaries): Likewise.
	(input_symtab): Likewise.
	* lto-streamer-in.c (fixup_call_stmt_edges_1): Likewise.
	(fixup_call_stmt_edges): Likewise.
	* lto-streamer-out.c (output_function): Likewise.
	(copy_function): Likewise.
	(lto_output): Likewise.
	(write_symbol): Likewise.
	(output_symbol_p): Likewise.
	(produce_symtab): Likewise.
	* lto-symtab.c (lto_cgraph_replace_node): Likewise.
	(lto_varpool_replace_node): Likewise.
	(lto_symtab_merge): Likewise.
	(lto_symtab_resolve_replaceable_p): Likewise.
	(lto_symtab_symbol_p): Likewise.
	(lto_symtab_resolve_can_prevail_p): Likewise.
	(lto_symtab_resolve_symbols): Likewise.
	(lto_symtab_merge_decls_2): Likewise.
	(lto_symtab_merge_decls_1): Likewise.
	(lto_symtab_merge_decls): Likewise.
	(lto_symtab_merge_symbols_1): Likewise.
	(lto_symtab_merge_symbols): Likewise.
	(lto_symtab_prevailing_decl): Likewise.
	* passes.c (dump_passes): Likewise.
	(do_per_function): Likewise.
	(do_per_function_toporder): Likewise.
	(ipa_write_summaries): Likewise.
	(ipa_write_optimization_summaries): Likewise.
	(function_called_by_processed_nodes_p): Likewise.
	* symtab.c (hash_node): Likewise.
	(eq_node): Likewise.
	(hash_node_by_assembler_name): Likewise.
	(eq_assembler_name): Likewise.
	(insert_to_assembler_name_hash): Likewise.
	(unlink_from_assembler_name_hash): Likewise.
	(symtab_register_node): Likewise.
	(symtab_insert_node_to_hashtable): Likewise.
	(symtab_unregister_node): Likewise.
	(symtab_add_to_same_comdat_group): Likewise.
	(symtab_dissolve_same_comdat_group_list): Likewise.
	(symtab_node_asm_name): Likewise.
	(symtab_node_name): Likewise.
	(dump_symtab_base): Likewise.
	(verify_symtab_base): Likewise.
	(symtab_used_from_object_file_p): Likewise.
	(symtab_alias_ultimate_target): Likewise.
	(fixup_same_cpp_alias_visibility): Likewise.
	(symtab_resolve_alias): Likewise.
	(symtab_for_node_and_aliases): Likewise.
	(symtab_nonoverwritable_alias_1): Likewise.
	(symtab_nonoverwritable_alias): Likewise.
	* toplev.c (wrapup_global_declaration_2): Likewise.
	* trans-mem.c (get_cg_data): Likewise.
	(ipa_tm_scan_calls_clone): Likewise.
	(ipa_tm_note_irrevocable): Likewise.
	(ipa_tm_scan_irr_function): Likewise.
	(ipa_tm_mayenterirr_function): Likewise.
	(ipa_tm_diagnose_tm_safe): Likewise.
	(ipa_tm_mark_force_output_node): Likewise.
	(ipa_tm_mark_forced_by_abi_node): Likewise.
	(ipa_tm_create_version_alias): Likewise.
	(ipa_tm_create_version): Likewise.
	(ipa_tm_insert_irr_call): Likewise.
	(ipa_tm_insert_gettmclone_call): Likewise.
	(ipa_tm_transform_calls_redirect): Likewise.
	(ipa_tm_transform_transaction): Likewise.
	(ipa_tm_transform_clone): Likewise.
	(ipa_tm_execute): Likewise.
	* tree-eh.c (tree_could_trap_p): Likewise.
	* tree-emutls.c (new_emutls_decl): Likewise.
	(emutls_decl): Likewise.
	(gen_emutls_addr): Likewise.
	(lower_emutls_function_body): Likewise.
	(create_emultls_var): Likewise.
	(ipa_lower_emutls): Likewise.
	* tree-inline.c (copy_bb): Likewise.
	(estimate_num_insns): Likewise.
	(expand_call_inline): Likewise.
	(optimize_inline_calls): Likewise.
	(tree_function_versioning): Likewise.
	* tree-nested.c (check_for_nested_with_variably_modified): Likewise.
	(create_nesting_tree): Likewise.
	(gimplify_all_functions): Likewise.
	* tree-pretty-print.c (dump_function_header): Likewise.
	* tree-profile.c (tree_profiling): Likewise.
	* tree-sra.c (convert_callers_for_node): Likewise.
	(convert_callers): Likewise.
	(modify_function): Likewise.
	(ipa_sra_preliminary_function_checks): Likewise.
	* tree-ssa-structalias.c (get_constraint_for_ssa_var): Likewise.
	(create_variable_info_for): Likewise.
	(associate_varinfo_to_alias): Likewise.
	(ipa_pta_execute): Likewise.
	* tree-vectorizer.c (increase_alignment): Likewise.
	* tree.c (free_lang_data_in_decl): Likewise.
	(find_decls_types_in_node): Likewise.
	(find_decls_types_in_var): Likewise.
	* value-prof.c (init_node_map): Likewise.
	(check_ic_target): Likewise.
	(gimple_ic): Likewise.
	(gimple_ic_transform): Likewise.
	* varasm.c (mark_decl_referenced): Likewise.
	(find_decl): Likewise.
	(assemble_alias): Likewise.
	(dump_tm_clone_pairs): Likewise.
	(default_binds_local_p_1): Likewise.
	(decl_binds_to_current_def_p): Likewise.
	* varpool.c (varpool_create_empty_node): Likewise.
	(varpool_node_for_decl): Likewise.
	(varpool_remove_node): Likewise.
	(varpool_remove_initializer): Likewise.
	(dump_varpool_node): Likewise.
	(ctor_for_folding): Likewise.
	(varpool_add_new_variable): Likewise.
	(cgraph_variable_initializer_availability): Likewise.
	(varpool_analyze_node): Likewise.
	(assemble_aliases): Likewise.
	(varpool_assemble_decl): Likewise.
	(enqueue_node): Likewise.
	(varpool_remove_unreferenced_decls): Likewise.
	(varpool_finalize_named_section_flags): Likewise.
	(add_new_static_var): Likewise.
	(varpool_create_variable_alias): Likewise.
	(varpool_extra_name_alias): Likewise.
	(varpool_for_node_and_aliases): Likewise.
	* config/i386/i386.c (ix86_get_function_versions_dispatcher):
	Likewise.
	(ix86_generate_version_dispatcher_body): Likewise.

gcc/ada/

	Patch autogenerated by refactor_symtab.py from
	https://github.com/davidmalcolm/gcc-refactoring-scripts
	revision e1f5fb89719e99ffa17cdd15e77e90790572acf3

	* gcc-interface/trans.c (finalize_nrv): Update for conversion of
	symtab types to a true class hierarchy.
	* gcc-interface/utils.c (gnat_write_global_declarations): Likewise.

gcc/c-family/

	Patch autogenerated by refactor_symtab.py from
	https://github.com/davidmalcolm/gcc-refactoring-scripts
	revision e1f5fb89719e99ffa17cdd15e77e90790572acf3

	* c-gimplify.c (c_genericize): Update for conversion of symtab types
	to a true class hierarchy.
	* c-pragma.c (maybe_apply_pending_pragma_weaks): Likewise.

gcc/cp/

	Patch autogenerated by refactor_symtab.py from
	https://github.com/davidmalcolm/gcc-refactoring-scripts
	revision e1f5fb89719e99ffa17cdd15e77e90790572acf3

	* call.c (mark_versions_used): Update for conversion of symtab types
	to a true class hierarchy.
	* decl2.c (maybe_make_one_only): Likewise.
	(var_finalized_p): Likewise.
	(mark_needed): Likewise.
	(collect_candidates_for_java_method_aliases): Likewise.
	(build_java_method_aliases): Likewise.
	(clear_decl_external): Likewise.
	(cp_write_global_declarations): Likewise.
	* tree.c (cp_fix_function_decl_p): Likewise.

gcc/java/

	Patch autogenerated by refactor_symtab.py from
	https://github.com/davidmalcolm/gcc-refactoring-scripts
	revision e1f5fb89719e99ffa17cdd15e77e90790572acf3

	* decl.c (java_mark_decl_local): Update for conversion of symtab types
	to a true class hierarchy.

gcc/lto/

	Patch autogenerated by refactor_symtab.py from
	https://github.com/davidmalcolm/gcc-refactoring-scripts
	revision e1f5fb89719e99ffa17cdd15e77e90790572acf3

	* lto-partition.c (get_symbol_class): Update for conversion of symtab
	types to a true class hierarchy.
	(symbol_partitioned_p): Likewise.
	(add_references_to_partition): Likewise.
	(add_symbol_to_partition_1): Likewise.
	(contained_in_symbol): Likewise.
	(add_symbol_to_partition): Likewise.
	(undo_partition): Likewise.
	(lto_1_to_1_map): Likewise.
	(node_cmp): Likewise.
	(varpool_node_cmp): Likewise.
	(lto_balanced_map): Likewise.
	(privatize_symbol_name): Likewise.
	(promote_symbol): Likewise.
	(rename_statics): Likewise.
	(lto_promote_cross_file_statics): Likewise.
	* lto.c (has_analyzed_clone_p): Likewise.
	(lto_materialize_function): Likewise.
	(cmp_partitions_order): Likewise.
	(read_cgraph_and_symbols): Likewise.
	(materialize_cgraph): Likewise.
	(do_whole_program_analysis): Likewise.
	(lto_main): Likewise.
---
 gcc/ada/gcc-interface/trans.c |   2 +-
 gcc/ada/gcc-interface/utils.c |   2 +-
 gcc/asan.c                    |  10 +-
 gcc/c-family/c-gimplify.c     |   2 +-
 gcc/c-family/c-pragma.c       |   2 +-
 gcc/cfgexpand.c               |   2 +-
 gcc/cgraph.c                  | 262 +++++++++++++--------------
 gcc/cgraph.h                  | 102 +++++------
 gcc/cgraphbuild.c             |  10 +-
 gcc/cgraphclones.c            |  84 ++++-----
 gcc/cgraphunit.c              | 260 +++++++++++++--------------
 gcc/config/i386/i386.c        |  18 +-
 gcc/coverage.c                |   4 +-
 gcc/cp/call.c                 |   2 +-
 gcc/cp/decl2.c                |  24 +--
 gcc/cp/tree.c                 |   4 +-
 gcc/dbxout.c                  |   2 +-
 gcc/dwarf2out.c               |   4 +-
 gcc/gimple-fold.c             |   8 +-
 gcc/gimplify.c                |   4 +-
 gcc/ipa-cp.c                  |  66 +++----
 gcc/ipa-inline-analysis.c     |  48 ++---
 gcc/ipa-inline-transform.c    |  46 ++---
 gcc/ipa-inline.c              | 166 ++++++++---------
 gcc/ipa-prop.c                |  56 +++---
 gcc/ipa-pure-const.c          |  54 +++---
 gcc/ipa-ref-inline.h          |   4 +-
 gcc/ipa-ref.c                 |  14 +-
 gcc/ipa-reference.c           |  60 +++----
 gcc/ipa-split.c               |  26 +--
 gcc/ipa-utils.c               |  46 ++---
 gcc/ipa.c                     | 410 +++++++++++++++++++++---------------------
 gcc/is-a.h                    |   2 +-
 gcc/java/decl.c               |   2 +-
 gcc/lto-cgraph.c              | 224 +++++++++++------------
 gcc/lto-streamer-in.c         |   4 +-
 gcc/lto-streamer-out.c        |  38 ++--
 gcc/lto-symtab.c              | 198 ++++++++++----------
 gcc/lto/lto-partition.c       | 126 ++++++-------
 gcc/lto/lto.c                 |  26 +--
 gcc/passes.c                  |  28 +--
 gcc/symtab.c                  | 368 ++++++++++++++++++-------------------
 gcc/toplev.c                  |   6 +-
 gcc/trans-mem.c               |  94 +++++-----
 gcc/tree-eh.c                 |   4 +-
 gcc/tree-emutls.c             |  38 ++--
 gcc/tree-inline.c             |  36 ++--
 gcc/tree-nested.c             |  10 +-
 gcc/tree-pretty-print.c       |   2 +-
 gcc/tree-profile.c            |  20 +--
 gcc/tree-sra.c                |  20 +--
 gcc/tree-ssa-structalias.c    |  40 ++---
 gcc/tree-vectorizer.c         |   2 +-
 gcc/tree.c                    |  10 +-
 gcc/value-prof.c              |  18 +-
 gcc/varasm.c                  |  30 ++--
 gcc/varpool.c                 | 118 ++++++------
 57 files changed, 1634 insertions(+), 1634 deletions(-)

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 0/2] Port symtab/cgraph/varpool nodes to use C++ inheritance
  2013-08-16  0:58 [PATCH 0/2] Port symtab/cgraph/varpool nodes to use C++ inheritance David Malcolm
  2013-08-16  0:58 ` [PATCH 2/2] Autogenerated fixes of "->symbol." to "->" David Malcolm
  2013-08-16  0:58 ` [PATCH 1/2] Convert symtab, cgraph and varpool nodes into a real class hierarchy David Malcolm
@ 2013-08-20 21:06 ` Jan Hubicka
  2013-08-21 10:03   ` Martin Jambor
                     ` (2 more replies)
  2 siblings, 3 replies; 39+ messages in thread
From: Jan Hubicka @ 2013-08-20 21:06 UTC (permalink / raw)
  To: David Malcolm; +Cc: gcc-patches, Jan Hubicka

Hi,
sorry for late reply, I noticed the patch only yesterday.

> Honza: following up from our IRC chat, I've ported the symtab, cgraph
> and varpool nodes from the current hand-coded inheritance-in-C scheme
> to being a C+ class hierarchy.
> 
> I know you're in the middle of making lots of other changes to this code,
> so I've written a script to automate the parts of the conversion where
> appropriate - see below.
> 
> In summary,
>   struct GTY(()) symtab_node_base
> becomes:
>   class GTY((user)) symtab_node_base
> 
> and the subclasses:
>   struct GTY(()) cgraph_node
> and:
>   struct GTY(()) varpool_node
> 
> become (respectively):
>   struct GTY((user)) cgraph_node : public symtab_node_base
> and:
>   class GTY((user)) varpool_node : public symtab_node_base

I am not quite sure why we need symtab_node_base.

symtab_node is meant to be basetype of the symbols.  Symbols can be either functions or variables.
I would expect then
   struct GTY((user)) cgraph_node : public symtab_node
   class GTY((user)) varpool_node : public symtab_node

> 
> The symtab_node_def union goes away, as do the "symbol" fields at the
> top of the two subclasses.

Yes, this is very nice.
> 
> I kept the existing names for things, and the "struct" for cgraph_node
> since it is often referred to as "struct cgraph_node".

In fact I think we should take the chance to rename
cgraph_node -> symtab_function
varpool_node-> symtab_variable
(or symtab_func/symtab_var as suggested by Martin today, I am fine with both)
symtab_node may also be better as symtab_symbol.  So the hearchy would be
that symbol table consists of symbols and symbols can be function or entries.

The original naming comes from callgraph code that is over decade old now.
node is because graph has nodes and edges.

We can also do this incrementally on the top of the hard work of getting the
hiearchy in at first place, if that seems easier for you.  Indeed there are
some references to it in comments, but they should be updated.

I am OK with temporary inconsistency with naming and I will be happy to
continue with incremental cleanups.
> 
> The patch is in three parts; all three are needed.
> 
>   * a fix for a bug in gengtype:
>       http://gcc.gnu.org/ml/gcc-patches/2013-08/msg00882.html
>     This is needed to avoid generating a malfunctioning gtype-desc.c
>     *some* of the time - in capriciously changing ways as the sources
>     change... :(   I sent it separately since I'm running into this
>     issue with other changes I'm trying out; it "randomly" appears
>     when trying to use GTY((user)).

I can't approve this change, unfortunately.
Note that cgraph node also go into PCH, so be sure to check that PCH
works well with the changes.
> 
>   * Patch 1 of the 2 in this series is the hand-written part of the
>     conversion.  This makes the changes above, plus various workarounds
>     for dealing with yet more issues in how gengtype handles
>     GTY((user)).

I will comment on this in the followup mail.
> 
>   * Patch 2 of the 2 in this series is the autogenerated part.
>     Currently to access the base symtab fields of a cgraph or varpool
>     node, the code has e.g.
> 
>        node->symbol.decl
> 
>     whereas with C++ inheritance, the "symbol" field is no more, and we
>     directly use the base-class field:
> 
>        node->decl

Indeed, this is very nice.  We also use
(symtab_node)node whenver we need to go from cgraph/varpool node back
to basetype.  These should go, too.
Finally I introduced cgraph(node)/varpool(node) functions that converts
symtab node to cgraph/varpool node and ICEs when failed.

We probably should use our new template conversions.  We have is_a
predicate and dyn_cast convertor that returns NULL on failure.  Do
we have variant that ICEs when conversion is not possible?
> 
> How does this look?  Are there other automated changes you'd like me
> to make?   How should I go about getting this into trunk, given that you
> have many other changes to this code on the way?

I like the general direction and I am grateful you work on it :) Lets go with
this as first step.  Incrementally I think the ipa-ref API should be cleaned up
(it worked around model before we had basetype for cgraph/varpool) and I am
having quite long TODO list on the top of that.

Honza

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 1/2] Convert symtab, cgraph and varpool nodes into a real class hierarchy
  2013-08-16  0:58 ` [PATCH 1/2] Convert symtab, cgraph and varpool nodes into a real class hierarchy David Malcolm
@ 2013-08-20 21:26   ` Jan Hubicka
  2013-08-20 21:31     ` Steven Bosscher
  2013-08-27 11:10   ` Richard Biener
  1 sibling, 1 reply; 39+ messages in thread
From: Jan Hubicka @ 2013-08-20 21:26 UTC (permalink / raw)
  To: David Malcolm; +Cc: gcc-patches, Jan Hubicka

> +/* GTY((user)) hooks for symtab_node_base (and its subclasses).
> +   We could use virtual functions for this, but given the presence of the
> +   "type" field and the trivial size of the class hierarchy, switches are
> +   perhaps simpler and faster.  */

Generally I am not really happy about the hand marking - why can't GTY just handle
it by itself?  Do we have some eisting exmaple of this?

GTY was in a way of getting proper class hiearchy for quite a while and this is
probably less ugly than C-syntax-classes we have now.  But it would be nice to
have some longer term plan what to do here.  Obviously this is going to make
any changes to GGC implementation close to imposible since all the
implementation details are exposed now.
> +/* Workarounds for deficiencies in gengtype's handling of GTY((user)).
> +
> +   gengtype walks the graph of the *types* in the code, and produces
> +   functions in gtype-desc.[ch] for all types that are reachable from a
> +   GTY root.
> +
> +   However, it ignores the contents of GTY((user)) types when walking
> +   this graph.
> +
> +   Hence if you have a subgraph of types that are only reachable
> +   via fields in GTY((user)) types, gengtype won't generate helper code
> +   for those types.
> +
> +   Ideally there would be some way to mark a GTY((user)) type to say
> +   which types it references, to avoid having to mark these types as
> +   GTY((user)).
> +
> +   For now, work around this issue by providing explicit roots of the
> +   missing types, of dummy variables.  */
> +
> +/* Force gengtype into providing GTY hooks for the type of this field:
> +     htab_t GTY((param_is (struct cgraph_edge))) call_site_hash;
> +   within cgraph_node.  */
> +static GTY(()) htab_t GTY((param_is (struct cgraph_edge))) dummy_call_site_hash;

I think call site hash can safely go off GGC memory.  All statements are linked
from CFG.
> +
> +/* Similarly for this field of symtab_node_base:
> +     struct ipa_ref_list ref_list;
> + */
> +static GTY((deletable)) struct ipa_ref_list *dummy_ipa_ref_list;
> +
> +/* Similarly for this field of cgraph_node:
> +     struct cgraph_clone_info clone;
> +*/
> +static GTY((deletable)) struct cgraph_clone_info *dummy_cgraph_clone_info;
> +
> +/* Non-existent pointer, to trick gengtype into (correctly) realizing that
> +   ipa_replace_map is indeed used in the code, and thus should have ggc_alloc_*
> +   routines.  */
> +static GTY((deletable)) struct ipa_replace_map *dummy_ipa_replace_map_pointer;
> +
> +/* Non-existent pointer, to trick gengtype into (correctly) realizing that
> +   varpool_node is indeed used in the code, and thus should have ggc_alloc_*
> +   routines.  */
> +static GTY((deletable)) varpool_node *dummy_varpool_node_ptr;
> +

I would really like some GGC/middle-end or global maintainer to comment on these
changes.

The rest of changes seems fine to me with the comments from first email ;)

Honza

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 1/2] Convert symtab, cgraph and varpool nodes into a real class hierarchy
  2013-08-20 21:26   ` Jan Hubicka
@ 2013-08-20 21:31     ` Steven Bosscher
  2013-08-20 21:34       ` Jan Hubicka
  0 siblings, 1 reply; 39+ messages in thread
From: Steven Bosscher @ 2013-08-20 21:31 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: David Malcolm, GCC Patches

On Tue, Aug 20, 2013 at 11:06 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
>> +/* GTY((user)) hooks for symtab_node_base (and its subclasses).
>> +   We could use virtual functions for this, but given the presence of the
>> +   "type" field and the trivial size of the class hierarchy, switches are
>> +   perhaps simpler and faster.  */
>
> Generally I am not really happy about the hand marking - why can't GTY just handle
> it by itself?  Do we have some eisting exmaple of this?
>
> GTY was in a way of getting proper class hiearchy for quite a while and this is
> probably less ugly than C-syntax-classes we have now.  But it would be nice to
> have some longer term plan what to do here.  Obviously this is going to make
> any changes to GGC implementation close to imposible since all the
> implementation details are exposed now.

As far as I understand, the intent is to move to user markers, see:
http://gcc.gnu.org/ml/gcc-patches/2012-08/msg00630.html

On the up-side: This would allow explicitly-tracked objects to be
moved back out of GGC-space. Can't wait to put the CFG object back in
pools! :-) And I guess symtab objects are also explicitly tracked and
therefore candidates for a more cache-friendly allocation strategy...

Ciao!
Steven

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 1/2] Convert symtab, cgraph and varpool nodes into a real class hierarchy
  2013-08-20 21:31     ` Steven Bosscher
@ 2013-08-20 21:34       ` Jan Hubicka
  2013-08-20 21:42         ` Jan Hubicka
  0 siblings, 1 reply; 39+ messages in thread
From: Jan Hubicka @ 2013-08-20 21:34 UTC (permalink / raw)
  To: Steven Bosscher; +Cc: Jan Hubicka, David Malcolm, GCC Patches

> On Tue, Aug 20, 2013 at 11:06 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
> >> +/* GTY((user)) hooks for symtab_node_base (and its subclasses).
> >> +   We could use virtual functions for this, but given the presence of the
> >> +   "type" field and the trivial size of the class hierarchy, switches are
> >> +   perhaps simpler and faster.  */
> >
> > Generally I am not really happy about the hand marking - why can't GTY just handle
> > it by itself?  Do we have some eisting exmaple of this?
> >
> > GTY was in a way of getting proper class hiearchy for quite a while and this is
> > probably less ugly than C-syntax-classes we have now.  But it would be nice to
> > have some longer term plan what to do here.  Obviously this is going to make
> > any changes to GGC implementation close to imposible since all the
> > implementation details are exposed now.
> 
> As far as I understand, the intent is to move to user markers, see:
> http://gcc.gnu.org/ml/gcc-patches/2012-08/msg00630.html

OK, I have nothing against explicit user markers. It however seem to need a bit
of abstraction - just writting by hand whatever gengtype produces seems ugly.
> 
> On the up-side: This would allow explicitly-tracked objects to be
> moved back out of GGC-space. Can't wait to put the CFG object back in
> pools! :-) And I guess symtab objects are also explicitly tracked and
> therefore candidates for a more cache-friendly allocation strategy...

Indeed, nothing in symbol table needs to be garbage collected and everything is
freed explicitely.  We only have it in GGC because of PCH and the fact that we
hook trees out of that and we do not want them to be garbage collected out.

Honza
> 
> Ciao!
> Steven

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 1/2] Convert symtab, cgraph and varpool nodes into a real class hierarchy
  2013-08-20 21:34       ` Jan Hubicka
@ 2013-08-20 21:42         ` Jan Hubicka
  0 siblings, 0 replies; 39+ messages in thread
From: Jan Hubicka @ 2013-08-20 21:42 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: Steven Bosscher, David Malcolm, GCC Patches

> > On Tue, Aug 20, 2013 at 11:06 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
> > >> +/* GTY((user)) hooks for symtab_node_base (and its subclasses).
> > >> +   We could use virtual functions for this, but given the presence of the
> > >> +   "type" field and the trivial size of the class hierarchy, switches are
> > >> +   perhaps simpler and faster.  */
> > >
> > > Generally I am not really happy about the hand marking - why can't GTY just handle
> > > it by itself?  Do we have some eisting exmaple of this?
> > >
> > > GTY was in a way of getting proper class hiearchy for quite a while and this is
> > > probably less ugly than C-syntax-classes we have now.  But it would be nice to
> > > have some longer term plan what to do here.  Obviously this is going to make
> > > any changes to GGC implementation close to imposible since all the
> > > implementation details are exposed now.
> > 
> > As far as I understand, the intent is to move to user markers, see:
> > http://gcc.gnu.org/ml/gcc-patches/2012-08/msg00630.html
> 
> OK, I have nothing against explicit user markers. It however seem to need a bit
> of abstraction - just writting by hand whatever gengtype produces seems ugly.

However reading through the thread, I guess we do have agreement on going with user
markers, so I do not think it is a reason to hold the patch.

Honza

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 0/2] Port symtab/cgraph/varpool nodes to use C++ inheritance
  2013-08-20 21:06 ` [PATCH 0/2] Port symtab/cgraph/varpool nodes to use C++ inheritance Jan Hubicka
@ 2013-08-21 10:03   ` Martin Jambor
  2013-08-26 22:27   ` David Malcolm
  2013-09-09 19:32   ` [PATCH v2 0/6] Port symtab/cgraph/varpool nodes to use C++ inheritance; rename types David Malcolm
  2 siblings, 0 replies; 39+ messages in thread
From: Martin Jambor @ 2013-08-21 10:03 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: David Malcolm, gcc-patches

Hi,

On Tue, Aug 20, 2013 at 11:01:04PM +0200, Jan Hubicka wrote:

[...]

> >     Currently to access the base symtab fields of a cgraph or varpool
> >     node, the code has e.g.
> > 
> >        node->symbol.decl
> > 
> >     whereas with C++ inheritance, the "symbol" field is no more, and we
> >     directly use the base-class field:
> > 
> >        node->decl
> 
> Indeed, this is very nice.  We also use
> (symtab_node)node whenver we need to go from cgraph/varpool node back
> to basetype.  These should go, too.
> Finally I introduced cgraph(node)/varpool(node) functions that converts
> symtab node to cgraph/varpool node and ICEs when failed.
> 
> We probably should use our new template conversions.  We have is_a
> predicate and dyn_cast convertor that returns NULL on failure.  Do
> we have variant that ICEs when conversion is not possible?
> > 

as_a ...it ICEs when gcc is configured with checking (and happily does
invalid conversion otherwise).

Martin

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 0/2] Port symtab/cgraph/varpool nodes to use C++ inheritance
  2013-08-20 21:06 ` [PATCH 0/2] Port symtab/cgraph/varpool nodes to use C++ inheritance Jan Hubicka
  2013-08-21 10:03   ` Martin Jambor
@ 2013-08-26 22:27   ` David Malcolm
  2013-09-09 19:32   ` [PATCH v2 0/6] Port symtab/cgraph/varpool nodes to use C++ inheritance; rename types David Malcolm
  2 siblings, 0 replies; 39+ messages in thread
From: David Malcolm @ 2013-08-26 22:27 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: gcc-patches

On Tue, 2013-08-20 at 23:01 +0200, Jan Hubicka wrote:
[...]
> > 
> > In summary,
> >   struct GTY(()) symtab_node_base
> > becomes:
> >   class GTY((user)) symtab_node_base
> > 
> > and the subclasses:
> >   struct GTY(()) cgraph_node
> > and:
> >   struct GTY(()) varpool_node
> > 
> > become (respectively):
> >   struct GTY((user)) cgraph_node : public symtab_node_base
> > and:
> >   class GTY((user)) varpool_node : public symtab_node_base
> 
> I am not quite sure why we need symtab_node_base.
> 
> symtab_node is meant to be basetype of the symbols.  Symbols can be either functions or variables.
> I would expect then
>    struct GTY((user)) cgraph_node : public symtab_node
>    class GTY((user)) varpool_node : public symtab_node

Indeed, I would have used "symtab_node", but it's already in use as the
typedef of the *pointer* type - to quote the current ipa-ref.h:

   typedef union symtab_node_def *symtab_node;

So I kept the name "symtab_node_base".

I was also holding off on renames since you have other changes
in-flight.

> > The symtab_node_def union goes away, as do the "symbol" fields at the
> > top of the two subclasses.
> 
> Yes, this is very nice.
> > 
> > I kept the existing names for things, and the "struct" for cgraph_node
> > since it is often referred to as "struct cgraph_node".
> 
> In fact I think we should take the chance to rename
> cgraph_node -> symtab_function
> varpool_node-> symtab_variable
> (or symtab_func/symtab_var as suggested by Martin today, I am fine with both)
> symtab_node may also be better as symtab_symbol.  So the hearchy would be
> that symbol table consists of symbols and symbols can be function or entries.
> 
> The original naming comes from callgraph code that is over decade old now.
> node is because graph has nodes and edges.
> 
> We can also do this incrementally on the top of the hard work of getting the
> hiearchy in at first place, if that seems easier for you.  Indeed there are
> some references to it in comments, but they should be updated.

Given how much of this is done by a script (with its own test suite),
I'd be up for getting in such other changes at the same time.

Let the wild rumpus^Wbikesheddery commence! 

How about:

  class symtab_sym {};
  class symtab_func : public symtab_sym {};
  class symtab_var : public symtab_sym {};
  typedef symtab_sym *symtab_node;

In an ideal world I'd use a namespace for this, but I'm wary about
confusions between the symtab meaning of "function" vs the cfun meaning
of "function".

> I am OK with temporary inconsistency with naming and I will be happy to
> continue with incremental cleanups.
> > 
> > The patch is in three parts; all three are needed.
> > 
> >   * a fix for a bug in gengtype:
> >       http://gcc.gnu.org/ml/gcc-patches/2013-08/msg00882.html
[...]
> I can't approve this change, unfortunately.

This one is already approved and committed.

> >   * Patch 1 of the 2 in this series is the hand-written part of the
[...]

> > 
> >   * Patch 2 of the 2 in this series is the autogenerated part.
> >     Currently to access the base symtab fields of a cgraph or varpool
> >     node, the code has e.g.
> > 
> >        node->symbol.decl
> > 
> >     whereas with C++ inheritance, the "symbol" field is no more, and we
> >     directly use the base-class field:
> > 
> >        node->decl
> 
> Indeed, this is very nice.  We also use
> (symtab_node)node whenver we need to go from cgraph/varpool node back
> to basetype.  These should go, too.
> Finally I introduced cgraph(node)/varpool(node) functions that converts
> symtab node to cgraph/varpool node and ICEs when failed.
> 
> We probably should use our new template conversions.  We have is_a
> predicate and dyn_cast convertor that returns NULL on failure.  Do
> we have variant that ICEs when conversion is not possible?
> > 
> > How does this look?  Are there other automated changes you'd like me
> > to make?   How should I go about getting this into trunk, given that you
> > have many other changes to this code on the way?
> 
> I like the general direction and I am grateful you work on it :) Lets go with
> this as first step.  Incrementally I think the ipa-ref API should be cleaned up
> (it worked around model before we had basetype for cgraph/varpool) and I am
> having quite long TODO list on the top of that.
> 
> Honza






^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 1/2] Convert symtab, cgraph and varpool nodes into a real class hierarchy
  2013-08-16  0:58 ` [PATCH 1/2] Convert symtab, cgraph and varpool nodes into a real class hierarchy David Malcolm
  2013-08-20 21:26   ` Jan Hubicka
@ 2013-08-27 11:10   ` Richard Biener
  2013-08-27 11:48     ` Jan Hubicka
  2013-08-27 15:25     ` Mike Stump
  1 sibling, 2 replies; 39+ messages in thread
From: Richard Biener @ 2013-08-27 11:10 UTC (permalink / raw)
  To: David Malcolm; +Cc: GCC Patches, Jan Hubicka

On Fri, Aug 16, 2013 at 2:57 AM, David Malcolm <dmalcolm@redhat.com> wrote:
> This patch is the handwritten part of the conversion of these types
> to C++; it requires the followup patch, which is autogenerated.
>
> It converts:
>   struct GTY(()) symtab_node_base
> to:
>   class GTY((user)) symtab_node_base
>
> and converts:
>   struct GTY(()) cgraph_node
> to:
>   struct GTY((user)) cgraph_node : public symtab_node_base
>
> and:
>   struct GTY(()) varpool_node
> to:
>   class GTY((user)) varpool_node : public symtab_node_base
>
> dropping the symtab_node_def union.
>
> Since gengtype is unable to cope with inheritance, we have to mark the
> types with GTY((user)), and handcode the gty field-visiting functions.
> Given the simple hierarchy, we don't need virtual functions for this.
>
> Unfortunately doing so runs into various bugs in gengtype's handling
> of GTY((user)), so the patch also includes workarounds for these bugs.
>
> gengtype walks the graph of the *types* in the code, and produces
> functions in gtype-desc.[ch] for all types that are reachable from a
> GTY root.
>
> However, it ignores the contents of GTY((user)) types when walking
> this graph.
>
> Hence if you have a subgraph of types that are only reachable
> via fields in GTY((user)) types, gengtype won't generate helper code
> for those types.
>
> Ideally there would be some way to mark a GTY((user)) type to say
> which types it references, to avoid having to mark these types as
> GTY((user)).
>
> For now, work around this issue by providing explicit roots of the
> missing types, of dummy variables (see the bottom of cgraph.c)
>
> gcc/
>
>         * cgraph.c (gt_ggc_mx): New.
>         (gt_pch_nx (symtab_node_base *)): New.
>         (gt_pch_nx (symtab_node_base *, gt_pointer_operator, void *)): New.
>         (dummy_call_site_hash): New.
>         (dummy_ipa_ref_list): New.
>         (dummy_cgraph_clone_info): New.
>         (dummy_ipa_replace_map_pointer): New.
>         (dummy_varpool_node_ptr): New.
>
>         * cgraph.h (symtab_node_base): Convert to a class;
>         add GTY((user)).
>         (gt_ggc_mx): New.
>         (gt_pch_nx (symtab_node_base *p)): New.
>         (gt_pch_nx (symtab_node_base *p, gt_pointer_operator op,
>         void *cookie)): New.
>         (cgraph_node): Inherit from symtab_node; convert to GTY((user)).
>         (varpool_node): Likewise.
>         (symtab_node_def): Remove.
>         (is_a_helper <cgraph_node>::test (symtab_node_def *)): Convert to...
>         (is_a_helper <cgraph_node>::test (symtab_node_base *)): ...this.
>         (is_a_helper <varpool_node>::test (symtab_node_def *)): Convert to...
>         (is_a_helper <varpool_node>::test (symtab_node_base *)): ...this.
>
>         * ipa-ref.h (symtab_node_def): Drop.
>         (symtab_node): Change underlying type from symtab_node_def to
>         symtab_node_base.
>         (const_symtab_node): Likwise.
>
>         * is-a.h: Update examples in comment.
>
>         * symtab.c (symtab_hash): Change symtab_node_def to symtab_node_base.
>         (assembler_name_hash): Likewise.
> ---
>  gcc/cgraph.c  | 218 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  gcc/cgraph.h  |  48 ++++++-------
>  gcc/ipa-ref.h |   6 +-
>  gcc/is-a.h    |   6 +-
>  gcc/symtab.c  |   4 +-
>  5 files changed, 247 insertions(+), 35 deletions(-)
>
> diff --git a/gcc/cgraph.c b/gcc/cgraph.c
> index 50d13ab..5cb6a31 100644
> --- a/gcc/cgraph.c
> +++ b/gcc/cgraph.c
> @@ -3035,4 +3035,222 @@ cgraph_get_body (struct cgraph_node *node)
>    return true;
>  }
>
> +/* GTY((user)) hooks for symtab_node_base (and its subclasses).
> +   We could use virtual functions for this, but given the presence of the
> +   "type" field and the trivial size of the class hierarchy, switches are
> +   perhaps simpler and faster.  */
> +
> +void gt_ggc_mx (symtab_node_base *x)
> +{
> +  /* Hand-written equivalent of the chain_next/chain_prev machinery, to
> +     avoid deep call-stacks.
> +
> +     Locate the neighbors of x (within the linked-list) that haven't been
> +     marked yet, so that x through xlimit give a range suitable for marking.
> +     Note that x (on entry) itself has already been marked by the
> +     gtype-desc.c code, so we first try its successor.
> +  */
> +  symtab_node_base * xlimit = x ? x->next : NULL;
> +  while (ggc_test_and_set_mark (xlimit))
> +   xlimit = xlimit->next;
> +  if (x != xlimit)
> +    for (;;)
> +      {
> +        symtab_node_base * const xprev = x->previous;
> +        if (xprev == NULL) break;
> +        x = xprev;
> +        (void) ggc_test_and_set_mark (xprev);
> +      }
> +  while (x != xlimit)
> +    {
> +      /* Code common to all symtab nodes. */
> +      gt_ggc_m_9tree_node (x->decl);
> +      gt_ggc_mx_symtab_node_base (x->next);
> +      gt_ggc_mx_symtab_node_base (x->previous);
> +      gt_ggc_mx_symtab_node_base (x->next_sharing_asm_name);
> +      gt_ggc_mx_symtab_node_base (x->previous_sharing_asm_name);
> +      gt_ggc_mx_symtab_node_base (x->same_comdat_group);
> +      gt_ggc_m_20vec_ipa_ref_t_va_gc_ (x->ref_list.references);
> +      gt_ggc_m_9tree_node (x->alias_target);
> +      gt_ggc_m_18lto_file_decl_data (x->lto_file_data);

Don't we have template specializations so we just can do

         gt_ggc_mark (x->decl);
         gt_ggc_mark (x->next);
...
etc?

Also all of the symbol table is reachable from the global symbol_table
dynamic array which is a GC root.  So instead of walking ->next/previous
and edges you should have a custom marker for the symbol_table global
which does more efficient marking with loops.

Richard.

> +      /* Extra code, per subclass. */
> +      switch (x->type)
> +        {
> +        case SYMTAB_FUNCTION:
> +          {
> +            cgraph_node *cgn = static_cast <cgraph_node *> (x);
> +            gt_ggc_m_11cgraph_edge (cgn->callees);
> +            gt_ggc_m_11cgraph_edge (cgn->callers);
> +            gt_ggc_m_11cgraph_edge (cgn->indirect_calls);
> +            gt_ggc_m_11cgraph_node (cgn->origin);
> +            gt_ggc_m_11cgraph_node (cgn->nested);
> +            gt_ggc_m_11cgraph_node (cgn->next_nested);
> +            gt_ggc_m_11cgraph_node (cgn->next_sibling_clone);
> +            gt_ggc_m_11cgraph_node (cgn->prev_sibling_clone);
> +            gt_ggc_m_11cgraph_node (cgn->clones);
> +            gt_ggc_m_11cgraph_node (cgn->clone_of);
> +            gt_ggc_m_P11cgraph_edge4htab (cgn->call_site_hash);
> +            gt_ggc_m_9tree_node (cgn->former_clone_of);
> +            gt_ggc_m_11cgraph_node (cgn->global.inlined_to);
> +            gt_ggc_m_28vec_ipa_replace_map_p_va_gc_ (cgn->clone.tree_map);
> +            gt_ggc_m_15bitmap_head_def (cgn->clone.args_to_skip);
> +            gt_ggc_m_15bitmap_head_def (cgn->clone.combined_args_to_skip);
> +            gt_ggc_m_9tree_node (cgn->thunk.alias);
> +          }
> +          break;
> +        default:
> +          break;
> +        }
> +      x = x->next;
> +    }
> +}
> +
> +void gt_pch_nx (symtab_node_base *x)
> +{
> +  symtab_node_base * xlimit = x ? x->next : NULL;
> +  while (gt_pch_note_object (xlimit, xlimit, gt_pch_p_16symtab_node_base))
> +   xlimit = xlimit->next;
> +  if (x != xlimit)
> +    for (;;)
> +      {
> +        symtab_node_base * const xprev = x->previous;
> +        if (xprev == NULL) break;
> +        x = xprev;
> +        (void) gt_pch_note_object (xprev, xprev,
> +                                   gt_pch_p_16symtab_node_base);
> +      }
> +  while (x != xlimit)
> +    {
> +      /* Code common to all symtab nodes. */
> +      gt_pch_n_9tree_node (x->decl);
> +      gt_pch_nx_symtab_node_base (x->next);
> +      gt_pch_nx_symtab_node_base (x->previous);
> +      gt_pch_nx_symtab_node_base (x->next_sharing_asm_name);
> +      gt_pch_nx_symtab_node_base (x->previous_sharing_asm_name);
> +      gt_pch_nx_symtab_node_base (x->same_comdat_group);
> +      gt_pch_n_20vec_ipa_ref_t_va_gc_ (x->ref_list.references);
> +      gt_pch_n_9tree_node (x->alias_target);
> +      gt_pch_n_18lto_file_decl_data (x->lto_file_data);
> +
> +      /* Extra code, per subclass. */
> +      switch (x->type)
> +        {
> +        case SYMTAB_FUNCTION:
> +          {
> +            cgraph_node *cgn = static_cast <cgraph_node *> (x);
> +            gt_pch_n_11cgraph_edge (cgn->callees);
> +            gt_pch_n_11cgraph_edge (cgn->callers);
> +            gt_pch_n_11cgraph_edge (cgn->indirect_calls);
> +            gt_pch_n_11cgraph_node (cgn->origin);
> +            gt_pch_n_11cgraph_node (cgn->nested);
> +            gt_pch_n_11cgraph_node (cgn->next_nested);
> +            gt_pch_n_11cgraph_node (cgn->next_sibling_clone);
> +            gt_pch_n_11cgraph_node (cgn->prev_sibling_clone);
> +            gt_pch_n_11cgraph_node (cgn->clones);
> +            gt_pch_n_11cgraph_node (cgn->clone_of);
> +            gt_pch_n_P11cgraph_edge4htab (cgn->call_site_hash);
> +            gt_pch_n_9tree_node (cgn->former_clone_of);
> +            gt_pch_n_11cgraph_node (cgn->global.inlined_to);
> +            gt_pch_n_28vec_ipa_replace_map_p_va_gc_ (cgn->clone.tree_map);
> +            gt_pch_n_15bitmap_head_def (cgn->clone.args_to_skip);
> +            gt_pch_n_15bitmap_head_def (cgn->clone.combined_args_to_skip);
> +            gt_pch_n_9tree_node (cgn->thunk.alias);
> +          }
> +          break;
> +        default:
> +          break;
> +        }
> +      x = x->next;
> +    }
> +}
> +
> +void gt_pch_nx (symtab_node_base *p, gt_pointer_operator op, void *cookie)
> +{
> +  /* Code common to all symtab nodes. */
> +  op (&(p->decl), cookie);
> +  op (&(p->next), cookie);
> +  op (&(p->previous), cookie);
> +  op (&(p->next_sharing_asm_name), cookie);
> +  op (&(p->previous_sharing_asm_name), cookie);
> +  op (&(p->same_comdat_group), cookie);
> +  op (&(p->ref_list.references), cookie);
> +  op (&(p->alias_target), cookie);
> +  op (&(p->lto_file_data), cookie);
> +
> +  /* Extra code, per subclass. */
> +  switch (p->type)
> +    {
> +    case SYMTAB_FUNCTION:
> +      {
> +        cgraph_node *cgn = static_cast <cgraph_node *> (p);
> +        op (&(cgn->callees), cookie);
> +        op (&(cgn->callers), cookie);
> +        op (&(cgn->indirect_calls), cookie);
> +        op (&(cgn->origin), cookie);
> +        op (&(cgn->nested), cookie);
> +        op (&(cgn->next_nested), cookie);
> +        op (&(cgn->next_sibling_clone), cookie);
> +        op (&(cgn->prev_sibling_clone), cookie);
> +        op (&(cgn->clones), cookie);
> +        op (&(cgn->clone_of), cookie);
> +        op (&(cgn->call_site_hash), cookie);
> +        op (&(cgn->former_clone_of), cookie);
> +        op (&(cgn->global.inlined_to), cookie);
> +        op (&(cgn->clone.tree_map), cookie);
> +        op (&(cgn->clone.args_to_skip), cookie);
> +        op (&(cgn->clone.combined_args_to_skip), cookie);
> +        op (&(cgn->thunk.alias), cookie);
> +      }
> +      break;
> +    default:
> +      break;
> +    }
> +}
> +
> +/* Workarounds for deficiencies in gengtype's handling of GTY((user)).
> +
> +   gengtype walks the graph of the *types* in the code, and produces
> +   functions in gtype-desc.[ch] for all types that are reachable from a
> +   GTY root.
> +
> +   However, it ignores the contents of GTY((user)) types when walking
> +   this graph.
> +
> +   Hence if you have a subgraph of types that are only reachable
> +   via fields in GTY((user)) types, gengtype won't generate helper code
> +   for those types.
> +
> +   Ideally there would be some way to mark a GTY((user)) type to say
> +   which types it references, to avoid having to mark these types as
> +   GTY((user)).
> +
> +   For now, work around this issue by providing explicit roots of the
> +   missing types, of dummy variables.  */
> +
> +/* Force gengtype into providing GTY hooks for the type of this field:
> +     htab_t GTY((param_is (struct cgraph_edge))) call_site_hash;
> +   within cgraph_node.  */
> +static GTY(()) htab_t GTY((param_is (struct cgraph_edge))) dummy_call_site_hash;
> +
> +/* Similarly for this field of symtab_node_base:
> +     struct ipa_ref_list ref_list;
> + */
> +static GTY((deletable)) struct ipa_ref_list *dummy_ipa_ref_list;
> +
> +/* Similarly for this field of cgraph_node:
> +     struct cgraph_clone_info clone;
> +*/
> +static GTY((deletable)) struct cgraph_clone_info *dummy_cgraph_clone_info;
> +
> +/* Non-existent pointer, to trick gengtype into (correctly) realizing that
> +   ipa_replace_map is indeed used in the code, and thus should have ggc_alloc_*
> +   routines.  */
> +static GTY((deletable)) struct ipa_replace_map *dummy_ipa_replace_map_pointer;
> +
> +/* Non-existent pointer, to trick gengtype into (correctly) realizing that
> +   varpool_node is indeed used in the code, and thus should have ggc_alloc_*
> +   routines.  */
> +static GTY((deletable)) varpool_node *dummy_varpool_node_ptr;
> +
>  #include "gt-cgraph.h"
> diff --git a/gcc/cgraph.h b/gcc/cgraph.h
> index e430533..412b5bb 100644
> --- a/gcc/cgraph.h
> +++ b/gcc/cgraph.h
> @@ -40,8 +40,9 @@ enum symtab_type
>
>  /* Base of all entries in the symbol table.
>     The symtab_node is inherited by cgraph and varpol nodes.  */
> -struct GTY(()) symtab_node_base
> +class GTY((user)) symtab_node_base
>  {
> +public:
>    /* Type of the symbol.  */
>    ENUM_BITFIELD (symtab_type) type : 8;
>
> @@ -143,6 +144,16 @@ struct GTY(()) symtab_node_base
>    PTR GTY ((skip)) aux;
>  };
>
> +/* These user-provided hooks are called by code in gtype-desc.c
> +   autogenerated by gengtype.c.
> +
> +   They are called the first time that the given object is visited
> +   within a GC/PCH traversal.
> +*/
> +extern void gt_ggc_mx (symtab_node_base *p);
> +extern void gt_pch_nx (symtab_node_base *p);
> +extern void gt_pch_nx (symtab_node_base *p, gt_pointer_operator op, void *cookie);
> +
>  enum availability
>  {
>    /* Not yet set by cgraph_function_body_availability.  */
> @@ -252,25 +263,19 @@ struct GTY(()) cgraph_clone_info
>  /* The cgraph data structure.
>     Each function decl has assigned cgraph_node listing callees and callers.  */
>
> -struct GTY(()) cgraph_node {
> -  struct symtab_node_base symbol;
> +struct GTY((user)) cgraph_node : public symtab_node_base {
> +public:
>    struct cgraph_edge *callees;
>    struct cgraph_edge *callers;
>    /* List of edges representing indirect calls with a yet undetermined
>       callee.  */
>    struct cgraph_edge *indirect_calls;
>    /* For nested functions points to function the node is nested in.  */
> -  struct cgraph_node *
> -    GTY ((nested_ptr (union symtab_node_def, "(struct cgraph_node *)(%h)", "(symtab_node)%h")))
> -    origin;
> +  struct cgraph_node *origin;
>    /* Points to first nested function, if any.  */
> -  struct cgraph_node *
> -    GTY ((nested_ptr (union symtab_node_def, "(struct cgraph_node *)(%h)", "(symtab_node)%h")))
> -    nested;
> +  struct cgraph_node *nested;
>    /* Pointer to the next function with same origin, if any.  */
> -  struct cgraph_node *
> -    GTY ((nested_ptr (union symtab_node_def, "(struct cgraph_node *)(%h)", "(symtab_node)%h")))
> -    next_nested;
> +  struct cgraph_node *next_nested;
>    /* Pointer to the next clone.  */
>    struct cgraph_node *next_sibling_clone;
>    struct cgraph_node *prev_sibling_clone;
> @@ -518,9 +523,8 @@ typedef struct cgraph_edge *cgraph_edge_p;
>  /* The varpool data structure.
>     Each static variable decl has assigned varpool_node.  */
>
> -struct GTY(()) varpool_node {
> -  struct symtab_node_base symbol;
> -
> +class GTY((user)) varpool_node : public symtab_node_base {
> +public:
>    /* Set when variable is scheduled to be assembled.  */
>    unsigned output : 1;
>  };
> @@ -536,22 +540,12 @@ struct GTY(()) asm_node {
>    int order;
>  };
>
> -/* Symbol table entry.  */
> -union GTY((desc ("%h.symbol.type"), chain_next ("%h.symbol.next"),
> -          chain_prev ("%h.symbol.previous"))) symtab_node_def {
> -  struct symtab_node_base GTY ((tag ("SYMTAB_SYMBOL"))) symbol;
> -  /* To access the following fields,
> -     use the use dyn_cast or as_a to obtain the concrete type.  */
> -  struct cgraph_node GTY ((tag ("SYMTAB_FUNCTION"))) x_function;
> -  struct varpool_node GTY ((tag ("SYMTAB_VARIABLE"))) x_variable;
> -};
> -
>  /* Report whether or not THIS symtab node is a function, aka cgraph_node.  */
>
>  template <>
>  template <>
>  inline bool
> -is_a_helper <cgraph_node>::test (symtab_node_def *p)
> +is_a_helper <cgraph_node>::test (symtab_node_base *p)
>  {
>    return p->symbol.type == SYMTAB_FUNCTION;
>  }
> @@ -561,7 +555,7 @@ is_a_helper <cgraph_node>::test (symtab_node_def *p)
>  template <>
>  template <>
>  inline bool
> -is_a_helper <varpool_node>::test (symtab_node_def *p)
> +is_a_helper <varpool_node>::test (symtab_node_base *p)
>  {
>    return p->symbol.type == SYMTAB_VARIABLE;
>  }
> diff --git a/gcc/ipa-ref.h b/gcc/ipa-ref.h
> index e0553bb..dc6e238 100644
> --- a/gcc/ipa-ref.h
> +++ b/gcc/ipa-ref.h
> @@ -20,9 +20,9 @@ along with GCC; see the file COPYING3.  If not see
>
>  struct cgraph_node;
>  struct varpool_node;
> -union symtab_node_def;
> -typedef union symtab_node_def *symtab_node;
> -typedef const union symtab_node_def *const_symtab_node;
> +class symtab_node_base;
> +typedef symtab_node_base *symtab_node;
> +typedef const symtab_node_base *const_symtab_node;
>
>
>  /* How the reference is done.  */
> diff --git a/gcc/is-a.h b/gcc/is-a.h
> index b5ee854..ccf12be 100644
> --- a/gcc/is-a.h
> +++ b/gcc/is-a.h
> @@ -31,7 +31,7 @@ bool is_a <TYPE> (pointer)
>
>      Tests whether the pointer actually points to a more derived TYPE.
>
> -    Suppose you have a symtab_node_def *ptr, AKA symtab_node ptr.  You can test
> +    Suppose you have a symtab_node_base *ptr, AKA symtab_node ptr.  You can test
>      whether it points to a 'derived' cgraph_node as follows.
>
>        if (is_a <cgraph_node> (ptr))
> @@ -110,7 +110,7 @@ example,
>    template <>
>    template <>
>    inline bool
> -  is_a_helper <cgraph_node>::test (symtab_node_def *p)
> +  is_a_helper <cgraph_node>::test (symtab_node_base *p)
>    {
>      return p->symbol.type == SYMTAB_FUNCTION;
>    }
> @@ -122,7 +122,7 @@ when needed may result in a crash.  For example,
>    template <>
>    template <>
>    inline bool
> -  is_a_helper <cgraph_node>::cast (symtab_node_def *p)
> +  is_a_helper <cgraph_node>::cast (symtab_node_base *p)
>    {
>      return &p->x_function;
>    }
> diff --git a/gcc/symtab.c b/gcc/symtab.c
> index a86bf6b..ba41f89 100644
> --- a/gcc/symtab.c
> +++ b/gcc/symtab.c
> @@ -48,9 +48,9 @@ const char * const ld_plugin_symbol_resolution_names[]=
>  };
>
>  /* Hash table used to convert declarations into nodes.  */
> -static GTY((param_is (union symtab_node_def))) htab_t symtab_hash;
> +static GTY((param_is (symtab_node_base))) htab_t symtab_hash;
>  /* Hash table used to convert assembler names into nodes.  */
> -static GTY((param_is (union symtab_node_def))) htab_t assembler_name_hash;
> +static GTY((param_is (symtab_node_base))) htab_t assembler_name_hash;
>
>  /* Linked list of symbol table nodes.  */
>  symtab_node symtab_nodes;
> --
> 1.7.11.7
>

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 1/2] Convert symtab, cgraph and varpool nodes into a real class hierarchy
  2013-08-27 11:10   ` Richard Biener
@ 2013-08-27 11:48     ` Jan Hubicka
  2013-08-27 12:17       ` Richard Biener
  2013-08-27 15:25     ` Mike Stump
  1 sibling, 1 reply; 39+ messages in thread
From: Jan Hubicka @ 2013-08-27 11:48 UTC (permalink / raw)
  To: Richard Biener; +Cc: David Malcolm, GCC Patches, Jan Hubicka

> > +  while (x != xlimit)
> > +    {
> > +      /* Code common to all symtab nodes. */
> > +      gt_ggc_m_9tree_node (x->decl);
> > +      gt_ggc_mx_symtab_node_base (x->next);
> > +      gt_ggc_mx_symtab_node_base (x->previous);
> > +      gt_ggc_mx_symtab_node_base (x->next_sharing_asm_name);
> > +      gt_ggc_mx_symtab_node_base (x->previous_sharing_asm_name);
> > +      gt_ggc_mx_symtab_node_base (x->same_comdat_group);
> > +      gt_ggc_m_20vec_ipa_ref_t_va_gc_ (x->ref_list.references);
> > +      gt_ggc_m_9tree_node (x->alias_target);
> > +      gt_ggc_m_18lto_file_decl_data (x->lto_file_data);
> 
> Don't we have template specializations so we just can do
> 
>          gt_ggc_mark (x->decl);
>          gt_ggc_mark (x->next);
Yep, that is what I hope for.
> ...
> etc?
> 
> Also all of the symbol table is reachable from the global symbol_table
> dynamic array which is a GC root.  So instead of walking ->next/previous
> and edges you should have a custom marker for the symbol_table global
> which does more efficient marking with loops.

Indeed, good point!
All of the pointers linking symbol table together (i.e. pointer to other symbol
table entries) can be ignored for PCH mark (since we are explicitely allocated,
and all we need is to mark the trees/lto data and other stuff we point to.

These are annotated primarily to get PCH working, where we obviously need
to keep them.

It would be nice to progress on this patch soon :)

Honza
> 
> Richard.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 1/2] Convert symtab, cgraph and varpool nodes into a real class hierarchy
  2013-08-27 11:48     ` Jan Hubicka
@ 2013-08-27 12:17       ` Richard Biener
  2013-08-27 12:50         ` Jan Hubicka
  0 siblings, 1 reply; 39+ messages in thread
From: Richard Biener @ 2013-08-27 12:17 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: David Malcolm, GCC Patches

On Tue, Aug 27, 2013 at 1:40 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
>> > +  while (x != xlimit)
>> > +    {
>> > +      /* Code common to all symtab nodes. */
>> > +      gt_ggc_m_9tree_node (x->decl);
>> > +      gt_ggc_mx_symtab_node_base (x->next);
>> > +      gt_ggc_mx_symtab_node_base (x->previous);
>> > +      gt_ggc_mx_symtab_node_base (x->next_sharing_asm_name);
>> > +      gt_ggc_mx_symtab_node_base (x->previous_sharing_asm_name);
>> > +      gt_ggc_mx_symtab_node_base (x->same_comdat_group);
>> > +      gt_ggc_m_20vec_ipa_ref_t_va_gc_ (x->ref_list.references);
>> > +      gt_ggc_m_9tree_node (x->alias_target);
>> > +      gt_ggc_m_18lto_file_decl_data (x->lto_file_data);
>>
>> Don't we have template specializations so we just can do
>>
>>          gt_ggc_mark (x->decl);
>>          gt_ggc_mark (x->next);
> Yep, that is what I hope for.
>> ...
>> etc?
>>
>> Also all of the symbol table is reachable from the global symbol_table
>> dynamic array which is a GC root.  So instead of walking ->next/previous
>> and edges you should have a custom marker for the symbol_table global
>> which does more efficient marking with loops.
>
> Indeed, good point!
> All of the pointers linking symbol table together (i.e. pointer to other symbol
> table entries) can be ignored for PCH mark (since we are explicitely allocated,
> and all we need is to mark the trees/lto data and other stuff we point to.
>
> These are annotated primarily to get PCH working, where we obviously need
> to keep them.
>
> It would be nice to progress on this patch soon :)

Oh, and with a custom marker for the symbol_table GC root the actual
symbol / edge objects need not be GC allocated at all!  Just make sure
to properly mark the GC objects they refer to.

Richard.

> Honza
>>
>> Richard.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 1/2] Convert symtab, cgraph and varpool nodes into a real class hierarchy
  2013-08-27 12:17       ` Richard Biener
@ 2013-08-27 12:50         ` Jan Hubicka
  0 siblings, 0 replies; 39+ messages in thread
From: Jan Hubicka @ 2013-08-27 12:50 UTC (permalink / raw)
  To: Richard Biener; +Cc: Jan Hubicka, David Malcolm, GCC Patches

> >>
> >> Also all of the symbol table is reachable from the global symbol_table
> >> dynamic array which is a GC root.  So instead of walking ->next/previous
> >> and edges you should have a custom marker for the symbol_table global
> >> which does more efficient marking with loops.
> >
> > Indeed, good point!
> > All of the pointers linking symbol table together (i.e. pointer to other symbol
> > table entries) can be ignored for PCH mark (since we are explicitely allocated,
> > and all we need is to mark the trees/lto data and other stuff we point to.
> >
> > These are annotated primarily to get PCH working, where we obviously need
> > to keep them.
> >
> > It would be nice to progress on this patch soon :)
> 
> Oh, and with a custom marker for the symbol_table GC root the actual
> symbol / edge objects need not be GC allocated at all!  Just make sure
> to properly mark the GC objects they refer to.

Lets play with this incrementally; first nodes are streamed to PCH, so we need
to get them out of that mess first.  Second even edges reffers to trees that needs
to be walked. There will be some surprises.

My previous comment about not walking all node pointers was wrong; we do maintain
list of removed cgraph nodes linked by ->next and not referred from any global
array (or rather hash).
So I guess in first iteration we can go with marker that marks all non-symtabs
and walks the ->next linked chains.

Thanks,
Honza
> 
> Richard.
> 
> > Honza
> >>
> >> Richard.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 1/2] Convert symtab, cgraph and varpool nodes into a real class hierarchy
  2013-08-27 11:10   ` Richard Biener
  2013-08-27 11:48     ` Jan Hubicka
@ 2013-08-27 15:25     ` Mike Stump
  2013-08-28  9:37       ` Richard Biener
  1 sibling, 1 reply; 39+ messages in thread
From: Mike Stump @ 2013-08-27 15:25 UTC (permalink / raw)
  To: Richard Biener, laurynas.biveinis; +Cc: David Malcolm, GCC Patches, Jan Hubicka

On Aug 27, 2013, at 4:08 AM, Richard Biener <richard.guenther@gmail.com> wrote:
>> and converts:
>>  struct GTY(()) cgraph_node
>> to:
>>  struct GTY((user)) cgraph_node : public symtab_node_base

GTY didn't like single inheritance for me in in wide-int.h.  I extended GTY to support it better.   See the wide-int branch, if you need more beef here.  It isn't flawless, but, it did left me to things to make it work nice enough for my purposes.  In my case, all my data is in the base class, and the base class and the derived have the same address (single inheritance, no virtual bases), and I have no embedded pointers in my data.  I don't use user, seemed less ideal to me.

I also had to put:

  void gt_ggc_mx(max_wide_int*) { }
  void gt_pch_nx(max_wide_int*,void (*)(void*, void*), void*) { }
  void gt_pch_nx(max_wide_int*) { }

in wide-int.cc and:

  extern void gt_ggc_mx(max_wide_int*);
  extern void gt_pch_nx(max_wide_int*,void (*)(void*, void*), void*);
  extern void gt_pch_nx(max_wide_int*);

into wide-int.h to get it to go.  These I think are merely because I'm using a typedef for a template with template args.  In the wide-int branch, it'd be nice if a GTY god can figure out how to improves things so I don't need to do the above, and to review/approve/fix the GTY code to support single inheritance even better.

>> and:
>>  struct GTY(()) varpool_node
>> to:
>>  class GTY((user)) varpool_node : public symtab_node_base
>> 
>> dropping the symtab_node_def union.
>> 
>> Since gengtype is unable to cope with inheritance, we have to mark the
>> types with GTY((user)), and handcode the gty field-visiting functions.
>> Given the simple hierarchy, we don't need virtual functions for this.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 1/2] Convert symtab, cgraph and varpool nodes into a real class hierarchy
  2013-08-27 15:25     ` Mike Stump
@ 2013-08-28  9:37       ` Richard Biener
  2013-08-28 17:06         ` Mike Stump
  0 siblings, 1 reply; 39+ messages in thread
From: Richard Biener @ 2013-08-28  9:37 UTC (permalink / raw)
  To: Mike Stump; +Cc: Laurynas Biveinis, David Malcolm, GCC Patches, Jan Hubicka

On Tue, Aug 27, 2013 at 5:06 PM, Mike Stump <mikestump@comcast.net> wrote:
> On Aug 27, 2013, at 4:08 AM, Richard Biener <richard.guenther@gmail.com> wrote:
>>> and converts:
>>>  struct GTY(()) cgraph_node
>>> to:
>>>  struct GTY((user)) cgraph_node : public symtab_node_base
>
> GTY didn't like single inheritance for me in in wide-int.h.  I extended GTY to support it better.   See the wide-int branch, if you need more beef here.  It isn't flawless, but, it did left me to things to make it work nice enough for my purposes.  In my case, all my data is in the base class, and the base class and the derived have the same address (single inheritance, no virtual bases), and I have no embedded pointers in my data.  I don't use user, seemed less ideal to me.
>
> I also had to put:
>
>   void gt_ggc_mx(max_wide_int*) { }
>   void gt_pch_nx(max_wide_int*,void (*)(void*, void*), void*) { }
>   void gt_pch_nx(max_wide_int*) { }
>
> in wide-int.cc and:
>
>   extern void gt_ggc_mx(max_wide_int*);
>   extern void gt_pch_nx(max_wide_int*,void (*)(void*, void*), void*);
>   extern void gt_pch_nx(max_wide_int*);
>
> into wide-int.h to get it to go.  These I think are merely because I'm using a typedef for a template with template args.  In the wide-int branch, it'd be nice if a GTY god can figure out how to improves things so I don't need to do the above, and to review/approve/fix the GTY code to support single inheritance even better.

Huh?  Why should wide-int need to be marked GTY at all?!

Richard.

>>> and:
>>>  struct GTY(()) varpool_node
>>> to:
>>>  class GTY((user)) varpool_node : public symtab_node_base
>>>
>>> dropping the symtab_node_def union.
>>>
>>> Since gengtype is unable to cope with inheritance, we have to mark the
>>> types with GTY((user)), and handcode the gty field-visiting functions.
>>> Given the simple hierarchy, we don't need virtual functions for this.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 1/2] Convert symtab, cgraph and varpool nodes into a real class hierarchy
  2013-08-28  9:37       ` Richard Biener
@ 2013-08-28 17:06         ` Mike Stump
  2013-08-29 10:16           ` Richard Biener
  0 siblings, 1 reply; 39+ messages in thread
From: Mike Stump @ 2013-08-28 17:06 UTC (permalink / raw)
  To: Richard Biener; +Cc: Laurynas Biveinis, David Malcolm, GCC Patches, Jan Hubicka

On Aug 28, 2013, at 2:34 AM, Richard Biener <richard.guenther@gmail.com> wrote:
> Huh?  Why should wide-int need to be marked GTY at all?!

Can I answer with a question?  Why would nb_iter_bound be GTYed?  Why would dw_val_struct be GTYed?  The first makes little sense to me.  The second, well, it is used to generate debug information…  When the clients no longer want to GTY, we could remove it.  wide_ints seem like they should not make it to the PCH file.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 1/2] Convert symtab, cgraph and varpool nodes into a real class hierarchy
  2013-08-28 17:06         ` Mike Stump
@ 2013-08-29 10:16           ` Richard Biener
  0 siblings, 0 replies; 39+ messages in thread
From: Richard Biener @ 2013-08-29 10:16 UTC (permalink / raw)
  To: Mike Stump; +Cc: Laurynas Biveinis, David Malcolm, GCC Patches, Jan Hubicka

On Wed, Aug 28, 2013 at 7:02 PM, Mike Stump <mikestump@comcast.net> wrote:
> On Aug 28, 2013, at 2:34 AM, Richard Biener <richard.guenther@gmail.com> wrote:
>> Huh?  Why should wide-int need to be marked GTY at all?!
>
> Can I answer with a question?  Why would nb_iter_bound be GTYed?

Because it references a GIMPLE stmt which resides in GC memory.

Why would dw_val_struct be GTYed?

Because it resides in GC memory?

The first makes little sense to me.  The second, well, it is used to
generate debug information…  When the clients no longer want to GTY,
we could remove it.  wide_ints seem like they should not make it to
the PCH file.

I don't think this is PCH related.

Richard.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH v2 2/6] Automated conversion of symtab to class hierarchy
  2013-09-09 19:32   ` [PATCH v2 0/6] Port symtab/cgraph/varpool nodes to use C++ inheritance; rename types David Malcolm
  2013-09-09 19:32     ` [PATCH v2 6/6] Update hand-written GTY routines for type renaming David Malcolm
@ 2013-09-09 19:32     ` David Malcolm
  2013-09-10 13:37       ` Jan Hubicka
  2013-09-09 19:32     ` [PATCH v2 3/6] Split symtab_node declarations onto multiple lines David Malcolm
                       ` (4 subsequent siblings)
  6 siblings, 1 reply; 39+ messages in thread
From: David Malcolm @ 2013-09-09 19:32 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jan Hubicka, David Malcolm

This patch is 439KB in size, so to avoid mailing-list limitations I've uploaded it to:
http://dmalcolm.fedorapeople.org/gcc/large-patches/fd607e77883b8d3f8fb7c8091d0626dbbd31b9a5-0002-Automated-conversion-of-symtab-to-class-hierarchy.patch

ChangeLog entry and diffstat follow:

gcc/

	Patch autogenerated by refactor_symtab.py from
	https://github.com/davidmalcolm/gcc-refactoring-scripts
	revision 761987353e7764909eca0e32c01040ed9574ce80

	* asan.c (asan_finish_file): Update for conversion of symtab types to
	a true class hierarchy.
	* cfgexpand.c (estimated_stack_frame_size): Likewise.
	* cgraph.c (cgraph_get_body): Likewise.
	(cgraph_get_create_real_symbol_node): Likewise.
	(verify_cgraph_node): Likewise.
	(verify_edge_corresponds_to_fndecl): Likewise.
	(verify_edge_count_and_frequency): Likewise.
	(cgraph_will_be_removed_from_program_if_no_direct_calls): Likewise.
	(cgraph_can_remove_if_no_direct_calls_p): Likewise.
	(cgraph_can_remove_if_no_direct_calls_and_refs_p): Likewise.
	(cgraph_node_cannot_return): Likewise.
	(cgraph_set_pure_flag_1): Likewise.
	(cgraph_set_const_flag_1): Likewise.
	(cgraph_set_nothrow_flag_1): Likewise.
	(cgraph_make_node_local_1): Likewise.
	(cgraph_for_node_and_aliases): Likewise.
	(cgraph_for_node_thunks_and_aliases): Likewise.
	(cgraph_node_can_be_local_p): Likewise.
	(cgraph_node_cannot_be_local_p_1): Likewise.
	(cgraph_function_body_availability): Likewise.
	(dump_cgraph_node): Likewise.
	(cgraph_rtl_info): Likewise.
	(cgraph_mark_address_taken_node): Likewise.
	(cgraph_remove_node): Likewise.
	(cgraph_release_function_body): Likewise.
	(cgraph_update_edges_for_call_stmt_node): Likewise.
	(cgraph_redirect_edge_call_stmt_to_callee): Likewise.
	(cgraph_make_edge_direct): Likewise.
	(cgraph_resolve_speculation): Likewise.
	(cgraph_speculative_call_info): Likewise.
	(cgraph_turn_edge_to_speculative): Likewise.
	(cgraph_create_edge_1): Likewise.
	(cgraph_set_call_stmt): Likewise.
	(cgraph_node_for_asm): Likewise.
	(cgraph_add_thunk): Likewise.
	(cgraph_same_body_alias): Likewise.
	(cgraph_create_function_alias): Likewise.
	(cgraph_create_node): Likewise.
	(cgraph_create_empty_node): Likewise.
	(record_function_versions): Likewise.
	(used_from_object_file_p): Likewise.
	* cgraph.h (symtab_can_be_discarded): Likewise.
	(symtab_real_symbol_p): Likewise.
	(cgraph_mark_force_output_node): Likewise.
	(cgraph_edge_recursive_p): Likewise.
	(symtab_alias_target): Likewise.
	(varpool_all_refs_explicit_p): Likewise.
	(varpool_can_remove_if_no_refs): Likewise.
	(cgraph_only_called_directly_or_aliased_p): Likewise.
	(cgraph_next_function_with_gimple_body): Likewise.
	(cgraph_first_function_with_gimple_body): Likewise.
	(cgraph_function_with_gimple_body_p): Likewise.
	(cgraph_next_function): Likewise.
	(cgraph_first_function): Likewise.
	(cgraph_next_defined_function): Likewise.
	(cgraph_first_defined_function): Likewise.
	(varpool_next_defined_variable): Likewise.
	(varpool_first_defined_variable): Likewise.
	(varpool_next_static_initializer): Likewise.
	(varpool_first_static_initializer): Likewise.
	(varpool_next_variable): Likewise.
	(varpool_first_variable): Likewise.
	(cgraph_node_asm_name): Likewise.
	(varpool): Likewise.
	(cgraph_turn_edge_to_speculative): Likewise.
	(is_a_helper <varpool_node>::test): Likewise.
	(is_a_helper <cgraph_node>::test): Likewise.
	(varpool_variable_node): Likewise.
	(cgraph_function_or_thunk_node): Likewise.
	(varpool_alias_target): Likewise.
	(cgraph_alias_target): Likewise.
	* cgraphbuild.c (remove_cgraph_callee_edges): Likewise.
	(cgraph_rebuild_references): Likewise.
	(rebuild_cgraph_edges): Likewise.
	(record_eh_tables): Likewise.
	(build_cgraph_edges): Likewise.
	(mark_store): Likewise.
	(mark_load): Likewise.
	(mark_address): Likewise.
	(record_type_list): Likewise.
	(record_reference): Likewise.
	* cgraphclones.c (cgraph_materialize_all_clones): Likewise.
	(cgraph_materialize_clone): Likewise.
	(cgraph_copy_node_for_versioning): Likewise.
	(update_call_expr): Likewise.
	(cgraph_find_replacement_node): Likewise.
	(cgraph_create_virtual_clone): Likewise.
	(cgraph_clone_node): Likewise.
	* cgraphunit.c (compile): Likewise.
	(output_weakrefs): Likewise.
	(output_in_order): Likewise.
	(expand_function): Likewise.
	(assemble_thunks_and_aliases): Likewise.
	(expand_thunk): Likewise.
	(mark_functions_to_output): Likewise.
	(handle_alias_pairs): Likewise.
	(analyze_functions): Likewise.
	(walk_polymorphic_call_targets): Likewise.
	(varpool_finalize_decl): Likewise.
	(process_function_and_variable_attributes): Likewise.
	(cgraph_process_same_body_aliases): Likewise.
	(analyze_function): Likewise.
	(cgraph_add_new_function): Likewise.
	(cgraph_finalize_function): Likewise.
	(referred_to_p): Likewise.
	(cgraph_reset_node): Likewise.
	(cgraph_process_new_functions): Likewise.
	(enqueue_node): Likewise.
	(decide_is_symbol_needed): Likewise.
	* coverage.c (coverage_compute_profile_id): Likewise.
	* dbxout.c (dbxout_expand_expr): Likewise.
	* dwarf2out.c (premark_types_used_by_global_vars_helper): Likewise.
	(reference_to_unused): Likewise.
	* gimple-fold.c (can_refer_decl_in_current_unit_p): Likewise.
	* gimplify.c (unvisit_body): Likewise.
	(unshare_body): Likewise.
	* ipa-cp.c (ipcp_generate_summary): Likewise.
	(ipcp_decision_stage): Likewise.
	(identify_dead_nodes): Likewise.
	(decide_whether_version_node): Likewise.
	(decide_about_value): Likewise.
	(perhaps_add_new_callers): Likewise.
	(create_specialized_node): Likewise.
	(update_profiling_info): Likewise.
	(ipcp_propagate_stage): Likewise.
	(propagate_constants_topo): Likewise.
	(estimate_local_effects): Likewise.
	(good_cloning_opportunity_p): Likewise.
	(devirtualization_time_bonus): Likewise.
	(propagate_constants_accross_call): Likewise.
	(initialize_node_lattices): Likewise.
	(ipcp_cloning_candidate_p): Likewise.
	(determine_versionability): Likewise.
	(print_all_lattices): Likewise.
	(print_lattice): Likewise.
	(edge_within_scc): Likewise.
	(ipcp_discover_new_direct_edges): Likewise.
	* ipa-devirt.c (ipa_devirt): Likewise.
	(likely_target_p): Likewise.
	(update_type_inheritance_graph): Likewise.
	(dump_possible_polymorphic_call_targets): Likewise.
	(build_type_inheritance_graph): Likewise.
	(maybe_record_node): Likewise.
	* ipa-inline-analysis.c (inline_write_summary): Likewise.
	(inline_generate_summary): Likewise.
	(inline_analyze_function): Likewise.
	(do_estimate_growth): Likewise.
	(simple_edge_hints): Likewise.
	(estimate_node_size_and_time): Likewise.
	(estimate_edge_devirt_benefit): Likewise.
	(compute_inline_parameters): Likewise.
	(estimate_function_body_sizes): Likewise.
	(compute_bb_predicates): Likewise.
	(initialize_inline_failed): Likewise.
	(dump_inline_summary): Likewise.
	(dump_inline_edge_summary): Likewise.
	* ipa-inline-transform.c (inline_transform): Likewise.
	(preserve_function_body_p): Likewise.
	(save_inline_function_body): Likewise.
	(inline_call): Likewise.
	(clone_inlined_nodes): Likewise.
	(can_remove_node_now_p): Likewise.
	(can_remove_node_now_p_1): Likewise.
	* ipa-inline.c (early_inliner): Likewise.
	(early_inline_small_functions): Likewise.
	(inline_always_inline_functions): Likewise.
	(ipa_inline): Likewise.
	(flatten_function): Likewise.
	(inline_small_functions): Likewise.
	(speculation_useful_p): Likewise.
	(recursive_inlining): Likewise.
	(update_caller_keys): Likewise.
	(reset_edge_caches): Likewise.
	(update_edge_key): Likewise.
	(edge_badness): Likewise.
	(relative_time_benefit): Likewise.
	(want_inline_self_recursive_call_p): Likewise.
	(want_inline_small_function_p): Likewise.
	(want_early_inline_function_p): Likewise.
	(num_calls): Likewise.
	(can_early_inline_edge_p): Likewise.
	(can_inline_edge_p): Likewise.
	(report_inline_failed_reason): Likewise.
	* ipa-profile.c (ipa_profile): Likewise.
	(ipa_propagate_frequency): Likewise.
	(ipa_propagate_frequency_1): Likewise.
	(ipa_profile_generate_summary): Likewise.
	* ipa-prop.c (ipcp_transform_function): Likewise.
	(read_replacements_section): Likewise.
	(ipa_prop_read_section): Likewise.
	(ipa_modify_call_arguments): Likewise.
	(ipa_print_node_params): Likewise.
	(propagate_controlled_uses): Likewise.
	(update_indirect_edges_after_inlining): Likewise.
	(remove_described_reference): Likewise.
	(ipa_make_edge_direct_to_target): Likewise.
	(ipa_analyze_node): Likewise.
	(ipa_analyze_params_uses): Likewise.
	(ipa_compute_jump_functions): Likewise.
	(ipa_get_callee_param_type): Likewise.
	(ipa_print_node_jump_functions): Likewise.
	(ipa_initialize_node_params): Likewise.
	(ipa_populate_param_decls): Likewise.
	(ipa_func_spec_opts_forbid_analysis_p): Likewise.
	(write_agg_replacement_chain): Likewise.
	(ipa_write_node_info): Likewise.
	(ipa_edge_duplication_hook): Likewise.
	(try_decrement_rdesc_refcount): Likewise.
	* ipa-pure-const.c (propagate_nothrow): Likewise.
	(propagate_pure_const): Likewise.
	(pure_const_read_summary): Likewise.
	(pure_const_write_summary): Likewise.
	(analyze_function): Likewise.
	* ipa-ref-inline.h (ipa_ref_referred_ref_list): Likewise.
	(ipa_ref_referring_ref_list): Likewise.
	* ipa-ref.c (ipa_clear_stmts_in_references): Likewise.
	(ipa_remove_stmt_references): Likewise.
	(ipa_find_reference): Likewise.
	(ipa_dump_referring): Likewise.
	(ipa_dump_references): Likewise.
	(ipa_record_reference): Likewise.
	* ipa-reference.c (ipa_reference_read_optimization_summary): Likewise.
	(ipa_reference_write_optimization_summary): Likewise.
	(write_node_summary_p): Likewise.
	(propagate): Likewise.
	(read_write_all_from_decl): Likewise.
	(generate_summary): Likewise.
	(analyze_function): Likewise.
	(propagate_bits): Likewise.
	(ipa_reference_get_not_written_global): Likewise.
	(ipa_reference_get_not_read_global): Likewise.
	* ipa-split.c (execute_split_functions): Likewise.
	(split_function): Likewise.
	* ipa-utils.c (ipa_merge_profiles): Likewise.
	(dump_cgraph_node_set): Likewise.
	(ipa_reverse_postorder): Likewise.
	(ipa_get_nodes_in_cycle): Likewise.
	(ipa_free_postorder_info): Likewise.
	(ipa_reduced_postorder): Likewise.
	(searchc): Likewise.
	(recursive_call_p): Likewise.
	* ipa.c (ipa_cdtor_merge): Likewise.
	(record_cdtor_fn): Likewise.
	(function_and_variable_visibility): Likewise.
	(varpool_externally_visible_p): Likewise.
	(cgraph_externally_visible_p): Likewise.
	(comdat_can_be_unshared_p): Likewise.
	(comdat_can_be_unshared_p_1): Likewise.
	(address_taken_from_non_vtable_p): Likewise.
	(ipa_discover_readonly_nonaddressable_vars): Likewise.
	(symtab_remove_unreachable_nodes): Likewise.
	(process_references): Likewise.
	(enqueue_node): Likewise.
	(has_addr_references_p): Likewise.
	(cgraph_non_local_node_p_1): Likewise.
	* is-a.h (is_a_helper <cgraph_node>::test): Likewise.
	* lto-cgraph.c (input_symtab): Likewise.
	(merge_profile_summaries): Likewise.
	(input_cgraph_1): Likewise.
	(input_edge): Likewise.
	(input_varpool_node): Likewise.
	(input_node): Likewise.
	(input_overwrite_node): Likewise.
	(compute_ltrans_boundary): Likewise.
	(output_refs): Likewise.
	(lto_output_varpool_node): Likewise.
	(lto_output_node): Likewise.
	(reachable_from_other_partition_p): Likewise.
	(referenced_from_other_partition_p): Likewise.
	(lto_output_edge): Likewise.
	(output_node_opt_summary): Likewise.
	(add_node_to): Likewise.
	(reachable_from_this_partition_p): Likewise.
	(lto_set_symtab_encoder_in_partition): Likewise.
	(lto_symtab_encoder_in_partition_p): Likewise.
	(lto_set_symtab_encoder_encode_initializer): Likewise.
	(lto_symtab_encoder_encode_initializer_p): Likewise.
	(lto_set_symtab_encoder_encode_body): Likewise.
	(lto_symtab_encoder_encode_body_p): Likewise.
	* lto-section-in.c (lto_free_function_in_decl_state_for_node):
	Likewise.
	* lto-streamer-in.c (lto_read_body): Likewise.
	(fixup_call_stmt_edges): Likewise.
	(fixup_call_stmt_edges_1): Likewise.
	* lto-streamer-out.c (produce_symtab): Likewise.
	(output_symbol_p): Likewise.
	(write_symbol): Likewise.
	(lto_output): Likewise.
	(copy_function): Likewise.
	(output_function): Likewise.
	* passes.c (function_called_by_processed_nodes_p): Likewise.
	(ipa_write_optimization_summaries): Likewise.
	(ipa_write_summaries): Likewise.
	(do_per_function_toporder): Likewise.
	(do_per_function): Likewise.
	(dump_passes): Likewise.
	* symtab.c (symtab_semantically_equivalent_p): Likewise.
	(symtab_nonoverwritable_alias): Likewise.
	(symtab_nonoverwritable_alias_1): Likewise.
	(symtab_for_node_and_aliases): Likewise.
	(symtab_resolve_alias): Likewise.
	(fixup_same_cpp_alias_visibility): Likewise.
	(symtab_alias_ultimate_target): Likewise.
	(symtab_used_from_object_file_p): Likewise.
	(verify_symtab_base): Likewise.
	(dump_symtab_base): Likewise.
	(symtab_node_name): Likewise.
	(symtab_node_asm_name): Likewise.
	(symtab_dissolve_same_comdat_group_list): Likewise.
	(symtab_add_to_same_comdat_group): Likewise.
	(symtab_unregister_node): Likewise.
	(symtab_insert_node_to_hashtable): Likewise.
	(symtab_register_node): Likewise.
	(unlink_from_assembler_name_hash): Likewise.
	(insert_to_assembler_name_hash): Likewise.
	(eq_assembler_name): Likewise.
	(hash_node_by_assembler_name): Likewise.
	(eq_node): Likewise.
	(hash_node): Likewise.
	* toplev.c (wrapup_global_declaration_2): Likewise.
	* trans-mem.c (ipa_tm_execute): Likewise.
	(ipa_tm_transform_clone): Likewise.
	(ipa_tm_transform_transaction): Likewise.
	(ipa_tm_transform_calls_redirect): Likewise.
	(ipa_tm_insert_gettmclone_call): Likewise.
	(ipa_tm_insert_irr_call): Likewise.
	(ipa_tm_create_version): Likewise.
	(ipa_tm_create_version_alias): Likewise.
	(ipa_tm_mark_forced_by_abi_node): Likewise.
	(ipa_tm_mark_force_output_node): Likewise.
	(ipa_tm_diagnose_tm_safe): Likewise.
	(ipa_tm_mayenterirr_function): Likewise.
	(ipa_tm_scan_irr_function): Likewise.
	(ipa_tm_note_irrevocable): Likewise.
	(ipa_tm_scan_calls_clone): Likewise.
	(get_cg_data): Likewise.
	* tree-eh.c (tree_could_trap_p): Likewise.
	* tree-emutls.c (ipa_lower_emutls): Likewise.
	(create_emultls_var): Likewise.
	(lower_emutls_function_body): Likewise.
	(gen_emutls_addr): Likewise.
	(emutls_decl): Likewise.
	(new_emutls_decl): Likewise.
	* tree-inline.c (tree_function_versioning): Likewise.
	(optimize_inline_calls): Likewise.
	(expand_call_inline): Likewise.
	(estimate_num_insns): Likewise.
	(copy_bb): Likewise.
	(delete_unreachable_blocks_update_callgraph): Likewise.
	* tree-nested.c (gimplify_all_functions): Likewise.
	(create_nesting_tree): Likewise.
	(check_for_nested_with_variably_modified): Likewise.
	* tree-pretty-print.c (dump_function_header): Likewise.
	* tree-profile.c (tree_profiling): Likewise.
	* tree-sra.c (ipa_sra_preliminary_function_checks): Likewise.
	(modify_function): Likewise.
	(convert_callers): Likewise.
	(convert_callers_for_node): Likewise.
	* tree-ssa-structalias.c (ipa_pta_execute): Likewise.
	(associate_varinfo_to_alias): Likewise.
	(create_variable_info_for): Likewise.
	(get_constraint_for_ssa_var): Likewise.
	* tree-vectorizer.c (increase_alignment): Likewise.
	* tree.c (find_decls_types_in_var): Likewise.
	(find_decls_types_in_node): Likewise.
	(free_lang_data_in_decl): Likewise.
	* value-prof.c (gimple_ic_transform): Likewise.
	(gimple_ic): Likewise.
	(check_ic_target): Likewise.
	(init_node_map): Likewise.
	* varasm.c (decl_binds_to_current_def_p): Likewise.
	(default_binds_local_p_1): Likewise.
	(dump_tm_clone_pairs): Likewise.
	(assemble_alias): Likewise.
	(find_decl): Likewise.
	(mark_decl_referenced): Likewise.
	* varpool.c (varpool_for_node_and_aliases): Likewise.
	(varpool_extra_name_alias): Likewise.
	(varpool_create_variable_alias): Likewise.
	(add_new_static_var): Likewise.
	(varpool_finalize_named_section_flags): Likewise.
	(varpool_remove_unreferenced_decls): Likewise.
	(enqueue_node): Likewise.
	(varpool_assemble_decl): Likewise.
	(assemble_aliases): Likewise.
	(varpool_analyze_node): Likewise.
	(cgraph_variable_initializer_availability): Likewise.
	(varpool_add_new_variable): Likewise.
	(ctor_for_folding): Likewise.
	(dump_varpool_node): Likewise.
	(varpool_remove_initializer): Likewise.
	(varpool_remove_node): Likewise.
	(varpool_node_for_decl): Likewise.
	(varpool_create_empty_node): Likewise.
	* config/i386/i386.c (ix86_generate_version_dispatcher_body):
	Likewise.
	(ix86_get_function_versions_dispatcher): Likewise.

gcc/ada/

	Patch autogenerated by refactor_symtab.py from
	https://github.com/davidmalcolm/gcc-refactoring-scripts
	revision 761987353e7764909eca0e32c01040ed9574ce80

	* gcc-interface/trans.c (finalize_nrv): Update for conversion of
	symtab types to a true class hierarchy.
	* gcc-interface/utils.c (gnat_write_global_declarations): Likewise.

gcc/c-family/

	Patch autogenerated by refactor_symtab.py from
	https://github.com/davidmalcolm/gcc-refactoring-scripts
	revision 761987353e7764909eca0e32c01040ed9574ce80

	* c-gimplify.c (c_genericize): Update for conversion of symtab types
	to a true class hierarchy.
	* c-pragma.c (maybe_apply_pending_pragma_weaks): Likewise.

gcc/cp/

	Patch autogenerated by refactor_symtab.py from
	https://github.com/davidmalcolm/gcc-refactoring-scripts
	revision 761987353e7764909eca0e32c01040ed9574ce80

	* call.c (mark_versions_used): Update for conversion of symtab types
	to a true class hierarchy.
	* decl2.c (cp_write_global_declarations): Likewise.
	(clear_decl_external): Likewise.
	(build_java_method_aliases): Likewise.
	(collect_candidates_for_java_method_aliases): Likewise.
	(mark_needed): Likewise.
	(var_finalized_p): Likewise.
	(maybe_make_one_only): Likewise.
	(maybe_emit_vtables): Likewise.
	* lambda.c (maybe_add_lambda_conv_op): Likewise.
	* method.c (use_thunk): Likewise.
	* optimize.c (maybe_clone_body): Likewise.
	* tree.c (cp_fix_function_decl_p): Likewise.

gcc/java/

	Patch autogenerated by refactor_symtab.py from
	https://github.com/davidmalcolm/gcc-refactoring-scripts
	revision 761987353e7764909eca0e32c01040ed9574ce80

	* decl.c (java_mark_decl_local): Update for conversion of symtab types
	to a true class hierarchy.

gcc/lto/

	Patch autogenerated by refactor_symtab.py from
	https://github.com/davidmalcolm/gcc-refactoring-scripts
	revision 761987353e7764909eca0e32c01040ed9574ce80

	* lto-partition.c (lto_promote_cross_file_statics): Update for
	conversion of symtab types to a true class hierarchy.
	(rename_statics): Likewise.
	(promote_symbol): Likewise.
	(privatize_symbol_name): Likewise.
	(lto_balanced_map): Likewise.
	(varpool_node_cmp): Likewise.
	(node_cmp): Likewise.
	(lto_1_to_1_map): Likewise.
	(undo_partition): Likewise.
	(add_symbol_to_partition): Likewise.
	(contained_in_symbol): Likewise.
	(add_symbol_to_partition_1): Likewise.
	(add_references_to_partition): Likewise.
	(symbol_partitioned_p): Likewise.
	(get_symbol_class): Likewise.
	(lto_max_map): Likewise.
	* lto-symtab.c (lto_symtab_prevailing_decl): Likewise.
	(lto_symtab_merge_symbols): Likewise.
	(lto_symtab_merge_symbols_1): Likewise.
	(lto_symtab_merge_decls): Likewise.
	(lto_symtab_merge_decls_1): Likewise.
	(lto_symtab_merge_decls_2): Likewise.
	(lto_symtab_resolve_symbols): Likewise.
	(lto_symtab_resolve_can_prevail_p): Likewise.
	(lto_symtab_symbol_p): Likewise.
	(lto_symtab_resolve_replaceable_p): Likewise.
	(lto_symtab_merge): Likewise.
	(lto_varpool_replace_node): Likewise.
	(lto_cgraph_replace_node): Likewise.
	* lto.c (lto_main): Likewise.
	(do_whole_program_analysis): Likewise.
	(materialize_cgraph): Likewise.
	(read_cgraph_and_symbols): Likewise.
	(cmp_partitions_order): Likewise.
	(lto_materialize_function): Likewise.
	(has_analyzed_clone_p): Likewise.
---
 gcc/ada/gcc-interface/trans.c |   2 +-
 gcc/ada/gcc-interface/utils.c |   2 +-
 gcc/asan.c                    |  10 +-
 gcc/c-family/c-gimplify.c     |   2 +-
 gcc/c-family/c-pragma.c       |   2 +-
 gcc/cfgexpand.c               |   2 +-
 gcc/cgraph.c                  | 304 +++++++++++++++---------------
 gcc/cgraph.h                  | 130 ++++++-------
 gcc/cgraphbuild.c             |  46 ++---
 gcc/cgraphclones.c            |  90 ++++-----
 gcc/cgraphunit.c              | 300 +++++++++++++++---------------
 gcc/config/i386/i386.c        |  18 +-
 gcc/coverage.c                |   4 +-
 gcc/cp/call.c                 |   2 +-
 gcc/cp/decl2.c                |  26 +--
 gcc/cp/lambda.c               |   4 +-
 gcc/cp/method.c               |   4 +-
 gcc/cp/optimize.c             |   2 +-
 gcc/cp/tree.c                 |   4 +-
 gcc/dbxout.c                  |   2 +-
 gcc/dwarf2out.c               |   4 +-
 gcc/gimple-fold.c             |   8 +-
 gcc/gimplify.c                |   4 +-
 gcc/ipa-cp.c                  |  72 ++++----
 gcc/ipa-devirt.c              |  44 ++---
 gcc/ipa-inline-analysis.c     |  50 ++---
 gcc/ipa-inline-transform.c    |  52 +++---
 gcc/ipa-inline.c              | 168 ++++++++---------
 gcc/ipa-profile.c             |  36 ++--
 gcc/ipa-prop.c                |  86 ++++-----
 gcc/ipa-pure-const.c          |  56 +++---
 gcc/ipa-ref-inline.h          |   4 +-
 gcc/ipa-ref.c                 |  14 +-
 gcc/ipa-reference.c           |  60 +++---
 gcc/ipa-split.c               |  28 +--
 gcc/ipa-utils.c               |  92 +++++-----
 gcc/ipa.c                     | 418 +++++++++++++++++++++---------------------
 gcc/is-a.h                    |   2 +-
 gcc/java/decl.c               |   2 +-
 gcc/lto-cgraph.c              | 274 +++++++++++++--------------
 gcc/lto-section-in.c          |  10 +-
 gcc/lto-streamer-in.c         |   6 +-
 gcc/lto-streamer-out.c        |  38 ++--
 gcc/lto/lto-partition.c       | 200 ++++++++++----------
 gcc/lto/lto-symtab.c          | 206 ++++++++++-----------
 gcc/lto/lto.c                 |  26 +--
 gcc/passes.c                  |  34 ++--
 gcc/symtab.c                  | 386 +++++++++++++++++++-------------------
 gcc/toplev.c                  |   6 +-
 gcc/trans-mem.c               |  94 +++++-----
 gcc/tree-eh.c                 |   4 +-
 gcc/tree-emutls.c             |  40 ++--
 gcc/tree-inline.c             |  42 ++---
 gcc/tree-nested.c             |  10 +-
 gcc/tree-pretty-print.c       |   2 +-
 gcc/tree-profile.c            |  20 +-
 gcc/tree-sra.c                |  20 +-
 gcc/tree-ssa-structalias.c    |  40 ++--
 gcc/tree-vectorizer.c         |   2 +-
 gcc/tree.c                    |  10 +-
 gcc/value-prof.c              |  20 +-
 gcc/varasm.c                  |  30 +--
 gcc/varpool.c                 | 138 +++++++-------
 63 files changed, 1907 insertions(+), 1907 deletions(-)

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH v2 6/6] Update hand-written GTY routines for type renaming
  2013-09-09 19:32   ` [PATCH v2 0/6] Port symtab/cgraph/varpool nodes to use C++ inheritance; rename types David Malcolm
@ 2013-09-09 19:32     ` David Malcolm
  2013-09-10 13:46       ` Jan Hubicka
  2013-09-09 19:32     ` [PATCH v2 2/6] Automated conversion of symtab to class hierarchy David Malcolm
                       ` (5 subsequent siblings)
  6 siblings, 1 reply; 39+ messages in thread
From: David Malcolm @ 2013-09-09 19:32 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jan Hubicka, David Malcolm

	* cgraph.c (gt_ggc_mx): Update for renaming of symtab_node_base
	to symtab_node
	(gt_pch_nx): Likewise.
---
 gcc/cgraph.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index bb2626d..abbffa1 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -3024,11 +3024,11 @@ void gt_ggc_mx (symtab_node *x)
     {
       /* Code common to all symtab nodes. */
       gt_ggc_m_9tree_node (x->decl);
-      gt_ggc_mx_symtab_node_base (x->next);
-      gt_ggc_mx_symtab_node_base (x->previous);
-      gt_ggc_mx_symtab_node_base (x->next_sharing_asm_name);
-      gt_ggc_mx_symtab_node_base (x->previous_sharing_asm_name);
-      gt_ggc_mx_symtab_node_base (x->same_comdat_group);
+      gt_ggc_mx_symtab_node (x->next);
+      gt_ggc_mx_symtab_node (x->previous);
+      gt_ggc_mx_symtab_node (x->next_sharing_asm_name);
+      gt_ggc_mx_symtab_node (x->previous_sharing_asm_name);
+      gt_ggc_mx_symtab_node (x->same_comdat_group);
       gt_ggc_m_20vec_ipa_ref_t_va_gc_ (x->ref_list.references);
       gt_ggc_m_9tree_node (x->alias_target);
       gt_ggc_m_18lto_file_decl_data (x->lto_file_data);
@@ -3068,7 +3068,7 @@ void gt_ggc_mx (symtab_node *x)
 void gt_pch_nx (symtab_node *x)
 {
   symtab_node * xlimit = x ? x->next : NULL;
-  while (gt_pch_note_object (xlimit, xlimit, gt_pch_p_16symtab_node_base))
+  while (gt_pch_note_object (xlimit, xlimit, gt_pch_p_11symtab_node))
    xlimit = xlimit->next;
   if (x != xlimit)
     for (;;)
@@ -3077,17 +3077,17 @@ void gt_pch_nx (symtab_node *x)
         if (xprev == NULL) break;
         x = xprev;
         (void) gt_pch_note_object (xprev, xprev,
-                                   gt_pch_p_16symtab_node_base);
+                                   gt_pch_p_11symtab_node);
       }
   while (x != xlimit)
     {
       /* Code common to all symtab nodes. */
       gt_pch_n_9tree_node (x->decl);
-      gt_pch_nx_symtab_node_base (x->next);
-      gt_pch_nx_symtab_node_base (x->previous);
-      gt_pch_nx_symtab_node_base (x->next_sharing_asm_name);
-      gt_pch_nx_symtab_node_base (x->previous_sharing_asm_name);
-      gt_pch_nx_symtab_node_base (x->same_comdat_group);
+      gt_pch_nx_symtab_node (x->next);
+      gt_pch_nx_symtab_node (x->previous);
+      gt_pch_nx_symtab_node (x->next_sharing_asm_name);
+      gt_pch_nx_symtab_node (x->previous_sharing_asm_name);
+      gt_pch_nx_symtab_node (x->same_comdat_group);
       gt_pch_n_20vec_ipa_ref_t_va_gc_ (x->ref_list.references);
       gt_pch_n_9tree_node (x->alias_target);
       gt_pch_n_18lto_file_decl_data (x->lto_file_data);
-- 
1.7.11.7

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH v2 0/6] Port symtab/cgraph/varpool nodes to use C++ inheritance; rename types.
  2013-08-20 21:06 ` [PATCH 0/2] Port symtab/cgraph/varpool nodes to use C++ inheritance Jan Hubicka
  2013-08-21 10:03   ` Martin Jambor
  2013-08-26 22:27   ` David Malcolm
@ 2013-09-09 19:32   ` David Malcolm
  2013-09-09 19:32     ` [PATCH v2 6/6] Update hand-written GTY routines for type renaming David Malcolm
                       ` (6 more replies)
  2 siblings, 7 replies; 39+ messages in thread
From: David Malcolm @ 2013-09-09 19:32 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jan Hubicka, David Malcolm

Here's version 2 of this patch series.

This is now 6 patches.

The first two patches correspond to the two patches from the original
patch series (and must both be applied together to make sense).  They
convert cgraph_node and varpool_node to inherit from symtab_node_base,
eliminating union symtab_node_def, and the "symbol" fields at the
top of the two subclasses.

Specifically:

  * Patch 1 of 6 is the hand-written part of the conversion to a C++
    inheritance hierarchy, plus various workarounds for dealing with
    issues in how gengtype handles GTY((user)).  It corresponds to
    "patch 1/2" in the original patch series.  It is largely unchanged
    from the previous submission.

  * Patch 2 of 6 is the automated part of the conversion to C++
    inheritance, corresponding to "patch 2/2" in the original series.
    The main improvement is that the script now removes casts to
    (symtab_node) where these are unnecessary i.e. almost all of them,
    apart from a few that I whitelisted.  See refactor_symtab.py
    within https://github.com/davidmalcolm/gcc-refactoring-scripts for
    details.

The remaining 4 patches rename some types:

"symtab_node_base" becomes "symtab_node" (Honza's preferred name, AIUI).

This would clash with the pre-existing "symtab_node", which was a
typedef for:
  union symtab_node_def *
before patch 1, and for:
  symtab_node_base *
after it.

So we eliminate this typedef, and all uses become simply a
"symtab_node *", which is the bulk of the renaming.  There is also
a "const_symtab_node" typedef, which is eliminated; all uses become
simply a "const symtab_node *".

Details of these patches

  * Patch 3 of 6: this is trivial preparatory work before running an
    automated script - split up declarations of multiple symtab_node,
    so that each gets its own declaration.

  * Patch 4 of 6: this eliminates the symtab_node and const_symtab_node
    typedefs from ipa-ref.h

  * Patch 5 of 6: generated by another automated script, this time
    "rename_symtab.py" (as opposed to "refactor_symtab.py"), with a
    testsuite "test_rename_symtab.py"; again, these can be seen at:
    https://github.com/davidmalcolm/gcc-refactoring-scripts

    This performs the big renaming described above.

    There are some mistakes in the ChangeLog of this patch.  I would
    fix these up manually before committing.

  * Patch 6 of 6: this patch updates the hand-written GTY-handling
    code from patch 1 to take into account the changing names of the
    types.

Again, all 4 patches must be applied together for the code to compile.

I've successfully bootstrapped:
   patches (1+2)
and
   all 6 patches together
on top of r202339 on x86_64-unknown-linux-gnu.

For both builds all tests showed the same test results as an unpatched
bootstrap of r202339.

OK for trunk?

David Malcolm (6):
  Convert symtab, cgraph and varpool nodes into a real class hierarchy
  Automated conversion of symtab to class hierarchy
  Split symtab_node declarations onto multiple lines
  Remove symtab_node and const_symtab_node typedefs.
  Automated renaming of symtab types
  Update hand-written GTY routines for type renaming

 gcc/ada/gcc-interface/trans.c |   2 +-
 gcc/ada/gcc-interface/utils.c |   2 +-
 gcc/asan.c                    |  10 +-
 gcc/c-family/c-gimplify.c     |   2 +-
 gcc/c-family/c-pragma.c       |   4 +-
 gcc/cfgexpand.c               |   2 +-
 gcc/cgraph.c                  | 526 +++++++++++++++++++++++++++++-------------
 gcc/cgraph.h                  | 266 +++++++++++----------
 gcc/cgraphbuild.c             |  56 ++---
 gcc/cgraphclones.c            |  90 ++++----
 gcc/cgraphunit.c              | 327 +++++++++++++-------------
 gcc/config/i386/i386.c        |  18 +-
 gcc/coverage.c                |   4 +-
 gcc/cp/call.c                 |   2 +-
 gcc/cp/decl2.c                |  26 +--
 gcc/cp/lambda.c               |   4 +-
 gcc/cp/method.c               |   4 +-
 gcc/cp/optimize.c             |   2 +-
 gcc/cp/tree.c                 |   4 +-
 gcc/dbxout.c                  |   2 +-
 gcc/dwarf2out.c               |   4 +-
 gcc/gimple-fold.c             |  10 +-
 gcc/gimplify.c                |   4 +-
 gcc/ipa-cp.c                  |  72 +++---
 gcc/ipa-devirt.c              |  44 ++--
 gcc/ipa-inline-analysis.c     |  54 ++---
 gcc/ipa-inline-transform.c    |  52 ++---
 gcc/ipa-inline.c              | 168 +++++++-------
 gcc/ipa-profile.c             |  36 +--
 gcc/ipa-prop.c                |  88 +++----
 gcc/ipa-pure-const.c          |  56 ++---
 gcc/ipa-ref-inline.h          |   4 +-
 gcc/ipa-ref.c                 |  34 +--
 gcc/ipa-ref.h                 |  26 +--
 gcc/ipa-reference.c           |  66 +++---
 gcc/ipa-split.c               |  28 +--
 gcc/ipa-utils.c               |  92 ++++----
 gcc/ipa.c                     | 444 +++++++++++++++++------------------
 gcc/is-a.h                    |   8 +-
 gcc/java/decl.c               |   2 +-
 gcc/lto-cgraph.c              | 320 ++++++++++++-------------
 gcc/lto-section-in.c          |  12 +-
 gcc/lto-streamer-in.c         |   6 +-
 gcc/lto-streamer-out.c        |  46 ++--
 gcc/lto-streamer.h            |  18 +-
 gcc/lto/lto-partition.c       | 242 +++++++++----------
 gcc/lto/lto-symtab.c          | 245 ++++++++++----------
 gcc/lto/lto.c                 |  34 +--
 gcc/passes.c                  |  34 +--
 gcc/symtab.c                  | 518 ++++++++++++++++++++---------------------
 gcc/toplev.c                  |   6 +-
 gcc/trans-mem.c               |  94 ++++----
 gcc/tree-eh.c                 |   4 +-
 gcc/tree-emutls.c             |  40 ++--
 gcc/tree-inline.c             |  42 ++--
 gcc/tree-nested.c             |  10 +-
 gcc/tree-pretty-print.c       |   2 +-
 gcc/tree-profile.c            |  20 +-
 gcc/tree-sra.c                |  20 +-
 gcc/tree-ssa-structalias.c    |  40 ++--
 gcc/tree-vectorizer.c         |   2 +-
 gcc/tree.c                    |  10 +-
 gcc/value-prof.c              |  22 +-
 gcc/varasm.c                  |  32 +--
 gcc/varpool.c                 | 142 ++++++------
 65 files changed, 2411 insertions(+), 2195 deletions(-)

-- 
1.7.11.7

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH v2 3/6] Split symtab_node declarations onto multiple lines
  2013-09-09 19:32   ` [PATCH v2 0/6] Port symtab/cgraph/varpool nodes to use C++ inheritance; rename types David Malcolm
  2013-09-09 19:32     ` [PATCH v2 6/6] Update hand-written GTY routines for type renaming David Malcolm
  2013-09-09 19:32     ` [PATCH v2 2/6] Automated conversion of symtab to class hierarchy David Malcolm
@ 2013-09-09 19:32     ` David Malcolm
  2013-09-10 13:38       ` Jan Hubicka
  2013-09-09 19:33     ` [PATCH v2 1/6] Convert symtab, cgraph and varpool nodes into a real class hierarchy David Malcolm
                       ` (3 subsequent siblings)
  6 siblings, 1 reply; 39+ messages in thread
From: David Malcolm @ 2013-09-09 19:32 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jan Hubicka, David Malcolm

Amongst other things, the rename_symtab.py script converts
"symtab_node" to "symtab_node *".

This will lead to broken code on declarations that declare
more than one variable (only the first would get a "*"), so split
up such declarations.

gcc/
	* cgraphunit.c (analyze_functions): Split symtab_node
	declarations onto multiple lines to make things easier
	for rename_symtab.py.

	* symtab.c (symtab_dissolve_same_comdat_group_list): Likewise.
	(symtab_semantically_equivalent_p): Likewise.

gcc/lto
	* lto-symtab.c (lto_symtab_merge_decls_2): Split symtab_node
	declarations onto multiple lines to make things easier for
	rename_symtab.py.
	(lto_symtab_merge_decls_1): Likewise.
	(lto_symtab_merge_symbols_1): Likewise.
---
 gcc/cgraphunit.c     | 3 ++-
 gcc/lto/lto-symtab.c | 9 ++++++---
 gcc/symtab.c         | 6 ++++--
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 5a8909f..351291b 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -906,7 +906,8 @@ analyze_functions (void)
   struct varpool_node *first_handled_var = first_analyzed_var;
   struct pointer_set_t *reachable_call_targets = pointer_set_create ();
 
-  symtab_node node, next;
+  symtab_node node;
+  symtab_node next;
   int i;
   struct ipa_ref *ref;
   bool changed = true;
diff --git a/gcc/lto/lto-symtab.c b/gcc/lto/lto-symtab.c
index 13646bb..ec42a93 100644
--- a/gcc/lto/lto-symtab.c
+++ b/gcc/lto/lto-symtab.c
@@ -361,7 +361,8 @@ lto_symtab_resolve_symbols (symtab_node first)
 static void
 lto_symtab_merge_decls_2 (symtab_node first, bool diagnosed_p)
 {
-  symtab_node prevailing, e;
+  symtab_node prevailing;
+  symtab_node e;
   vec<tree> mismatches = vNULL;
   unsigned i;
   tree decl;
@@ -413,7 +414,8 @@ lto_symtab_merge_decls_2 (symtab_node first, bool diagnosed_p)
 static void
 lto_symtab_merge_decls_1 (symtab_node first)
 {
-  symtab_node e, prevailing;
+  symtab_node e;
+  symtab_node prevailing;
   bool diagnosed_p = false;
 
   if (cgraph_dump_file)
@@ -536,7 +538,8 @@ lto_symtab_merge_decls (void)
 static void
 lto_symtab_merge_symbols_1 (symtab_node prevailing)
 {
-  symtab_node e, next;
+  symtab_node e;
+  symtab_node next;
 
   /* Replace the cgraph node of each entry with the prevailing one.  */
   for (e = prevailing->next_sharing_asm_name; e;
diff --git a/gcc/symtab.c b/gcc/symtab.c
index 8079854..2b612b3 100644
--- a/gcc/symtab.c
+++ b/gcc/symtab.c
@@ -441,7 +441,8 @@ symtab_add_to_same_comdat_group (symtab_node new_node,
 void
 symtab_dissolve_same_comdat_group_list (symtab_node node)
 {
-  symtab_node n = node, next;
+  symtab_node n = node;
+  symtab_node next;
 
   if (!node->same_comdat_group)
     return;
@@ -1124,7 +1125,8 @@ symtab_semantically_equivalent_p (symtab_node a,
 				  symtab_node b)
 {
   enum availability avail;
-  symtab_node ba, bb;
+  symtab_node ba;
+  symtab_node bb;
 
   /* Equivalent functions are equivalent.  */
   if (a->decl == b->decl)
-- 
1.7.11.7

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH v2 1/6] Convert symtab, cgraph and varpool nodes into a real class hierarchy
  2013-09-09 19:32   ` [PATCH v2 0/6] Port symtab/cgraph/varpool nodes to use C++ inheritance; rename types David Malcolm
                       ` (2 preceding siblings ...)
  2013-09-09 19:32     ` [PATCH v2 3/6] Split symtab_node declarations onto multiple lines David Malcolm
@ 2013-09-09 19:33     ` David Malcolm
  2013-09-10  9:14       ` Richard Biener
  2013-09-10 13:36       ` Jan Hubicka
  2013-09-09 19:43     ` [PATCH v2 4/6] Remove symtab_node and const_symtab_node typedefs David Malcolm
                       ` (2 subsequent siblings)
  6 siblings, 2 replies; 39+ messages in thread
From: David Malcolm @ 2013-09-09 19:33 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jan Hubicka, David Malcolm

This patch is the handwritten part of the conversion of these types
to C++; it requires the followup patch, which is autogenerated.

It converts:
  struct GTY(()) symtab_node_base
to:
  class GTY((user)) symtab_node_base

and converts:
  struct GTY(()) cgraph_node
to:
  struct GTY((user)) cgraph_node : public symtab_node_base

and:
  struct GTY(()) varpool_node
to:
  class GTY((user)) varpool_node : public symtab_node_base

dropping the symtab_node_def union.

Since gengtype is unable to cope with inheritance, we have to mark the
types with GTY((user)), and handcode the gty field-visiting functions.
Given the simple hierarchy, we don't need virtual functions for this.

Unfortunately doing so runs into various bugs in gengtype's handling
of GTY((user)), so the patch also includes workarounds for these bugs.

gengtype walks the graph of the *types* in the code, and produces
functions in gtype-desc.[ch] for all types that are reachable from a
GTY root.

However, it ignores the contents of GTY((user)) types when walking
this graph.

Hence if you have a subgraph of types that are only reachable
via fields in GTY((user)) types, gengtype won't generate helper code
for those types.

Ideally there would be some way to mark a GTY((user)) type to say
which types it references, to avoid having to mark these types as
GTY((user)).

For now, work around this issue by providing explicit roots of the
missing types, of dummy variables (see the bottom of cgraph.c)

gcc/

	* cgraph.c (gt_ggc_mx): New.
	(gt_pch_nx (symtab_node_base *)): New.
	(gt_pch_nx (symtab_node_base *, gt_pointer_operator, void *)): New.
	(dummy_call_site_hash): New.
	(dummy_ipa_ref_list): New.
	(dummy_cgraph_clone_info): New.
	(dummy_ipa_replace_map_pointer): New.
	(dummy_varpool_node_ptr): New.

	* cgraph.h (symtab_node_base): Convert to a class;
	add GTY((user)).
	(gt_ggc_mx): New.
	(gt_pch_nx (symtab_node_base *p)): New.
	(gt_pch_nx (symtab_node_base *p, gt_pointer_operator op,
	void *cookie)): New.
	(cgraph_node): Inherit from symtab_node; convert to GTY((user)).
	(varpool_node): Likewise.
	(symtab_node_def): Remove.
	(is_a_helper <cgraph_node>::test (symtab_node_def *)): Convert to...
	(is_a_helper <cgraph_node>::test (symtab_node_base *)): ...this.
	(is_a_helper <varpool_node>::test (symtab_node_def *)): Convert to...
	(is_a_helper <varpool_node>::test (symtab_node_base *)): ...this.

	* ipa-ref.h (symtab_node_def): Drop.
	(symtab_node): Change underlying type from symtab_node_def to
	symtab_node_base.
	(const_symtab_node): Likwise.

	* is-a.h: Update examples in comment.

	* symtab.c (symtab_hash): Change symtab_node_def to symtab_node_base.
	(assembler_name_hash): Likewise.
---
 gcc/cgraph.c  | 218 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gcc/cgraph.h  |  48 ++++++-------
 gcc/ipa-ref.h |   6 +-
 gcc/is-a.h    |   6 +-
 gcc/symtab.c  |   4 +-
 5 files changed, 247 insertions(+), 35 deletions(-)

diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index f12bf1b..4b12163 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -2994,4 +2994,222 @@ cgraph_get_body (struct cgraph_node *node)
   return true;
 }
 
+/* GTY((user)) hooks for symtab_node_base (and its subclasses).
+   We could use virtual functions for this, but given the presence of the
+   "type" field and the trivial size of the class hierarchy, switches are
+   perhaps simpler and faster.  */
+
+void gt_ggc_mx (symtab_node_base *x)
+{
+  /* Hand-written equivalent of the chain_next/chain_prev machinery, to
+     avoid deep call-stacks.
+
+     Locate the neighbors of x (within the linked-list) that haven't been
+     marked yet, so that x through xlimit give a range suitable for marking.
+     Note that x (on entry) itself has already been marked by the
+     gtype-desc.c code, so we first try its successor.
+  */
+  symtab_node_base * xlimit = x ? x->next : NULL;
+  while (ggc_test_and_set_mark (xlimit))
+   xlimit = xlimit->next;
+  if (x != xlimit)
+    for (;;)
+      {
+        symtab_node_base * const xprev = x->previous;
+        if (xprev == NULL) break;
+        x = xprev;
+        (void) ggc_test_and_set_mark (xprev);
+      }
+  while (x != xlimit)
+    {
+      /* Code common to all symtab nodes. */
+      gt_ggc_m_9tree_node (x->decl);
+      gt_ggc_mx_symtab_node_base (x->next);
+      gt_ggc_mx_symtab_node_base (x->previous);
+      gt_ggc_mx_symtab_node_base (x->next_sharing_asm_name);
+      gt_ggc_mx_symtab_node_base (x->previous_sharing_asm_name);
+      gt_ggc_mx_symtab_node_base (x->same_comdat_group);
+      gt_ggc_m_20vec_ipa_ref_t_va_gc_ (x->ref_list.references);
+      gt_ggc_m_9tree_node (x->alias_target);
+      gt_ggc_m_18lto_file_decl_data (x->lto_file_data);
+
+      /* Extra code, per subclass. */
+      switch (x->type)
+        {
+        case SYMTAB_FUNCTION:
+          {
+            cgraph_node *cgn = static_cast <cgraph_node *> (x);
+            gt_ggc_m_11cgraph_edge (cgn->callees);
+            gt_ggc_m_11cgraph_edge (cgn->callers);
+            gt_ggc_m_11cgraph_edge (cgn->indirect_calls);
+            gt_ggc_m_11cgraph_node (cgn->origin);
+            gt_ggc_m_11cgraph_node (cgn->nested);
+            gt_ggc_m_11cgraph_node (cgn->next_nested);
+            gt_ggc_m_11cgraph_node (cgn->next_sibling_clone);
+            gt_ggc_m_11cgraph_node (cgn->prev_sibling_clone);
+            gt_ggc_m_11cgraph_node (cgn->clones);
+            gt_ggc_m_11cgraph_node (cgn->clone_of);
+            gt_ggc_m_P11cgraph_edge4htab (cgn->call_site_hash);
+            gt_ggc_m_9tree_node (cgn->former_clone_of);
+            gt_ggc_m_11cgraph_node (cgn->global.inlined_to);
+            gt_ggc_m_28vec_ipa_replace_map_p_va_gc_ (cgn->clone.tree_map);
+            gt_ggc_m_15bitmap_head_def (cgn->clone.args_to_skip);
+            gt_ggc_m_15bitmap_head_def (cgn->clone.combined_args_to_skip);
+            gt_ggc_m_9tree_node (cgn->thunk.alias);
+          }
+          break;
+        default:
+          break;
+        }
+      x = x->next;
+    }
+}
+
+void gt_pch_nx (symtab_node_base *x)
+{
+  symtab_node_base * xlimit = x ? x->next : NULL;
+  while (gt_pch_note_object (xlimit, xlimit, gt_pch_p_16symtab_node_base))
+   xlimit = xlimit->next;
+  if (x != xlimit)
+    for (;;)
+      {
+        symtab_node_base * const xprev = x->previous;
+        if (xprev == NULL) break;
+        x = xprev;
+        (void) gt_pch_note_object (xprev, xprev,
+                                   gt_pch_p_16symtab_node_base);
+      }
+  while (x != xlimit)
+    {
+      /* Code common to all symtab nodes. */
+      gt_pch_n_9tree_node (x->decl);
+      gt_pch_nx_symtab_node_base (x->next);
+      gt_pch_nx_symtab_node_base (x->previous);
+      gt_pch_nx_symtab_node_base (x->next_sharing_asm_name);
+      gt_pch_nx_symtab_node_base (x->previous_sharing_asm_name);
+      gt_pch_nx_symtab_node_base (x->same_comdat_group);
+      gt_pch_n_20vec_ipa_ref_t_va_gc_ (x->ref_list.references);
+      gt_pch_n_9tree_node (x->alias_target);
+      gt_pch_n_18lto_file_decl_data (x->lto_file_data);
+
+      /* Extra code, per subclass. */
+      switch (x->type)
+        {
+        case SYMTAB_FUNCTION:
+          {
+            cgraph_node *cgn = static_cast <cgraph_node *> (x);
+            gt_pch_n_11cgraph_edge (cgn->callees);
+            gt_pch_n_11cgraph_edge (cgn->callers);
+            gt_pch_n_11cgraph_edge (cgn->indirect_calls);
+            gt_pch_n_11cgraph_node (cgn->origin);
+            gt_pch_n_11cgraph_node (cgn->nested);
+            gt_pch_n_11cgraph_node (cgn->next_nested);
+            gt_pch_n_11cgraph_node (cgn->next_sibling_clone);
+            gt_pch_n_11cgraph_node (cgn->prev_sibling_clone);
+            gt_pch_n_11cgraph_node (cgn->clones);
+            gt_pch_n_11cgraph_node (cgn->clone_of);
+            gt_pch_n_P11cgraph_edge4htab (cgn->call_site_hash);
+            gt_pch_n_9tree_node (cgn->former_clone_of);
+            gt_pch_n_11cgraph_node (cgn->global.inlined_to);
+            gt_pch_n_28vec_ipa_replace_map_p_va_gc_ (cgn->clone.tree_map);
+            gt_pch_n_15bitmap_head_def (cgn->clone.args_to_skip);
+            gt_pch_n_15bitmap_head_def (cgn->clone.combined_args_to_skip);
+            gt_pch_n_9tree_node (cgn->thunk.alias);
+          }
+          break;
+        default:
+          break;
+        }
+      x = x->next;
+    }
+}
+
+void gt_pch_nx (symtab_node_base *p, gt_pointer_operator op, void *cookie)
+{
+  /* Code common to all symtab nodes. */
+  op (&(p->decl), cookie);
+  op (&(p->next), cookie);
+  op (&(p->previous), cookie);
+  op (&(p->next_sharing_asm_name), cookie);
+  op (&(p->previous_sharing_asm_name), cookie);
+  op (&(p->same_comdat_group), cookie);
+  op (&(p->ref_list.references), cookie);
+  op (&(p->alias_target), cookie);
+  op (&(p->lto_file_data), cookie);
+
+  /* Extra code, per subclass. */
+  switch (p->type)
+    {
+    case SYMTAB_FUNCTION:
+      {
+        cgraph_node *cgn = static_cast <cgraph_node *> (p);
+        op (&(cgn->callees), cookie);
+        op (&(cgn->callers), cookie);
+        op (&(cgn->indirect_calls), cookie);
+        op (&(cgn->origin), cookie);
+        op (&(cgn->nested), cookie);
+        op (&(cgn->next_nested), cookie);
+        op (&(cgn->next_sibling_clone), cookie);
+        op (&(cgn->prev_sibling_clone), cookie);
+        op (&(cgn->clones), cookie);
+        op (&(cgn->clone_of), cookie);
+        op (&(cgn->call_site_hash), cookie);
+        op (&(cgn->former_clone_of), cookie);
+        op (&(cgn->global.inlined_to), cookie);
+        op (&(cgn->clone.tree_map), cookie);
+        op (&(cgn->clone.args_to_skip), cookie);
+        op (&(cgn->clone.combined_args_to_skip), cookie);
+        op (&(cgn->thunk.alias), cookie);
+      }
+      break;
+    default:
+      break;
+    }
+}
+
+/* Workarounds for deficiencies in gengtype's handling of GTY((user)).
+
+   gengtype walks the graph of the *types* in the code, and produces
+   functions in gtype-desc.[ch] for all types that are reachable from a
+   GTY root.
+
+   However, it ignores the contents of GTY((user)) types when walking
+   this graph.
+
+   Hence if you have a subgraph of types that are only reachable
+   via fields in GTY((user)) types, gengtype won't generate helper code
+   for those types.
+
+   Ideally there would be some way to mark a GTY((user)) type to say
+   which types it references, to avoid having to mark these types as
+   GTY((user)).
+
+   For now, work around this issue by providing explicit roots of the
+   missing types, of dummy variables.  */
+
+/* Force gengtype into providing GTY hooks for the type of this field:
+     htab_t GTY((param_is (struct cgraph_edge))) call_site_hash;
+   within cgraph_node.  */
+static GTY(()) htab_t GTY((param_is (struct cgraph_edge))) dummy_call_site_hash;
+
+/* Similarly for this field of symtab_node_base:
+     struct ipa_ref_list ref_list;
+ */
+static GTY((deletable)) struct ipa_ref_list *dummy_ipa_ref_list;
+
+/* Similarly for this field of cgraph_node:
+     struct cgraph_clone_info clone;
+*/
+static GTY((deletable)) struct cgraph_clone_info *dummy_cgraph_clone_info;
+
+/* Non-existent pointer, to trick gengtype into (correctly) realizing that
+   ipa_replace_map is indeed used in the code, and thus should have ggc_alloc_*
+   routines.  */
+static GTY((deletable)) struct ipa_replace_map *dummy_ipa_replace_map_pointer;
+
+/* Non-existent pointer, to trick gengtype into (correctly) realizing that
+   varpool_node is indeed used in the code, and thus should have ggc_alloc_*
+   routines.  */
+static GTY((deletable)) varpool_node *dummy_varpool_node_ptr;
+
 #include "gt-cgraph.h"
diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index 5a7a949..2bd2dc4 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -40,8 +40,9 @@ enum symtab_type
 
 /* Base of all entries in the symbol table.
    The symtab_node is inherited by cgraph and varpol nodes.  */
-struct GTY(()) symtab_node_base
+class GTY((user)) symtab_node_base
 {
+public:
   /* Type of the symbol.  */
   ENUM_BITFIELD (symtab_type) type : 8;
 
@@ -143,6 +144,16 @@ struct GTY(()) symtab_node_base
   PTR GTY ((skip)) aux;
 };
 
+/* These user-provided hooks are called by code in gtype-desc.c
+   autogenerated by gengtype.c.
+
+   They are called the first time that the given object is visited
+   within a GC/PCH traversal.
+*/
+extern void gt_ggc_mx (symtab_node_base *p);
+extern void gt_pch_nx (symtab_node_base *p);
+extern void gt_pch_nx (symtab_node_base *p, gt_pointer_operator op, void *cookie);
+
 enum availability
 {
   /* Not yet set by cgraph_function_body_availability.  */
@@ -252,25 +263,19 @@ struct GTY(()) cgraph_clone_info
 /* The cgraph data structure.
    Each function decl has assigned cgraph_node listing callees and callers.  */
 
-struct GTY(()) cgraph_node {
-  struct symtab_node_base symbol;
+struct GTY((user)) cgraph_node : public symtab_node_base {
+public:
   struct cgraph_edge *callees;
   struct cgraph_edge *callers;
   /* List of edges representing indirect calls with a yet undetermined
      callee.  */
   struct cgraph_edge *indirect_calls;
   /* For nested functions points to function the node is nested in.  */
-  struct cgraph_node *
-    GTY ((nested_ptr (union symtab_node_def, "(struct cgraph_node *)(%h)", "(symtab_node)%h")))
-    origin;
+  struct cgraph_node *origin;
   /* Points to first nested function, if any.  */
-  struct cgraph_node *
-    GTY ((nested_ptr (union symtab_node_def, "(struct cgraph_node *)(%h)", "(symtab_node)%h")))
-    nested;
+  struct cgraph_node *nested;
   /* Pointer to the next function with same origin, if any.  */
-  struct cgraph_node *
-    GTY ((nested_ptr (union symtab_node_def, "(struct cgraph_node *)(%h)", "(symtab_node)%h")))
-    next_nested;
+  struct cgraph_node *next_nested;
   /* Pointer to the next clone.  */
   struct cgraph_node *next_sibling_clone;
   struct cgraph_node *prev_sibling_clone;
@@ -518,9 +523,8 @@ typedef struct cgraph_edge *cgraph_edge_p;
 /* The varpool data structure.
    Each static variable decl has assigned varpool_node.  */
 
-struct GTY(()) varpool_node {
-  struct symtab_node_base symbol;
-
+class GTY((user)) varpool_node : public symtab_node_base {
+public:
   /* Set when variable is scheduled to be assembled.  */
   unsigned output : 1;
 };
@@ -536,22 +540,12 @@ struct GTY(()) asm_node {
   int order;
 };
 
-/* Symbol table entry.  */
-union GTY((desc ("%h.symbol.type"), chain_next ("%h.symbol.next"),
-	   chain_prev ("%h.symbol.previous"))) symtab_node_def {
-  struct symtab_node_base GTY ((tag ("SYMTAB_SYMBOL"))) symbol;
-  /* To access the following fields,
-     use the use dyn_cast or as_a to obtain the concrete type.  */
-  struct cgraph_node GTY ((tag ("SYMTAB_FUNCTION"))) x_function;
-  struct varpool_node GTY ((tag ("SYMTAB_VARIABLE"))) x_variable;
-};
-
 /* Report whether or not THIS symtab node is a function, aka cgraph_node.  */
 
 template <>
 template <>
 inline bool
-is_a_helper <cgraph_node>::test (symtab_node_def *p)
+is_a_helper <cgraph_node>::test (symtab_node_base *p)
 {
   return p->symbol.type == SYMTAB_FUNCTION;
 }
@@ -561,7 +555,7 @@ is_a_helper <cgraph_node>::test (symtab_node_def *p)
 template <>
 template <>
 inline bool
-is_a_helper <varpool_node>::test (symtab_node_def *p)
+is_a_helper <varpool_node>::test (symtab_node_base *p)
 {
   return p->symbol.type == SYMTAB_VARIABLE;
 }
diff --git a/gcc/ipa-ref.h b/gcc/ipa-ref.h
index e0553bb..dc6e238 100644
--- a/gcc/ipa-ref.h
+++ b/gcc/ipa-ref.h
@@ -20,9 +20,9 @@ along with GCC; see the file COPYING3.  If not see
 
 struct cgraph_node;
 struct varpool_node;
-union symtab_node_def;
-typedef union symtab_node_def *symtab_node;
-typedef const union symtab_node_def *const_symtab_node;
+class symtab_node_base;
+typedef symtab_node_base *symtab_node;
+typedef const symtab_node_base *const_symtab_node;
 
 
 /* How the reference is done.  */
diff --git a/gcc/is-a.h b/gcc/is-a.h
index b5ee854..ccf12be 100644
--- a/gcc/is-a.h
+++ b/gcc/is-a.h
@@ -31,7 +31,7 @@ bool is_a <TYPE> (pointer)
 
     Tests whether the pointer actually points to a more derived TYPE.
 
-    Suppose you have a symtab_node_def *ptr, AKA symtab_node ptr.  You can test
+    Suppose you have a symtab_node_base *ptr, AKA symtab_node ptr.  You can test
     whether it points to a 'derived' cgraph_node as follows.
 
       if (is_a <cgraph_node> (ptr))
@@ -110,7 +110,7 @@ example,
   template <>
   template <>
   inline bool
-  is_a_helper <cgraph_node>::test (symtab_node_def *p)
+  is_a_helper <cgraph_node>::test (symtab_node_base *p)
   {
     return p->symbol.type == SYMTAB_FUNCTION;
   }
@@ -122,7 +122,7 @@ when needed may result in a crash.  For example,
   template <>
   template <>
   inline bool
-  is_a_helper <cgraph_node>::cast (symtab_node_def *p)
+  is_a_helper <cgraph_node>::cast (symtab_node_base *p)
   {
     return &p->x_function;
   }
diff --git a/gcc/symtab.c b/gcc/symtab.c
index 8dc61d0..adc7c90 100644
--- a/gcc/symtab.c
+++ b/gcc/symtab.c
@@ -48,9 +48,9 @@ const char * const ld_plugin_symbol_resolution_names[]=
 };
 
 /* Hash table used to convert declarations into nodes.  */
-static GTY((param_is (union symtab_node_def))) htab_t symtab_hash;
+static GTY((param_is (symtab_node_base))) htab_t symtab_hash;
 /* Hash table used to convert assembler names into nodes.  */
-static GTY((param_is (union symtab_node_def))) htab_t assembler_name_hash;
+static GTY((param_is (symtab_node_base))) htab_t assembler_name_hash;
 
 /* Linked list of symbol table nodes.  */
 symtab_node symtab_nodes;
-- 
1.7.11.7

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH v2 4/6] Remove symtab_node and const_symtab_node typedefs.
  2013-09-09 19:32   ` [PATCH v2 0/6] Port symtab/cgraph/varpool nodes to use C++ inheritance; rename types David Malcolm
                       ` (3 preceding siblings ...)
  2013-09-09 19:33     ` [PATCH v2 1/6] Convert symtab, cgraph and varpool nodes into a real class hierarchy David Malcolm
@ 2013-09-09 19:43     ` David Malcolm
  2013-09-10 13:39       ` Jan Hubicka
  2013-09-09 20:49     ` [PATCH v2 5/6] Automated renaming of symtab types David Malcolm
  2013-09-10 13:04     ` [PATCH v2 0/6] Port symtab/cgraph/varpool nodes to use C++ inheritance; rename types Jan Hubicka
  6 siblings, 1 reply; 39+ messages in thread
From: David Malcolm @ 2013-09-09 19:43 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jan Hubicka, David Malcolm

gcc/

	* ipa-ref.h (symtab_node): Remove typedef to pointer type, as it
	clashes with the preferred name for the base class.
	(const_symtab_node): Remove redundant typedef.
---
 gcc/ipa-ref.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/gcc/ipa-ref.h b/gcc/ipa-ref.h
index dc6e238..d5ea7ee 100644
--- a/gcc/ipa-ref.h
+++ b/gcc/ipa-ref.h
@@ -21,8 +21,6 @@ along with GCC; see the file COPYING3.  If not see
 struct cgraph_node;
 struct varpool_node;
 class symtab_node_base;
-typedef symtab_node_base *symtab_node;
-typedef const symtab_node_base *const_symtab_node;
 
 
 /* How the reference is done.  */
-- 
1.7.11.7

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH v2 5/6] Automated renaming of symtab types
  2013-09-09 19:32   ` [PATCH v2 0/6] Port symtab/cgraph/varpool nodes to use C++ inheritance; rename types David Malcolm
                       ` (4 preceding siblings ...)
  2013-09-09 19:43     ` [PATCH v2 4/6] Remove symtab_node and const_symtab_node typedefs David Malcolm
@ 2013-09-09 20:49     ` David Malcolm
  2013-09-10 13:40       ` Jan Hubicka
  2013-09-10 13:04     ` [PATCH v2 0/6] Port symtab/cgraph/varpool nodes to use C++ inheritance; rename types Jan Hubicka
  6 siblings, 1 reply; 39+ messages in thread
From: David Malcolm @ 2013-09-09 20:49 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jan Hubicka, David Malcolm

gcc/

	Patch autogenerated by rename_symtab.py from
	https://github.com/davidmalcolm/gcc-refactoring-scripts
	revision 714e57b66b08fb29f47826fbb642707bdfa19520

	* cgraph.c (cgraph_get_body): Rename symtab_node_base to symtab_node.
	(cgraph_edge_remove_callee): Likewise.
	(cgraph_node_for_asm): Likewise.
	* cgraph.h (gt_ggc_mx): Likewise.
	(gt_pch_nx): Likewise.
	(GTY): Likewise.
	(is_a_helper <cgraph_node>::test): Likewise.
	(way): Likewise.
	(is_a_helper <varpool_node>::test): Likewise.
	(cgraph_turn_edge_to_speculative): Likewise.
	(cgraph): Likewise.
	(varpool_first_variable): Likewise.
	(varpool_next_variable): Likewise.
	(varpool_first_static_initializer): Likewise.
	(varpool_next_static_initializer): Likewise.
	(varpool_first_defined_variable): Likewise.
	(varpool_next_defined_variable): Likewise.
	(cgraph_first_defined_function): Likewise.
	(cgraph_next_defined_function): Likewise.
	(cgraph_first_function): Likewise.
	(cgraph_next_function): Likewise.
	(cgraph_first_function_with_gimple_body): Likewise.
	(cgraph_next_function_with_gimple_body): Likewise.
	(varpool_all_refs_explicit_p): Likewise.
	(cgraph_mark_force_output_node): Likewise.
	(symtab_real_symbol_p): Likewise.
	* cgraphbuild.c (mark_address): Likewise.
	(mark_load): Likewise.
	(mark_store): Likewise.
	* cgraphunit.c (decide_is_symbol_needed): Likewise.
	(cgraph_reset_node): Likewise.
	(cgraph_process_same_body_aliases): Likewise.
	(analyze_functions): Likewise.
	(handle_alias_pairs): Likewise.
	(output_weakrefs): Likewise.
	(compile): Likewise.
	* gimple-fold.c (can_refer_decl_in_current_unit_p): Likewise.
	* ipa-inline-analysis.c (inline_write_summary): Likewise.
	* ipa-prop.c (ipa_find_agg_cst_for_param): Likewise.
	(try_decrement_rdesc_refcount): Likewise.
	(ipa_edge_duplication_hook): Likewise.
	* ipa-ref.c (ipa_record_reference): Likewise.
	(ipa_maybe_record_reference): Likewise.
	(ipa_dump_referring): Likewise.
	(ipa_clone_ref): Likewise.
	(ipa_clone_references): Likewise.
	(ipa_ref_has_aliases_p): Likewise.
	(ipa_find_reference): Likewise.
	(ipa_remove_stmt_references): Likewise.
	* ipa-ref.h (or): Likewise.
	(GTY): Likewise.
	(ipa_record_reference): Likewise.
	(ipa_maybe_record_reference): Likewise.
	(ipa_clone_references): Likewise.
	(ipa_clone_referring): Likewise.
	(ipa_clone_ref): Likewise.
	(ipa_find_reference): Likewise.
	(ipa_remove_stmt_references): Likewise.
	(ipa_clear_stmts_in_references): Likewise.
	* ipa-reference.c (ipa_reference_write_optimization_summary):
	Likewise.
	* ipa.c (update_inlined_to_pointer): Likewise.
	(enqueue_node): Likewise.
	(process_references): Likewise.
	(symtab_remove_unreachable_nodes): Likewise.
	(ipa_discover_readonly_nonaddressable_vars): Likewise.
	(address_taken_from_non_vtable_p): Likewise.
	(comdat_can_be_unshared_p_1): Likewise.
	(comdat_can_be_unshared_p): Likewise.
	(varpool_externally_visible_p): Likewise.
	(function_and_variable_visibility): Likewise.
	* is-a.h (varpool_analyze_node): Likewise.
	(or): Likewise.
	* lto-cgraph.c (input_cgraph_opt_summary): Likewise.
	(lto_symtab_encoder_delete): Likewise.
	(lto_symtab_encoder_encode): Likewise.
	(lto_set_symtab_encoder_encode_initializer): Likewise.
	(lto_symtab_encoder_in_partition_p): Likewise.
	(output_refs): Likewise.
	(compute_ltrans_boundary): Likewise.
	(output_symtab): Likewise.
	(get_alias_symbol): Likewise.
	(input_node): Likewise.
	(input_varpool_node): Likewise.
	(input_ref): Likewise.
	(input_edge): Likewise.
	(input_cgraph_1): Likewise.
	(input_refs): Likewise.
	(input_symtab): Likewise.
	(output_cgraph_opt_summary): Likewise.
	(input_node_opt_summary): Likewise.
	(input_cgraph_opt_section): Likewise.
	* lto-section-in.c (lto_free_function_in_decl_state): Likewise.
	* lto-streamer-out.c (lto_output): Likewise.
	(write_symbol): Likewise.
	(produce_symtab): Likewise.
	* lto-streamer.h (LTO_INIT_INPUT_BLOCK_PTR): Likewise.
	(lto_destroy_simple_input_block): Likewise.
	(lto_symtab_encoder_size): Likewise.
	(lsei_next): Likewise.
	(lsei_varpool_node): Likewise.
	* symtab.c (hash_node): Likewise.
	(eq_node): Likewise.
	(hash_node_by_assembler_name): Likewise.
	(GTY): Likewise.
	(eq_assembler_name): Likewise.
	(insert_to_assembler_name_hash): Likewise.
	(unlink_from_assembler_name_hash): Likewise.
	(symtab_prevail_in_asm_name_hash): Likewise.
	(symtab_register_node): Likewise.
	(symtab_insert_node_to_hashtable): Likewise.
	(symtab_unregister_node): Likewise.
	(symtab_get_node): Likewise.
	(symtab_initialize_asm_name_hash): Likewise.
	(symtab_node_for_asm): Likewise.
	(change_decl_assembler_name): Likewise.
	(symtab_add_to_same_comdat_group): Likewise.
	(symtab_dissolve_same_comdat_group_list): Likewise.
	(symtab_node_asm_name): Likewise.
	(symtab_node_name): Likewise.
	(dump_symtab_base): Likewise.
	(dump_symtab): Likewise.
	(debug_symtab): Likewise.
	(verify_symtab_base): Likewise.
	(verify_symtab): Likewise.
	(resolution_used_from_other_file_p): Likewise.
	(symtab_make_decl_local): Likewise.
	(symtab_node_availability): Likewise.
	(symtab_alias_ultimate_target): Likewise.
	(fixup_same_cpp_alias_visibility): Likewise.
	(symtab_resolve_alias): Likewise.
	(symtab_for_node_and_aliases): Likewise.
	(symtab_nonoverwritable_alias_1): Likewise.
	(symtab_nonoverwritable_alias): Likewise.
	(symtab_semantically_equivalent_p): Likewise.
	* value-prof.c (init_node_map): Likewise.
	* varasm.c (find_decl): Likewise.
	* varpool.c (varpool_node_for_asm): Likewise.
	(varpool_remove_unreferenced_decls): Likewise.

gcc/c-family/

	Patch autogenerated by rename_symtab.py from
	https://github.com/davidmalcolm/gcc-refactoring-scripts
	revision 714e57b66b08fb29f47826fbb642707bdfa19520

	* c-pragma.c (maybe_apply_pending_pragma_weaks): Rename
	symtab_node_base to symtab_node.

gcc/lto/

	Patch autogenerated by rename_symtab.py from
	https://github.com/davidmalcolm/gcc-refactoring-scripts
	revision 714e57b66b08fb29f47826fbb642707bdfa19520

	* lto-partition.c (get_symbol_class): Rename symtab_node_base to
	symtab_node.
	(free_ltrans_partitions): Likewise.
	(symbol_partitioned_p): Likewise.
	(add_references_to_partition): Likewise.
	(add_symbol_to_partition_1): Likewise.
	(contained_in_symbol): Likewise.
	(add_symbol_to_partition): Likewise.
	(undo_partition): Likewise.
	(lto_1_to_1_map): Likewise.
	(lto_max_map): Likewise.
	(lto_balanced_map): Likewise.
	(privatize_symbol_name): Likewise.
	(promote_symbol): Likewise.
	(may_need_named_section_p): Likewise.
	(rename_statics): Likewise.
	(lto_promote_cross_file_statics): Likewise.
	(lto_promote_statics_nonwpa): Likewise.
	* lto-symtab.c (lto_varpool_replace_node): Likewise.
	(lto_symtab_merge): Likewise.
	(lto_symtab_resolve_replaceable_p): Likewise.
	(lto_symtab_symbol_p): Likewise.
	(lto_symtab_resolve_can_prevail_p): Likewise.
	(lto_symtab_resolve_symbols): Likewise.
	(lto_symtab_merge_decls_2): Likewise.
	(lto_symtab_merge_decls_1): Likewise.
	(lto_symtab_merge_decls): Likewise.
	(lto_symtab_merge_symbols_1): Likewise.
	(lto_symtab_merge_symbols): Likewise.
	(lto_symtab_prevailing_decl): Likewise.
	* lto.c (lto_wpa_write_files): Likewise.
	(read_cgraph_and_symbols): Likewise.
	(do_whole_program_analysis): Likewise.
---
 gcc/c-family/c-pragma.c   |   2 +-
 gcc/cgraph.c              |  22 ++++----
 gcc/cgraph.h              | 116 +++++++++++++++++++-------------------
 gcc/cgraphbuild.c         |  10 ++--
 gcc/cgraphunit.c          |  34 +++++------
 gcc/gimple-fold.c         |   2 +-
 gcc/ipa-inline-analysis.c |   4 +-
 gcc/ipa-prop.c            |   6 +-
 gcc/ipa-ref.c             |  20 +++----
 gcc/ipa-ref.h             |  24 ++++----
 gcc/ipa-reference.c       |   6 +-
 gcc/ipa.c                 |  28 +++++-----
 gcc/is-a.h                |   6 +-
 gcc/lto-cgraph.c          |  50 ++++++++---------
 gcc/lto-section-in.c      |   2 +-
 gcc/lto-streamer-out.c    |   8 +--
 gcc/lto-streamer.h        |  18 +++---
 gcc/lto/lto-partition.c   |  42 +++++++-------
 gcc/lto/lto-symtab.c      |  44 +++++++--------
 gcc/lto/lto.c             |   8 +--
 gcc/symtab.c              | 140 +++++++++++++++++++++++-----------------------
 gcc/value-prof.c          |   4 +-
 gcc/varasm.c              |   2 +-
 gcc/varpool.c             |   4 +-
 24 files changed, 301 insertions(+), 301 deletions(-)

diff --git a/gcc/c-family/c-pragma.c b/gcc/c-family/c-pragma.c
index 409fcb1..8adb4ee 100644
--- a/gcc/c-family/c-pragma.c
+++ b/gcc/c-family/c-pragma.c
@@ -307,7 +307,7 @@ maybe_apply_pending_pragma_weaks (void)
   tree alias_id, id, decl;
   int i;
   pending_weak *pe;
-  symtab_node target;
+  symtab_node *target;
 
   if (!pending_weaks)
     return;
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index 84f617f..bb2626d 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -61,7 +61,7 @@ static inline void cgraph_edge_remove_caller (struct cgraph_edge *e);
 static inline void cgraph_edge_remove_callee (struct cgraph_edge *e);
 
 /* Queue of cgraph nodes scheduled to be lowered.  */
-symtab_node x_cgraph_nodes_queue;
+symtab_node *x_cgraph_nodes_queue;
 #define cgraph_nodes_queue ((struct cgraph_node *)x_cgraph_nodes_queue)
 
 /* Number of nodes in existence.  */
@@ -644,7 +644,7 @@ struct cgraph_node *
 cgraph_node_for_asm (tree asmname)
 {
   /* We do not want to look at inline clones.  */
-  for (symtab_node node = symtab_node_for_asm (asmname);
+  for (symtab_node *node = symtab_node_for_asm (asmname);
        node;
        node = node->next_sharing_asm_name)
     {
@@ -2994,12 +2994,12 @@ cgraph_get_body (struct cgraph_node *node)
   return true;
 }
 
-/* GTY((user)) hooks for symtab_node_base (and its subclasses).
+/* GTY((user)) hooks for symtab_node (and its subclasses).
    We could use virtual functions for this, but given the presence of the
    "type" field and the trivial size of the class hierarchy, switches are
    perhaps simpler and faster.  */
 
-void gt_ggc_mx (symtab_node_base *x)
+void gt_ggc_mx (symtab_node *x)
 {
   /* Hand-written equivalent of the chain_next/chain_prev machinery, to
      avoid deep call-stacks.
@@ -3009,13 +3009,13 @@ void gt_ggc_mx (symtab_node_base *x)
      Note that x (on entry) itself has already been marked by the
      gtype-desc.c code, so we first try its successor.
   */
-  symtab_node_base * xlimit = x ? x->next : NULL;
+  symtab_node * xlimit = x ? x->next : NULL;
   while (ggc_test_and_set_mark (xlimit))
    xlimit = xlimit->next;
   if (x != xlimit)
     for (;;)
       {
-        symtab_node_base * const xprev = x->previous;
+        symtab_node * const xprev = x->previous;
         if (xprev == NULL) break;
         x = xprev;
         (void) ggc_test_and_set_mark (xprev);
@@ -3065,15 +3065,15 @@ void gt_ggc_mx (symtab_node_base *x)
     }
 }
 
-void gt_pch_nx (symtab_node_base *x)
+void gt_pch_nx (symtab_node *x)
 {
-  symtab_node_base * xlimit = x ? x->next : NULL;
+  symtab_node * xlimit = x ? x->next : NULL;
   while (gt_pch_note_object (xlimit, xlimit, gt_pch_p_16symtab_node_base))
    xlimit = xlimit->next;
   if (x != xlimit)
     for (;;)
       {
-        symtab_node_base * const xprev = x->previous;
+        symtab_node * const xprev = x->previous;
         if (xprev == NULL) break;
         x = xprev;
         (void) gt_pch_note_object (xprev, xprev,
@@ -3124,7 +3124,7 @@ void gt_pch_nx (symtab_node_base *x)
     }
 }
 
-void gt_pch_nx (symtab_node_base *p, gt_pointer_operator op, void *cookie)
+void gt_pch_nx (symtab_node *p, gt_pointer_operator op, void *cookie)
 {
   /* Code common to all symtab nodes. */
   op (&(p->decl), cookie);
@@ -3192,7 +3192,7 @@ void gt_pch_nx (symtab_node_base *p, gt_pointer_operator op, void *cookie)
    within cgraph_node.  */
 static GTY(()) htab_t GTY((param_is (struct cgraph_edge))) dummy_call_site_hash;
 
-/* Similarly for this field of symtab_node_base:
+/* Similarly for this field of symtab_node:
      struct ipa_ref_list ref_list;
  */
 static GTY((deletable)) struct ipa_ref_list *dummy_ipa_ref_list;
diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index 6e825846..b1f9f84 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -40,7 +40,7 @@ enum symtab_type
 
 /* Base of all entries in the symbol table.
    The symtab_node is inherited by cgraph and varpol nodes.  */
-class GTY((user)) symtab_node_base
+class GTY((user)) symtab_node
 {
 public:
   /* Type of the symbol.  */
@@ -112,8 +112,8 @@ public:
   tree decl;
 
   /* Linked list of symbol table entries starting with symtab_nodes.  */
-  symtab_node next;
-  symtab_node previous;
+  symtab_node *next;
+  symtab_node *previous;
 
   /* Linked list of symbols with the same asm name.  There may be multiple
      entries for single symbol name during LTO, because symbols are renamed
@@ -124,11 +124,11 @@ public:
 
      There are also several long standing bugs where frontends and builtin
      code produce duplicated decls.  */
-  symtab_node next_sharing_asm_name;
-  symtab_node previous_sharing_asm_name;
+  symtab_node *next_sharing_asm_name;
+  symtab_node *previous_sharing_asm_name;
 
   /* Circular list of nodes in the same comdat group if non-NULL.  */
-  symtab_node same_comdat_group;
+  symtab_node *same_comdat_group;
 
   /* Vectors of referring and referenced entities.  */
   struct ipa_ref_list ref_list;
@@ -150,9 +150,9 @@ public:
    They are called the first time that the given object is visited
    within a GC/PCH traversal.
 */
-extern void gt_ggc_mx (symtab_node_base *p);
-extern void gt_pch_nx (symtab_node_base *p);
-extern void gt_pch_nx (symtab_node_base *p, gt_pointer_operator op, void *cookie);
+extern void gt_ggc_mx (symtab_node *p);
+extern void gt_pch_nx (symtab_node *p);
+extern void gt_pch_nx (symtab_node *p, gt_pointer_operator op, void *cookie);
 
 enum availability
 {
@@ -263,7 +263,7 @@ struct GTY(()) cgraph_clone_info
 /* The cgraph data structure.
    Each function decl has assigned cgraph_node listing callees and callers.  */
 
-struct GTY((user)) cgraph_node : public symtab_node_base {
+struct GTY((user)) cgraph_node : public symtab_node {
 public:
   struct cgraph_edge *callees;
   struct cgraph_edge *callers;
@@ -523,7 +523,7 @@ typedef struct cgraph_edge *cgraph_edge_p;
 /* The varpool data structure.
    Each static variable decl has assigned varpool_node.  */
 
-class GTY((user)) varpool_node : public symtab_node_base {
+class GTY((user)) varpool_node : public symtab_node {
 public:
   /* Set when variable is scheduled to be assembled.  */
   unsigned output : 1;
@@ -545,7 +545,7 @@ struct GTY(()) asm_node {
 template <>
 template <>
 inline bool
-is_a_helper <cgraph_node>::test (symtab_node_base *p)
+is_a_helper <cgraph_node>::test (symtab_node *p)
 {
   return p->type == SYMTAB_FUNCTION;
 }
@@ -555,12 +555,12 @@ is_a_helper <cgraph_node>::test (symtab_node_base *p)
 template <>
 template <>
 inline bool
-is_a_helper <varpool_node>::test (symtab_node_base *p)
+is_a_helper <varpool_node>::test (symtab_node *p)
 {
   return p->type == SYMTAB_VARIABLE;
 }
 
-extern GTY(()) symtab_node symtab_nodes;
+extern GTY(()) symtab_node *symtab_nodes;
 extern GTY(()) int cgraph_n_nodes;
 extern GTY(()) int cgraph_max_uid;
 extern GTY(()) int cgraph_edge_max_uid;
@@ -591,37 +591,37 @@ extern GTY(()) int symtab_order;
 extern bool cpp_implicit_aliases_done;
 
 /* In symtab.c  */
-void symtab_register_node (symtab_node);
-void symtab_unregister_node (symtab_node);
-void symtab_remove_node (symtab_node);
-symtab_node symtab_get_node (const_tree);
-symtab_node symtab_node_for_asm (const_tree asmname);
-const char * symtab_node_asm_name (symtab_node);
-const char * symtab_node_name (symtab_node);
-void symtab_insert_node_to_hashtable (symtab_node);
-void symtab_add_to_same_comdat_group (symtab_node, symtab_node);
-void symtab_dissolve_same_comdat_group_list (symtab_node node);
+void symtab_register_node (symtab_node *);
+void symtab_unregister_node (symtab_node *);
+void symtab_remove_node (symtab_node *);
+symtab_node *symtab_get_node (const_tree);
+symtab_node *symtab_node_for_asm (const_tree asmname);
+const char * symtab_node_asm_name (symtab_node *);
+const char * symtab_node_name (symtab_node *);
+void symtab_insert_node_to_hashtable (symtab_node *);
+void symtab_add_to_same_comdat_group (symtab_node *, symtab_node *);
+void symtab_dissolve_same_comdat_group_list (symtab_node *node);
 void dump_symtab (FILE *);
 void debug_symtab (void);
-void dump_symtab_node (FILE *, symtab_node);
-void debug_symtab_node (symtab_node);
-void dump_symtab_base (FILE *, symtab_node);
+void dump_symtab_node (FILE *, symtab_node *);
+void debug_symtab_node (symtab_node *);
+void dump_symtab_base (FILE *, symtab_node *);
 void verify_symtab (void);
-void verify_symtab_node (symtab_node);
-bool verify_symtab_base (symtab_node);
-bool symtab_used_from_object_file_p (symtab_node);
+void verify_symtab_node (symtab_node *);
+bool verify_symtab_base (symtab_node *);
+bool symtab_used_from_object_file_p (symtab_node *);
 void symtab_make_decl_local (tree);
-symtab_node symtab_alias_ultimate_target (symtab_node,
+symtab_node *symtab_alias_ultimate_target (symtab_node *,
 					  enum availability *avail = NULL);
-bool symtab_resolve_alias (symtab_node node, symtab_node target);
-void fixup_same_cpp_alias_visibility (symtab_node node, symtab_node target);
-bool symtab_for_node_and_aliases (symtab_node,
-				  bool (*) (symtab_node, void *),
+bool symtab_resolve_alias (symtab_node *node, symtab_node *target);
+void fixup_same_cpp_alias_visibility (symtab_node *node, symtab_node *target);
+bool symtab_for_node_and_aliases (symtab_node *,
+				  bool (*) (symtab_node *, void *),
 				  void *,
 				  bool);
-symtab_node symtab_nonoverwritable_alias (symtab_node);
-enum availability symtab_node_availability (symtab_node);
-bool symtab_semantically_equivalent_p (symtab_node, symtab_node);
+symtab_node *symtab_nonoverwritable_alias (symtab_node *);
+enum availability symtab_node_availability (symtab_node *);
+bool symtab_semantically_equivalent_p (symtab_node *, symtab_node *);
 
 /* In cgraph.c  */
 void dump_cgraph (FILE *);
@@ -738,7 +738,7 @@ void compile (void);
 void init_cgraph (void);
 bool cgraph_process_new_functions (void);
 void cgraph_process_same_body_aliases (void);
-void fixup_same_cpp_alias_visibility (symtab_node, symtab_node target, tree);
+void fixup_same_cpp_alias_visibility (symtab_node *, symtab_node *target, tree);
 /*  Initialize datastructures so DECL is a function in lowered gimple form.
     IN_SSA is true if the gimple is in SSA.  */
 basic_block init_lowered_empty_function (tree, bool);
@@ -842,13 +842,13 @@ bool varpool_for_node_and_aliases (struct varpool_node *,
 			           void *, bool);
 void varpool_add_new_variable (tree);
 void symtab_initialize_asm_name_hash (void);
-void symtab_prevail_in_asm_name_hash (symtab_node node);
+void symtab_prevail_in_asm_name_hash (symtab_node *node);
 void varpool_remove_initializer (struct varpool_node *);
 
 
 /* Return callgraph node for given symbol and check it is a function. */
 static inline struct cgraph_node *
-cgraph (symtab_node node)
+cgraph (symtab_node *node)
 {
   gcc_checking_assert (!node || node->type == SYMTAB_FUNCTION);
   return (struct cgraph_node *)node;
@@ -856,7 +856,7 @@ cgraph (symtab_node node)
 
 /* Return varpool node for given symbol and check it is a variable.  */
 static inline struct varpool_node *
-varpool (symtab_node node)
+varpool (symtab_node *node)
 {
   gcc_checking_assert (!node || node->type == SYMTAB_VARIABLE);
   return (struct varpool_node *)node;
@@ -915,7 +915,7 @@ varpool_node_name(struct varpool_node *node)
 static inline struct varpool_node *
 varpool_first_variable (void)
 {
-  symtab_node node;
+  symtab_node *node;
   for (node = symtab_nodes; node; node = node->next)
     if (varpool_node *vnode = dyn_cast <varpool_node> (node))
       return vnode;
@@ -926,7 +926,7 @@ varpool_first_variable (void)
 static inline struct varpool_node *
 varpool_next_variable (struct varpool_node *node)
 {
-  symtab_node node1 = node->next;
+  symtab_node *node1 = node->next;
   for (; node1; node1 = node1->next)
     if (varpool_node *vnode1 = dyn_cast <varpool_node> (node1))
       return vnode1;
@@ -942,7 +942,7 @@ varpool_next_variable (struct varpool_node *node)
 static inline struct varpool_node *
 varpool_first_static_initializer (void)
 {
-  symtab_node node;
+  symtab_node *node;
   for (node = symtab_nodes; node; node = node->next)
     {
       varpool_node *vnode = dyn_cast <varpool_node> (node);
@@ -956,7 +956,7 @@ varpool_first_static_initializer (void)
 static inline struct varpool_node *
 varpool_next_static_initializer (struct varpool_node *node)
 {
-  symtab_node node1 = node->next;
+  symtab_node *node1 = node->next;
   for (; node1; node1 = node1->next)
     {
       varpool_node *vnode1 = dyn_cast <varpool_node> (node1);
@@ -975,7 +975,7 @@ varpool_next_static_initializer (struct varpool_node *node)
 static inline struct varpool_node *
 varpool_first_defined_variable (void)
 {
-  symtab_node node;
+  symtab_node *node;
   for (node = symtab_nodes; node; node = node->next)
     {
       varpool_node *vnode = dyn_cast <varpool_node> (node);
@@ -989,7 +989,7 @@ varpool_first_defined_variable (void)
 static inline struct varpool_node *
 varpool_next_defined_variable (struct varpool_node *node)
 {
-  symtab_node node1 = node->next;
+  symtab_node *node1 = node->next;
   for (; node1; node1 = node1->next)
     {
       varpool_node *vnode1 = dyn_cast <varpool_node> (node1);
@@ -1007,7 +1007,7 @@ varpool_next_defined_variable (struct varpool_node *node)
 static inline struct cgraph_node *
 cgraph_first_defined_function (void)
 {
-  symtab_node node;
+  symtab_node *node;
   for (node = symtab_nodes; node; node = node->next)
     {
       cgraph_node *cn = dyn_cast <cgraph_node> (node);
@@ -1021,7 +1021,7 @@ cgraph_first_defined_function (void)
 static inline struct cgraph_node *
 cgraph_next_defined_function (struct cgraph_node *node)
 {
-  symtab_node node1 = node->next;
+  symtab_node *node1 = node->next;
   for (; node1; node1 = node1->next)
     {
       cgraph_node *cn1 = dyn_cast <cgraph_node> (node1);
@@ -1040,7 +1040,7 @@ cgraph_next_defined_function (struct cgraph_node *node)
 static inline struct cgraph_node *
 cgraph_first_function (void)
 {
-  symtab_node node;
+  symtab_node *node;
   for (node = symtab_nodes; node; node = node->next)
     if (cgraph_node *cn = dyn_cast <cgraph_node> (node))
       return cn;
@@ -1051,7 +1051,7 @@ cgraph_first_function (void)
 static inline struct cgraph_node *
 cgraph_next_function (struct cgraph_node *node)
 {
-  symtab_node node1 = node->next;
+  symtab_node *node1 = node->next;
   for (; node1; node1 = node1->next)
     if (cgraph_node *cn1 = dyn_cast <cgraph_node> (node1))
       return cn1;
@@ -1078,7 +1078,7 @@ cgraph_function_with_gimple_body_p (struct cgraph_node *node)
 static inline struct cgraph_node *
 cgraph_first_function_with_gimple_body (void)
 {
-  symtab_node node;
+  symtab_node *node;
   for (node = symtab_nodes; node; node = node->next)
     {
       cgraph_node *cn = dyn_cast <cgraph_node> (node);
@@ -1092,7 +1092,7 @@ cgraph_first_function_with_gimple_body (void)
 static inline struct cgraph_node *
 cgraph_next_function_with_gimple_body (struct cgraph_node *node)
 {
-  symtab_node node1 = node->next;
+  symtab_node *node1 = node->next;
   for (; node1; node1 = node1->next)
     {
       cgraph_node *cn1 = dyn_cast <cgraph_node> (node1);
@@ -1291,8 +1291,8 @@ htab_t constant_pool_htab (void);
 
 /* Return node that alias N is aliasing.  */
 
-static inline symtab_node
-symtab_alias_target (symtab_node n)
+static inline symtab_node *
+symtab_alias_target (symtab_node *n)
 {
   struct ipa_ref *ref;
   ipa_ref_list_reference_iterate (&n->ref_list, 0, ref);
@@ -1380,7 +1380,7 @@ cgraph_mark_force_output_node (struct cgraph_node *node)
    or abstract function kept for debug info purposes only.  */
 
 static inline bool
-symtab_real_symbol_p (symtab_node node)
+symtab_real_symbol_p (symtab_node *node)
 {
   struct cgraph_node *cnode;
 
@@ -1397,7 +1397,7 @@ symtab_real_symbol_p (symtab_node node)
 /* Return true if NODE can be discarded by linker from the binary.  */
 
 static inline bool
-symtab_can_be_discarded (symtab_node node)
+symtab_can_be_discarded (symtab_node *node)
 {
   return (DECL_EXTERNAL (node->decl)
 	  || (DECL_ONE_ONLY (node->decl)
diff --git a/gcc/cgraphbuild.c b/gcc/cgraphbuild.c
index 34ce79a..c47edbd 100644
--- a/gcc/cgraphbuild.c
+++ b/gcc/cgraphbuild.c
@@ -225,7 +225,7 @@ mark_address (gimple stmt, tree addr, void *data)
     {
       struct cgraph_node *node = cgraph_get_create_real_symbol_node (addr);
       cgraph_mark_address_taken_node (node);
-      ipa_record_reference ((symtab_node)data,
+      ipa_record_reference ((symtab_node *)data,
 			    node,
 			    IPA_REF_ADDR, stmt);
     }
@@ -234,7 +234,7 @@ mark_address (gimple stmt, tree addr, void *data)
     {
       struct varpool_node *vnode = varpool_node_for_decl (addr);
 
-      ipa_record_reference ((symtab_node)data,
+      ipa_record_reference ((symtab_node *)data,
 			    vnode,
 			    IPA_REF_ADDR, stmt);
     }
@@ -254,7 +254,7 @@ mark_load (gimple stmt, tree t, void *data)
 	 directly manipulated in the code.  Pretend that it's an address.  */
       struct cgraph_node *node = cgraph_get_create_real_symbol_node (t);
       cgraph_mark_address_taken_node (node);
-      ipa_record_reference ((symtab_node)data,
+      ipa_record_reference ((symtab_node *)data,
 			    node,
 			    IPA_REF_ADDR, stmt);
     }
@@ -263,7 +263,7 @@ mark_load (gimple stmt, tree t, void *data)
     {
       struct varpool_node *vnode = varpool_node_for_decl (t);
 
-      ipa_record_reference ((symtab_node)data,
+      ipa_record_reference ((symtab_node *)data,
 			    vnode,
 			    IPA_REF_LOAD, stmt);
     }
@@ -281,7 +281,7 @@ mark_store (gimple stmt, tree t, void *data)
     {
       struct varpool_node *vnode = varpool_node_for_decl (t);
 
-      ipa_record_reference ((symtab_node)data,
+      ipa_record_reference ((symtab_node *)data,
 			    vnode,
 			    IPA_REF_STORE, stmt);
      }
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 351291b..ceab448 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -223,7 +223,7 @@ static GTY (()) tree vtable_entry_type;
    either outside this translation unit, something magic in the system
    configury */
 bool
-decide_is_symbol_needed (symtab_node node)
+decide_is_symbol_needed (symtab_node *node)
 {
   tree decl = node->decl;
 
@@ -261,13 +261,13 @@ decide_is_symbol_needed (symtab_node node)
 
 /* Head of the queue of nodes to be processed while building callgraph */
 
-static symtab_node first = (symtab_node)(void *)1;
+static symtab_node *first = (symtab_node *)(void *)1;
 
 /* Add NODE to queue starting at FIRST. 
    The queue is linked via AUX pointers and terminated by pointer to 1.  */
 
 static void
-enqueue_node (symtab_node node)
+enqueue_node (symtab_node *node)
 {
   if (node->aux)
     return;
@@ -385,7 +385,7 @@ cgraph_reset_node (struct cgraph_node *node)
 /* Return true when there are references to NODE.  */
 
 static bool
-referred_to_p (symtab_node node)
+referred_to_p (symtab_node *node)
 {
   struct ipa_ref *ref;
 
@@ -663,14 +663,14 @@ analyze_function (struct cgraph_node *node)
 void
 cgraph_process_same_body_aliases (void)
 {
-  symtab_node node;
+  symtab_node *node;
   FOR_EACH_SYMBOL (node)
     if (node->cpp_implicit_alias && !node->analyzed)
       symtab_resolve_alias
         (node,
 	 TREE_CODE (node->alias_target) == VAR_DECL
-	 ? (symtab_node)varpool_node_for_decl (node->alias_target)
-	 : (symtab_node)cgraph_get_create_node (node->alias_target));
+	 ? (symtab_node *)varpool_node_for_decl (node->alias_target)
+	 : (symtab_node *)cgraph_get_create_node (node->alias_target));
   cpp_implicit_aliases_done = true;
 }
 
@@ -906,8 +906,8 @@ analyze_functions (void)
   struct varpool_node *first_handled_var = first_analyzed_var;
   struct pointer_set_t *reachable_call_targets = pointer_set_create ();
 
-  symtab_node node;
-  symtab_node next;
+  symtab_node *node;
+  symtab_node *next;
   int i;
   struct ipa_ref *ref;
   bool changed = true;
@@ -961,11 +961,11 @@ analyze_functions (void)
 
       /* Lower representation, build callgraph edges and references for all trivially
          needed symbols and all symbols referred by them.  */
-      while (first != (symtab_node)(void *)1)
+      while (first != (symtab_node *)(void *)1)
 	{
 	  changed = true;
 	  node = first;
-	  first = (symtab_node)first->aux;
+	  first = (symtab_node *)first->aux;
 	  cgraph_node *cnode = dyn_cast <cgraph_node> (node);
 	  if (cnode && cnode->definition)
 	    {
@@ -1024,7 +1024,7 @@ analyze_functions (void)
 
 	  if (node->same_comdat_group)
 	    {
-	      symtab_node next;
+	      symtab_node *next;
 	      for (next = node->same_comdat_group;
 		   next != node;
 		   next = next->same_comdat_group)
@@ -1108,7 +1108,7 @@ handle_alias_pairs (void)
   
   for (i = 0; alias_pairs && alias_pairs->iterate (i, &p);)
     {
-      symtab_node target_node = symtab_node_for_asm (p->target);
+      symtab_node *target_node = symtab_node_for_asm (p->target);
 
       /* Weakrefs with target not defined in current unit are easy to handle:
 	 they behave just as external variables except we need to note the
@@ -1116,7 +1116,7 @@ handle_alias_pairs (void)
       if (!target_node
 	  && lookup_attribute ("weakref", DECL_ATTRIBUTES (p->decl)) != NULL)
 	{
-	  symtab_node node = symtab_get_node (p->decl);
+	  symtab_node *node = symtab_get_node (p->decl);
 	  if (node)
 	    {
 	      node->alias_target = p->target;
@@ -1129,7 +1129,7 @@ handle_alias_pairs (void)
       else if (!target_node)
 	{
 	  error ("%q+D aliased to undefined symbol %qE", p->decl, p->target);
-	  symtab_node node = symtab_get_node (p->decl);
+	  symtab_node *node = symtab_get_node (p->decl);
 	  if (node)
 	    node->alias = false;
 	  alias_pairs->unordered_remove (i);
@@ -2006,7 +2006,7 @@ get_alias_symbol (tree decl)
 static void
 output_weakrefs (void)
 {
-  symtab_node node;
+  symtab_node *node;
   FOR_EACH_SYMBOL (node)
     if (node->alias
         && !TREE_ASM_WRITTEN (node->decl)
@@ -2128,7 +2128,7 @@ compile (void)
      level by physically rewritting the IL.  At the moment we can only redirect
      calls, so we need infrastructure for renaming references as well.  */
 #ifndef ASM_OUTPUT_WEAKREF
-  symtab_node node;
+  symtab_node *node;
 
   FOR_EACH_SYMBOL (node)
     if (node->alias
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index e946333..9486fcd 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -58,7 +58,7 @@ can_refer_decl_in_current_unit_p (tree decl, tree from_decl)
 {
   struct varpool_node *vnode;
   struct cgraph_node *node;
-  symtab_node snode;
+  symtab_node *snode;
 
   /* We will later output the initializer, so we can refer to it.
      So we are concerned only when DECL comes from initializer of
diff --git a/gcc/ipa-inline-analysis.c b/gcc/ipa-inline-analysis.c
index 702daaf..c6511d6 100644
--- a/gcc/ipa-inline-analysis.c
+++ b/gcc/ipa-inline-analysis.c
@@ -3942,7 +3942,7 @@ inline_write_summary (void)
 
   for (i = 0; i < lto_symtab_encoder_size (encoder); i++)
     {
-      symtab_node snode = lto_symtab_encoder_deref (encoder, i);
+      symtab_node *snode = lto_symtab_encoder_deref (encoder, i);
       cgraph_node *cnode = dyn_cast <cgraph_node> (snode);
       if (cnode && cnode->definition && !cnode->alias)
 	count++;
@@ -3951,7 +3951,7 @@ inline_write_summary (void)
 
   for (i = 0; i < lto_symtab_encoder_size (encoder); i++)
     {
-      symtab_node snode = lto_symtab_encoder_deref (encoder, i);
+      symtab_node *snode = lto_symtab_encoder_deref (encoder, i);
       cgraph_node *cnode = dyn_cast <cgraph_node> (snode);
       if (cnode && (node = cnode)->definition && !node->alias)
 	{
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index e95f393..9bc2ef8 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -2500,7 +2500,7 @@ ipa_find_agg_cst_for_param (struct ipa_agg_jump_function *agg,
    successfully found and removed.  */
 
 static bool
-remove_described_reference (symtab_node symbol, struct ipa_cst_ref_desc *rdesc)
+remove_described_reference (symtab_node *symbol, struct ipa_cst_ref_desc *rdesc)
 {
   struct ipa_ref *to_del;
   struct cgraph_edge *origin;
@@ -2563,7 +2563,7 @@ try_decrement_rdesc_refcount (struct ipa_jump_func *jfunc)
       && (rdesc = jfunc_rdesc_usable (jfunc))
       && --rdesc->refcount == 0)
     {
-      symtab_node symbol = cgraph_node_for_jfunc (jfunc);
+      symtab_node *symbol = cgraph_node_for_jfunc (jfunc);
       if (!symbol)
 	return false;
 
@@ -3071,7 +3071,7 @@ ipa_edge_duplication_hook (struct cgraph_edge *src, struct cgraph_edge *dst,
 	  else if (src->caller == dst->caller)
 	    {
 	      struct ipa_ref *ref;
-	      symtab_node n = cgraph_node_for_jfunc (src_jf);
+	      symtab_node *n = cgraph_node_for_jfunc (src_jf);
 	      gcc_checking_assert (n);
 	      ref = ipa_find_reference (src->caller, n,
 					src->call_stmt, src->lto_stmt_uid);
diff --git a/gcc/ipa-ref.c b/gcc/ipa-ref.c
index 4f04614e..04ce909 100644
--- a/gcc/ipa-ref.c
+++ b/gcc/ipa-ref.c
@@ -34,8 +34,8 @@ static const char *ipa_ref_use_name[] = {"read","write","addr","alias"};
    of the use and STMT the statement (if it exists).  */
 
 struct ipa_ref *
-ipa_record_reference (symtab_node referring_node,
-		      symtab_node referred_node,
+ipa_record_reference (symtab_node *referring_node,
+		      symtab_node *referred_node,
 		      enum ipa_ref_use use_type, gimple stmt)
 {
   struct ipa_ref *ref, *ref2;
@@ -76,7 +76,7 @@ ipa_record_reference (symtab_node referring_node,
    reference or NULL if none was created.  */
 
 struct ipa_ref *
-ipa_maybe_record_reference (symtab_node referring_node, tree val,
+ipa_maybe_record_reference (symtab_node *referring_node, tree val,
 			    enum ipa_ref_use use_type, gimple stmt)
 {
   STRIP_NOPS (val);
@@ -86,7 +86,7 @@ ipa_maybe_record_reference (symtab_node referring_node, tree val,
   if (val && (TREE_CODE (val) == FUNCTION_DECL
 	       || TREE_CODE (val) == VAR_DECL))
     {
-      symtab_node referred = symtab_get_node (val);
+      symtab_node *referred = symtab_get_node (val);
       gcc_checking_assert (referred);
       return ipa_record_reference (referring_node, referred,
 				   use_type, stmt);
@@ -186,7 +186,7 @@ ipa_dump_referring (FILE * file, struct ipa_ref_list *list)
 
 struct ipa_ref *
 ipa_clone_ref (struct ipa_ref *ref,
-	       symtab_node dest_node,
+	       symtab_node *dest_node,
 	       gimple stmt)
 {
   bool speculative = ref->speculative;
@@ -204,7 +204,7 @@ ipa_clone_ref (struct ipa_ref *ref,
 /* Clone all references from SRC to DEST_NODE or DEST_VARPOOL_NODE.  */
 
 void
-ipa_clone_references (symtab_node dest_node,
+ipa_clone_references (symtab_node *dest_node,
 		      struct ipa_ref_list *src)
 {
   struct ipa_ref *ref, *ref2;
@@ -225,7 +225,7 @@ ipa_clone_references (symtab_node dest_node,
 /* Clone all referring from SRC to DEST_NODE or DEST_VARPOOL_NODE.  */
 
 void
-ipa_clone_referring (symtab_node dest_node,
+ipa_clone_referring (symtab_node *dest_node,
 		    struct ipa_ref_list *src)
 {
   struct ipa_ref *ref, *ref2;
@@ -268,7 +268,7 @@ ipa_ref_has_aliases_p (struct ipa_ref_list *ref_list)
    and associated with statement STMT.  */
 
 struct ipa_ref *
-ipa_find_reference (symtab_node referring_node, symtab_node referred_node,
+ipa_find_reference (symtab_node *referring_node, symtab_node *referred_node,
 		    gimple stmt, unsigned int lto_stmt_uid)
 {
   struct ipa_ref *r = NULL;
@@ -288,7 +288,7 @@ ipa_find_reference (symtab_node referring_node, symtab_node referred_node,
    STMT.  */
 
 void
-ipa_remove_stmt_references (symtab_node referring_node, gimple stmt)
+ipa_remove_stmt_references (symtab_node *referring_node, gimple stmt)
 {
   struct ipa_ref *r = NULL;
   int i;
@@ -304,7 +304,7 @@ ipa_remove_stmt_references (symtab_node referring_node, gimple stmt)
    with callgraph edges associated with them.  */
 
 void
-ipa_clear_stmts_in_references (symtab_node referring_node)
+ipa_clear_stmts_in_references (symtab_node *referring_node)
 {
   struct ipa_ref *r = NULL;
   int i;
diff --git a/gcc/ipa-ref.h b/gcc/ipa-ref.h
index d5ea7ee..9f392b4 100644
--- a/gcc/ipa-ref.h
+++ b/gcc/ipa-ref.h
@@ -20,7 +20,7 @@ along with GCC; see the file COPYING3.  If not see
 
 struct cgraph_node;
 struct varpool_node;
-class symtab_node_base;
+class symtab_node;
 
 
 /* How the reference is done.  */
@@ -35,8 +35,8 @@ enum GTY(()) ipa_ref_use
 /* Record of reference in callgraph or varpool.  */
 struct GTY(()) ipa_ref
 {
-  symtab_node referring;
-  symtab_node referred;
+  symtab_node *referring;
+  symtab_node *referred;
   gimple stmt;
   unsigned int lto_stmt_uid;
   unsigned int referred_index;
@@ -58,10 +58,10 @@ struct GTY(()) ipa_ref_list
   vec<ipa_ref_ptr>  GTY((skip)) referring;
 };
 
-struct ipa_ref * ipa_record_reference (symtab_node,
-				       symtab_node,
+struct ipa_ref * ipa_record_reference (symtab_node *,
+				       symtab_node *,
 				       enum ipa_ref_use, gimple);
-struct ipa_ref * ipa_maybe_record_reference (symtab_node, tree,
+struct ipa_ref * ipa_maybe_record_reference (symtab_node *, tree,
 					     enum ipa_ref_use, gimple);
 
 void ipa_remove_reference (struct ipa_ref *);
@@ -69,11 +69,11 @@ void ipa_remove_all_references (struct ipa_ref_list *);
 void ipa_remove_all_referring (struct ipa_ref_list *);
 void ipa_dump_references (FILE *, struct ipa_ref_list *);
 void ipa_dump_referring (FILE *, struct ipa_ref_list *);
-void ipa_clone_references (symtab_node, struct ipa_ref_list *);
-void ipa_clone_referring (symtab_node, struct ipa_ref_list *);
-struct ipa_ref * ipa_clone_ref (struct ipa_ref *, symtab_node, gimple);
+void ipa_clone_references (symtab_node *, struct ipa_ref_list *);
+void ipa_clone_referring (symtab_node *, struct ipa_ref_list *);
+struct ipa_ref * ipa_clone_ref (struct ipa_ref *, symtab_node *, gimple);
 bool ipa_ref_cannot_lead_to_return (struct ipa_ref *);
 bool ipa_ref_has_aliases_p (struct ipa_ref_list *);
-struct ipa_ref * ipa_find_reference (symtab_node, symtab_node, gimple, unsigned int);
-void ipa_remove_stmt_references (symtab_node, gimple);
-void ipa_clear_stmts_in_references (symtab_node);
+struct ipa_ref * ipa_find_reference (symtab_node *, symtab_node *, gimple, unsigned int);
+void ipa_remove_stmt_references (symtab_node *, gimple);
+void ipa_clear_stmts_in_references (symtab_node *);
diff --git a/gcc/ipa-reference.c b/gcc/ipa-reference.c
index 9c54921..587f70b 100644
--- a/gcc/ipa-reference.c
+++ b/gcc/ipa-reference.c
@@ -971,7 +971,7 @@ ipa_reference_write_optimization_summary (void)
   /* See what variables we are interested in.  */
   for (i = 0; i < lto_symtab_encoder_size (encoder); i++)
     {
-      symtab_node snode = lto_symtab_encoder_deref (encoder, i);
+      symtab_node *snode = lto_symtab_encoder_deref (encoder, i);
       varpool_node *vnode = dyn_cast <varpool_node> (snode);
       if (vnode
 	  && bitmap_bit_p (all_module_statics, DECL_UID (vnode->decl))
@@ -989,7 +989,7 @@ ipa_reference_write_optimization_summary (void)
   if (ltrans_statics_bitcount)
     for (i = 0; i < lto_symtab_encoder_size (encoder); i++)
       {
-	symtab_node snode = lto_symtab_encoder_deref (encoder, i);
+	symtab_node *snode = lto_symtab_encoder_deref (encoder, i);
 	cgraph_node *cnode = dyn_cast <cgraph_node> (snode);
 	if (cnode && write_node_summary_p (cnode, encoder, ltrans_statics))
 	  count++;
@@ -1004,7 +1004,7 @@ ipa_reference_write_optimization_summary (void)
   if (ltrans_statics_bitcount)
     for (i = 0; i < lto_symtab_encoder_size (encoder); i++)
       {
-	symtab_node snode = lto_symtab_encoder_deref (encoder, i);
+	symtab_node *snode = lto_symtab_encoder_deref (encoder, i);
 	cgraph_node *cnode = dyn_cast <cgraph_node> (snode);
 	if (cnode && write_node_summary_p (cnode, encoder, ltrans_statics))
 	  {
diff --git a/gcc/ipa.c b/gcc/ipa.c
index 408c690..80f5f9d 100644
--- a/gcc/ipa.c
+++ b/gcc/ipa.c
@@ -106,7 +106,7 @@ update_inlined_to_pointer (struct cgraph_node *node, struct cgraph_node *inlined
    reachable.  */
 
 static void
-enqueue_node (symtab_node node, symtab_node *first,
+enqueue_node (symtab_node *node, symtab_node **first,
 	      struct pointer_set_t *reachable)
 {
   /* Node is still in queue; do nothing.  */
@@ -124,7 +124,7 @@ enqueue_node (symtab_node node, symtab_node *first,
 
 static void
 process_references (struct ipa_ref_list *list,
-		    symtab_node *first,
+		    symtab_node **first,
 		    bool before_inlining_p,
 		    struct pointer_set_t *reachable)
 {
@@ -132,7 +132,7 @@ process_references (struct ipa_ref_list *list,
   struct ipa_ref *ref;
   for (i = 0; ipa_ref_list_reference_iterate (list, i, ref); i++)
     {
-      symtab_node node = ref->referred;
+      symtab_node *node = ref->referred;
 
       if (node->definition && !node->in_other_partition
 	  && ((!DECL_EXTERNAL (node->decl) || node->alias)
@@ -208,7 +208,7 @@ process_references (struct ipa_ref_list *list,
 bool
 symtab_remove_unreachable_nodes (bool before_inlining_p, FILE *file)
 {
-  symtab_node first = (symtab_node) (void *) 1;
+  symtab_node *first = (symtab_node *) (void *) 1;
   struct cgraph_node *node, *next;
   struct varpool_node *vnode, *vnext;
   bool changed = false;
@@ -261,12 +261,12 @@ symtab_remove_unreachable_nodes (bool before_inlining_p, FILE *file)
       }
 
   /* Perform reachability analysis.  */
-  while (first != (symtab_node) (void *) 1)
+  while (first != (symtab_node *) (void *) 1)
     {
       bool in_boundary_p = !pointer_set_contains (reachable, first);
-      symtab_node node = first;
+      symtab_node *node = first;
 
-      first = (symtab_node)first->aux;
+      first = (symtab_node *)first->aux;
 
       /* If we are processing symbol in boundary, mark its AUX pointer for
 	 possible later re-processing in enqueue_node.  */
@@ -285,7 +285,7 @@ symtab_remove_unreachable_nodes (bool before_inlining_p, FILE *file)
 	     all other in the same comdat group to be also reachable.  */
 	  if (node->same_comdat_group)
 	    {
-	      symtab_node next;
+	      symtab_node *next;
 	      for (next = node->same_comdat_group;
 		   next != node;
 		   next = next->same_comdat_group)
@@ -547,7 +547,7 @@ ipa_discover_readonly_nonaddressable_vars (void)
 
 /* Return true when there is a reference to node and it is not vtable.  */
 static bool
-address_taken_from_non_vtable_p (symtab_node node)
+address_taken_from_non_vtable_p (symtab_node *node)
 {
   int i;
   struct ipa_ref *ref;
@@ -568,7 +568,7 @@ address_taken_from_non_vtable_p (symtab_node node)
 /* A helper for comdat_can_be_unshared_p.  */
 
 static bool
-comdat_can_be_unshared_p_1 (symtab_node node)
+comdat_can_be_unshared_p_1 (symtab_node *node)
 {
   /* When address is taken, we don't know if equality comparison won't
      break eventually. Exception are virutal functions, C++
@@ -611,13 +611,13 @@ comdat_can_be_unshared_p_1 (symtab_node node)
    but in C++ there is no way to compare their addresses for equality.  */
 
 static bool
-comdat_can_be_unshared_p (symtab_node node)
+comdat_can_be_unshared_p (symtab_node *node)
 {
   if (!comdat_can_be_unshared_p_1 (node))
     return false;
   if (node->same_comdat_group)
     {
-      symtab_node next;
+      symtab_node *next;
 
       /* If more than one function is in the same COMDAT group, it must
          be shared even if just one function in the comdat group has
@@ -766,7 +766,7 @@ varpool_externally_visible_p (struct varpool_node *vnode)
  */
 
 bool
-can_replace_by_local_alias (symtab_node node)
+can_replace_by_local_alias (symtab_node *node)
 {
   return (symtab_node_availability (node) > AVAIL_OVERWRITABLE
 	  && !symtab_can_be_discarded (node));
@@ -826,7 +826,7 @@ function_and_variable_visibility (bool whole_program)
       if (node->same_comdat_group && DECL_EXTERNAL (node->decl))
 	{
 #ifdef ENABLE_CHECKING
-	  symtab_node n;
+	  symtab_node *n;
 
 	  for (n = node->same_comdat_group;
 	       n != node;
diff --git a/gcc/is-a.h b/gcc/is-a.h
index 15540e4..c47d10f 100644
--- a/gcc/is-a.h
+++ b/gcc/is-a.h
@@ -31,7 +31,7 @@ bool is_a <TYPE> (pointer)
 
     Tests whether the pointer actually points to a more derived TYPE.
 
-    Suppose you have a symtab_node_base *ptr, AKA symtab_node ptr.  You can test
+    Suppose you have a symtab_node *ptr, AKA symtab_node *ptr.  You can test
     whether it points to a 'derived' cgraph_node as follows.
 
       if (is_a <cgraph_node> (ptr))
@@ -110,7 +110,7 @@ example,
   template <>
   template <>
   inline bool
-  is_a_helper <cgraph_node>::test (symtab_node_base *p)
+  is_a_helper <cgraph_node>::test (symtab_node *p)
   {
     return p->type == SYMTAB_FUNCTION;
   }
@@ -122,7 +122,7 @@ when needed may result in a crash.  For example,
   template <>
   template <>
   inline bool
-  is_a_helper <cgraph_node>::cast (symtab_node_base *p)
+  is_a_helper <cgraph_node>::cast (symtab_node *p)
   {
     return &p->x_function;
   }
diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c
index 80e041a..e84c7d0 100644
--- a/gcc/lto-cgraph.c
+++ b/gcc/lto-cgraph.c
@@ -51,7 +51,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "pass_manager.h"
 
 static void output_cgraph_opt_summary (void);
-static void input_cgraph_opt_summary (vec<symtab_node>  nodes);
+static void input_cgraph_opt_summary (vec<symtab_node *>  nodes);
 
 /* Number of LDPR values known to GCC.  */
 #define LDPR_NUM_KNOWN (LDPR_PREVAILING_DEF_IRONLY_EXP + 1)
@@ -110,7 +110,7 @@ lto_symtab_encoder_delete (lto_symtab_encoder_t encoder)
 
 int
 lto_symtab_encoder_encode (lto_symtab_encoder_t encoder,
-			   symtab_node node)
+			   symtab_node *node)
 {
   int ref;
   void **slot;
@@ -144,7 +144,7 @@ lto_symtab_encoder_encode (lto_symtab_encoder_t encoder,
 
 bool
 lto_symtab_encoder_delete_node (lto_symtab_encoder_t encoder,
-			        symtab_node node)
+			        symtab_node *node)
 {
   void **slot, **last_slot;
   int index;
@@ -223,7 +223,7 @@ lto_set_symtab_encoder_encode_initializer (lto_symtab_encoder_t encoder,
 
 bool
 lto_symtab_encoder_in_partition_p (lto_symtab_encoder_t encoder,
-				   symtab_node node)
+				   symtab_node *node)
 {
   int index = lto_symtab_encoder_lookup (encoder, node);
   if (index == LCC_NOT_FOUND)
@@ -235,7 +235,7 @@ lto_symtab_encoder_in_partition_p (lto_symtab_encoder_t encoder,
 
 void
 lto_set_symtab_encoder_in_partition (lto_symtab_encoder_t encoder,
-				     symtab_node node)
+				     symtab_node *node)
 {
   int index = lto_symtab_encoder_encode (encoder, node);
   encoder->nodes[index].in_partition = true;
@@ -702,7 +702,7 @@ output_refs (lto_symtab_encoder_t encoder)
   for (lsei = lsei_start_in_partition (encoder); !lsei_end_p (lsei);
        lsei_next_in_partition (&lsei))
     {
-      symtab_node node = lsei_node (lsei);
+      symtab_node *node = lsei_node (lsei);
 
       count = ipa_ref_list_nreferences (&node->ref_list);
       if (count)
@@ -808,7 +808,7 @@ compute_ltrans_boundary (lto_symtab_encoder_t in_encoder)
      pickle those too.  */
   for (i = 0; i < lto_symtab_encoder_size (encoder); i++)
     {
-      symtab_node node = lto_symtab_encoder_deref (encoder, i);
+      symtab_node *node = lto_symtab_encoder_deref (encoder, i);
       if (varpool_node *vnode = dyn_cast <varpool_node> (node))
 	{
 	  if (!lto_symtab_encoder_encode_initializer_p (encoder,
@@ -872,7 +872,7 @@ output_symtab (void)
   n_nodes = lto_symtab_encoder_size (encoder);
   for (i = 0; i < n_nodes; i++)
     {
-      symtab_node node = lto_symtab_encoder_deref (encoder, i);
+      symtab_node *node = lto_symtab_encoder_deref (encoder, i);
       if (cgraph_node *cnode = dyn_cast <cgraph_node> (node))
         lto_output_node (ob, cnode, encoder);
       else
@@ -978,7 +978,7 @@ static struct cgraph_node *
 input_node (struct lto_file_decl_data *file_data,
 	    struct lto_input_block *ib,
 	    enum LTO_symtab_tags tag,
-	    vec<symtab_node> nodes)
+	    vec<symtab_node *> nodes)
 {
   gcc::pass_manager *passes = g->get_passes ();
   tree fn_decl;
@@ -1051,7 +1051,7 @@ input_node (struct lto_file_decl_data *file_data,
   node->global.inlined_to = (cgraph_node_ptr) (intptr_t) ref;
 
   /* Store a reference for now, and fix up later to be a pointer.  */
-  node->same_comdat_group = (symtab_node) (intptr_t) ref2;
+  node->same_comdat_group = (symtab_node *) (intptr_t) ref2;
 
   if (node->thunk.thunk_p)
     {
@@ -1120,7 +1120,7 @@ input_varpool_node (struct lto_file_decl_data *file_data,
     node->alias_target = get_alias_symbol (node->decl);
   ref = streamer_read_hwi (ib);
   /* Store a reference for now, and fix up later to be a pointer.  */
-  node->same_comdat_group = (symtab_node) (intptr_t) ref;
+  node->same_comdat_group = (symtab_node *) (intptr_t) ref;
   node->resolution = streamer_read_enum (ib, ld_plugin_symbol_resolution,
 					        LDPR_NUM_KNOWN);
 
@@ -1132,10 +1132,10 @@ input_varpool_node (struct lto_file_decl_data *file_data,
 
 static void
 input_ref (struct lto_input_block *ib,
-	   symtab_node referring_node,
-	   vec<symtab_node> nodes)
+	   symtab_node *referring_node,
+	   vec<symtab_node *> nodes)
 {
-  symtab_node node = NULL;
+  symtab_node *node = NULL;
   struct bitpack_d bp;
   enum ipa_ref_use use;
   bool speculative;
@@ -1157,7 +1157,7 @@ input_ref (struct lto_input_block *ib,
    indirect_unknown_callee set).  */
 
 static void
-input_edge (struct lto_input_block *ib, vec<symtab_node> nodes,
+input_edge (struct lto_input_block *ib, vec<symtab_node *> nodes,
 	    bool indirect)
 {
   struct cgraph_node *caller, *callee;
@@ -1224,13 +1224,13 @@ input_edge (struct lto_input_block *ib, vec<symtab_node> nodes,
 
 /* Read a cgraph from IB using the info in FILE_DATA.  */
 
-static vec<symtab_node> 
+static vec<symtab_node *> 
 input_cgraph_1 (struct lto_file_decl_data *file_data,
 		struct lto_input_block *ib)
 {
   enum LTO_symtab_tags tag;
-  vec<symtab_node> nodes = vNULL;
-  symtab_node node;
+  vec<symtab_node *> nodes = vNULL;
+  symtab_node *node;
   unsigned i;
 
   tag = streamer_read_enum (ib, LTO_symtab_tags, LTO_symtab_last_tag);
@@ -1302,13 +1302,13 @@ input_cgraph_1 (struct lto_file_decl_data *file_data,
 
 static void
 input_refs (struct lto_input_block *ib,
-	    vec<symtab_node> nodes)
+	    vec<symtab_node *> nodes)
 {
   int count;
   int idx;
   while (true)
     {
-      symtab_node node;
+      symtab_node *node;
       count = streamer_read_uhwi (ib);
       if (!count)
 	break;
@@ -1512,7 +1512,7 @@ input_symtab (void)
       const char *data;
       size_t len;
       struct lto_input_block *ib;
-      vec<symtab_node> nodes;
+      vec<symtab_node *> nodes;
 
       ib = lto_create_simple_input_block (file_data, LTO_section_symtab_nodes,
 					  &data, &len);
@@ -1642,7 +1642,7 @@ output_cgraph_opt_summary (void)
   n_nodes = lto_symtab_encoder_size (encoder);
   for (i = 0; i < n_nodes; i++)
     {
-      symtab_node node = lto_symtab_encoder_deref (encoder, i);
+      symtab_node *node = lto_symtab_encoder_deref (encoder, i);
       cgraph_node *cnode = dyn_cast <cgraph_node> (node);
       if (cnode && output_cgraph_opt_summary_p (cnode))
 	count++;
@@ -1650,7 +1650,7 @@ output_cgraph_opt_summary (void)
   streamer_write_uhwi (ob, count);
   for (i = 0; i < n_nodes; i++)
     {
-      symtab_node node = lto_symtab_encoder_deref (encoder, i);
+      symtab_node *node = lto_symtab_encoder_deref (encoder, i);
       cgraph_node *cnode = dyn_cast <cgraph_node> (node);
       if (cnode && output_cgraph_opt_summary_p (cnode))
 	{
@@ -1723,7 +1723,7 @@ input_node_opt_summary (struct cgraph_node *node,
 static void
 input_cgraph_opt_section (struct lto_file_decl_data *file_data,
 			  const char *data, size_t len,
-			  vec<symtab_node> nodes)
+			  vec<symtab_node *> nodes)
 {
   const struct lto_function_header *header =
     (const struct lto_function_header *) data;
@@ -1757,7 +1757,7 @@ input_cgraph_opt_section (struct lto_file_decl_data *file_data,
 /* Input optimization summary of cgraph.  */
 
 static void
-input_cgraph_opt_summary (vec<symtab_node> nodes)
+input_cgraph_opt_summary (vec<symtab_node *> nodes)
 {
   struct lto_file_decl_data **file_data_vec = lto_get_file_decl_data ();
   struct lto_file_decl_data *file_data;
diff --git a/gcc/lto-section-in.c b/gcc/lto-section-in.c
index ead0c41..c6a418f 100644
--- a/gcc/lto-section-in.c
+++ b/gcc/lto-section-in.c
@@ -429,7 +429,7 @@ lto_free_function_in_decl_state (struct lto_in_decl_state *state)
    release trees needed by the NODE's body.  */
 
 void
-lto_free_function_in_decl_state_for_node (symtab_node node)
+lto_free_function_in_decl_state_for_node (symtab_node *node)
 {
   struct lto_in_decl_state temp;
   void **slot;
diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
index ae725d5..45b98ef 100644
--- a/gcc/lto-streamer-out.c
+++ b/gcc/lto-streamer-out.c
@@ -1981,7 +1981,7 @@ lto_output (void)
   /* Process only the functions with bodies.  */
   for (i = 0; i < n_nodes; i++)
     {
-      symtab_node snode = lto_symtab_encoder_deref (encoder, i);
+      symtab_node *snode = lto_symtab_encoder_deref (encoder, i);
       cgraph_node *node = dyn_cast <cgraph_node> (snode);
       if (node
 	  && lto_symtab_encoder_encode_body_p (encoder, node)
@@ -2290,7 +2290,7 @@ write_symbol (struct streamer_tree_cache_d *cache,
 /* Return true if NODE should appear in the plugin symbol table.  */
 
 bool
-output_symbol_p (symtab_node node)
+output_symbol_p (symtab_node *node)
 {
   struct cgraph_node *cnode;
   if (!symtab_real_symbol_p (node))
@@ -2352,7 +2352,7 @@ produce_symtab (struct output_block *ob)
   for (lsei = lsei_start (encoder);
        !lsei_end_p (lsei); lsei_next (&lsei))
     {
-      symtab_node node = lsei_node (lsei);
+      symtab_node *node = lsei_node (lsei);
 
       if (!output_symbol_p (node) || DECL_EXTERNAL (node->decl))
 	continue;
@@ -2361,7 +2361,7 @@ produce_symtab (struct output_block *ob)
   for (lsei = lsei_start (encoder);
        !lsei_end_p (lsei); lsei_next (&lsei))
     {
-      symtab_node node = lsei_node (lsei);
+      symtab_node *node = lsei_node (lsei);
 
       if (!output_symbol_p (node) || !DECL_EXTERNAL (node->decl))
 	continue;
diff --git a/gcc/lto-streamer.h b/gcc/lto-streamer.h
index 13a9593..28245c9 100644
--- a/gcc/lto-streamer.h
+++ b/gcc/lto-streamer.h
@@ -432,7 +432,7 @@ struct lto_stats_d
 /* Entry of LTO symtab encoder.  */
 typedef struct
 {
-  symtab_node node;
+  symtab_node *node;
   /* Is the node in this partition (i.e. ltrans of this partition will
      be responsible for outputting it)? */
   unsigned int in_partition:1;
@@ -775,7 +775,7 @@ extern int lto_eq_in_decl_state (const void *, const void *);
 extern struct lto_in_decl_state *lto_get_function_in_decl_state (
 				      struct lto_file_decl_data *, tree);
 extern void lto_free_function_in_decl_state (struct lto_in_decl_state *);
-extern void lto_free_function_in_decl_state_for_node (symtab_node);
+extern void lto_free_function_in_decl_state_for_node (symtab_node *);
 extern void lto_section_overrun (struct lto_input_block *) ATTRIBUTE_NORETURN;
 extern void lto_value_range_error (const char *,
 				   HOST_WIDE_INT, HOST_WIDE_INT,
@@ -874,15 +874,15 @@ void lto_output_location (struct output_block *, struct bitpack_d *, location_t)
 
 /* In lto-cgraph.c  */
 lto_symtab_encoder_t lto_symtab_encoder_new (bool);
-int lto_symtab_encoder_encode (lto_symtab_encoder_t, symtab_node);
+int lto_symtab_encoder_encode (lto_symtab_encoder_t, symtab_node *);
 void lto_symtab_encoder_delete (lto_symtab_encoder_t);
-bool lto_symtab_encoder_delete_node (lto_symtab_encoder_t, symtab_node);
+bool lto_symtab_encoder_delete_node (lto_symtab_encoder_t, symtab_node *);
 bool lto_symtab_encoder_encode_body_p (lto_symtab_encoder_t,
 				       struct cgraph_node *);
 bool lto_symtab_encoder_in_partition_p (lto_symtab_encoder_t,
-					symtab_node);
+					symtab_node *);
 void lto_set_symtab_encoder_in_partition (lto_symtab_encoder_t,
-					  symtab_node);
+					  symtab_node *);
 
 bool lto_symtab_encoder_encode_initializer_p (lto_symtab_encoder_t,
 					      struct varpool_node *);
@@ -1045,7 +1045,7 @@ lto_symtab_encoder_size (lto_symtab_encoder_t encoder)
 
 static inline int
 lto_symtab_encoder_lookup (lto_symtab_encoder_t encoder,
-			   symtab_node node)
+			   symtab_node *node)
 {
   void **slot = pointer_map_contains (encoder->map, node);
   return (slot && *slot ? (size_t) *(slot) - 1 : LCC_NOT_FOUND);
@@ -1066,7 +1066,7 @@ lsei_next (lto_symtab_encoder_iterator *lsei)
 }
 
 /* Return the node pointed to by LSI.  */
-static inline symtab_node
+static inline symtab_node *
 lsei_node (lto_symtab_encoder_iterator lsei)
 {
   return lsei.encoder->nodes[lsei.index].node;
@@ -1088,7 +1088,7 @@ lsei_varpool_node (lto_symtab_encoder_iterator lsei)
 
 /* Return the cgraph node corresponding to REF using ENCODER.  */
 
-static inline symtab_node
+static inline symtab_node *
 lto_symtab_encoder_deref (lto_symtab_encoder_t encoder, int ref)
 {
   if (ref == LCC_NOT_FOUND)
diff --git a/gcc/lto/lto-partition.c b/gcc/lto/lto-partition.c
index e2a237a..98218f7 100644
--- a/gcc/lto/lto-partition.c
+++ b/gcc/lto/lto-partition.c
@@ -46,12 +46,12 @@ enum symbol_class
 
 vec<ltrans_partition> ltrans_partitions;
 
-static void add_symbol_to_partition (ltrans_partition part, symtab_node node);
+static void add_symbol_to_partition (ltrans_partition part, symtab_node *node);
 
 /* Classify symbol NODE.  */
 
 enum symbol_class
-get_symbol_class (symtab_node node)
+get_symbol_class (symtab_node *node)
 {
   /* Inline clones are always duplicated.
      This include external delcarations.   */
@@ -130,14 +130,14 @@ free_ltrans_partitions (void)
 /* Return true if symbol is already in some partition.  */
 
 static inline bool
-symbol_partitioned_p (symtab_node node)
+symbol_partitioned_p (symtab_node *node)
 {
   return node->aux;
 }
 
 /* Add references into the partition.  */
 static void
-add_references_to_partition (ltrans_partition part, symtab_node node)
+add_references_to_partition (ltrans_partition part, symtab_node *node)
 {
   int i;
   struct ipa_ref *ref;
@@ -164,12 +164,12 @@ add_references_to_partition (ltrans_partition part, symtab_node node)
    of adding NODE to PART.  */
 
 static bool
-add_symbol_to_partition_1 (ltrans_partition part, symtab_node node)
+add_symbol_to_partition_1 (ltrans_partition part, symtab_node *node)
 {
   enum symbol_class c = get_symbol_class (node);
   int i;
   struct ipa_ref *ref;
-  symtab_node node1;
+  symtab_node *node1;
 
   /* If NODE is already there, we have nothing to do.  */
   if (lto_symtab_encoder_in_partition_p (part->encoder, node))
@@ -240,8 +240,8 @@ add_symbol_to_partition_1 (ltrans_partition part, symtab_node node)
    internal label, thunk, alias or so), return the outer symbol. 
    When add_symbol_to_partition_1 is called on the outer symbol it must
    eventually add NODE, too.  */
-static symtab_node
-contained_in_symbol (symtab_node node)
+static symtab_node *
+contained_in_symbol (symtab_node *node)
 {
   /* Weakrefs are never contained in anything.  */
   if (node->weakref)
@@ -262,9 +262,9 @@ contained_in_symbol (symtab_node node)
    of other symbol definition, add the other symbol, too.  */
 
 static void
-add_symbol_to_partition (ltrans_partition part, symtab_node node)
+add_symbol_to_partition (ltrans_partition part, symtab_node *node)
 {
-  symtab_node node1;
+  symtab_node *node1;
 
   /* Verify that we do not try to duplicate something that can not be.  */
   gcc_checking_assert (get_symbol_class (node) == SYMBOL_DUPLICATE
@@ -293,7 +293,7 @@ undo_partition (ltrans_partition partition, unsigned int n_nodes)
 {
   while (lto_symtab_encoder_size (partition->encoder) > (int)n_nodes)
     {
-      symtab_node node = lto_symtab_encoder_deref (partition->encoder,
+      symtab_node *node = lto_symtab_encoder_deref (partition->encoder,
 						   n_nodes);
 
       /* After UNDO we no longer know what was visited.  */
@@ -314,7 +314,7 @@ undo_partition (ltrans_partition partition, unsigned int n_nodes)
 void
 lto_1_to_1_map (void)
 {
-  symtab_node node;
+  symtab_node *node;
   struct lto_file_decl_data *file_data;
   struct pointer_map_t *pmap;
   ltrans_partition partition;
@@ -371,7 +371,7 @@ lto_1_to_1_map (void)
 void
 lto_max_map (void)
 {
-  symtab_node node;
+  symtab_node *node;
   ltrans_partition partition;
   int npartitions = 0;
 
@@ -544,7 +544,7 @@ lto_balanced_map (void)
 	  struct ipa_ref_list *refs;
 	  int j;
 	  struct ipa_ref *ref;
-	  symtab_node snode = lto_symtab_encoder_deref (partition->encoder,
+	  symtab_node *snode = lto_symtab_encoder_deref (partition->encoder,
 							last_visited_node);
 
 	  if (cgraph_node *node = dyn_cast <cgraph_node> (snode))
@@ -762,7 +762,7 @@ lto_balanced_map (void)
 */
 
 static bool
-privatize_symbol_name (symtab_node node)
+privatize_symbol_name (symtab_node *node)
 {
   tree decl = node->decl;
   const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
@@ -805,7 +805,7 @@ privatize_symbol_name (symtab_node node)
 /* Promote variable VNODE to be static.  */
 
 static void
-promote_symbol (symtab_node node)
+promote_symbol (symtab_node *node)
 {
   /* We already promoted ... */
   if (DECL_VISIBILITY (node->decl) == VISIBILITY_HIDDEN
@@ -831,7 +831,7 @@ promote_symbol (symtab_node node)
    FIXME: we should really not use named sections for inline clones and master clones.  */
 
 static bool
-may_need_named_section_p (lto_symtab_encoder_t encoder, symtab_node node)
+may_need_named_section_p (lto_symtab_encoder_t encoder, symtab_node *node)
 {
   struct cgraph_node *cnode = dyn_cast <cgraph_node> (node);
   if (!cnode)
@@ -851,10 +851,10 @@ may_need_named_section_p (lto_symtab_encoder_t encoder, symtab_node node)
    asm statemnets referring to them by symbol name.  */
 
 static void
-rename_statics (lto_symtab_encoder_t encoder, symtab_node node)
+rename_statics (lto_symtab_encoder_t encoder, symtab_node *node)
 {
   tree decl = node->decl;
-  symtab_node s;
+  symtab_node *s;
   tree name = DECL_ASSEMBLER_NAME (decl);
 
   /* See if this is static symbol. */
@@ -934,7 +934,7 @@ lto_promote_cross_file_statics (void)
       for (lsei = lsei_start (encoder); !lsei_end_p (lsei);
 	   lsei_next (&lsei))
         {
-          symtab_node node = lsei_node (lsei);
+          symtab_node *node = lsei_node (lsei);
 
 	  /* If symbol is static, rename it if its assembler name clash with
 	     anything else in this unit.  */
@@ -960,7 +960,7 @@ lto_promote_cross_file_statics (void)
 void
 lto_promote_statics_nonwpa (void)
 {
-  symtab_node node;
+  symtab_node *node;
   FOR_EACH_SYMBOL (node)
     rename_statics (NULL, node);
 }
diff --git a/gcc/lto/lto-symtab.c b/gcc/lto/lto-symtab.c
index ec42a93..ced6cf9 100644
--- a/gcc/lto/lto-symtab.c
+++ b/gcc/lto/lto-symtab.c
@@ -113,7 +113,7 @@ lto_varpool_replace_node (struct varpool_node *vnode,
    should be emitted.  */
 
 static bool
-lto_symtab_merge (symtab_node prevailing, symtab_node entry)
+lto_symtab_merge (symtab_node *prevailing, symtab_node *entry)
 {
   tree prevailing_decl = prevailing->decl;
   tree decl = entry->decl;
@@ -216,7 +216,7 @@ lto_symtab_merge (symtab_node prevailing, symtab_node entry)
    entry.  */
 
 static bool
-lto_symtab_resolve_replaceable_p (symtab_node e)
+lto_symtab_resolve_replaceable_p (symtab_node *e)
 {
   if (DECL_EXTERNAL (e->decl)
       || DECL_COMDAT (e->decl)
@@ -236,7 +236,7 @@ lto_symtab_resolve_replaceable_p (symtab_node e)
    handle renaming of static later in partitioning).  */
 
 static bool
-lto_symtab_symbol_p (symtab_node e)
+lto_symtab_symbol_p (symtab_node *e)
 {
   if (!TREE_PUBLIC (e->decl) && !DECL_EXTERNAL (e->decl))
     return false;
@@ -246,7 +246,7 @@ lto_symtab_symbol_p (symtab_node e)
 /* Return true if the symtab entry E can be the prevailing one.  */
 
 static bool
-lto_symtab_resolve_can_prevail_p (symtab_node e)
+lto_symtab_resolve_can_prevail_p (symtab_node *e)
 {
   if (!lto_symtab_symbol_p (e))
     return false;
@@ -263,11 +263,11 @@ lto_symtab_resolve_can_prevail_p (symtab_node e)
 /* Resolve the symbol with the candidates in the chain *SLOT and store
    their resolutions.  */
 
-static symtab_node
-lto_symtab_resolve_symbols (symtab_node first)
+static symtab_node *
+lto_symtab_resolve_symbols (symtab_node *first)
 {
-  symtab_node e;
-  symtab_node prevailing = NULL;
+  symtab_node *e;
+  symtab_node *prevailing = NULL;
 
   /* Always set e->node so that edges are updated to reflect decl merging. */
   for (e = first; e; e = e->next_sharing_asm_name)
@@ -359,10 +359,10 @@ lto_symtab_resolve_symbols (symtab_node first)
    do not issue further diagnostics.*/
 
 static void
-lto_symtab_merge_decls_2 (symtab_node first, bool diagnosed_p)
+lto_symtab_merge_decls_2 (symtab_node *first, bool diagnosed_p)
 {
-  symtab_node prevailing;
-  symtab_node e;
+  symtab_node *prevailing;
+  symtab_node *e;
   vec<tree> mismatches = vNULL;
   unsigned i;
   tree decl;
@@ -412,10 +412,10 @@ lto_symtab_merge_decls_2 (symtab_node first, bool diagnosed_p)
 /* Helper to process the decl chain for the symbol table entry *SLOT.  */
 
 static void
-lto_symtab_merge_decls_1 (symtab_node first)
+lto_symtab_merge_decls_1 (symtab_node *first)
 {
-  symtab_node e;
-  symtab_node prevailing;
+  symtab_node *e;
+  symtab_node *prevailing;
   bool diagnosed_p = false;
 
   if (cgraph_dump_file)
@@ -522,7 +522,7 @@ lto_symtab_merge_decls_1 (symtab_node first)
 void
 lto_symtab_merge_decls (void)
 {
-  symtab_node node;
+  symtab_node *node;
 
   /* Populate assembler name hash.   */
   symtab_initialize_asm_name_hash ();
@@ -536,10 +536,10 @@ lto_symtab_merge_decls (void)
 /* Helper to process the decl chain for the symbol table entry *SLOT.  */
 
 static void
-lto_symtab_merge_symbols_1 (symtab_node prevailing)
+lto_symtab_merge_symbols_1 (symtab_node *prevailing)
 {
-  symtab_node e;
-  symtab_node next;
+  symtab_node *e;
+  symtab_node *next;
 
   /* Replace the cgraph node of each entry with the prevailing one.  */
   for (e = prevailing->next_sharing_asm_name; e;
@@ -565,7 +565,7 @@ lto_symtab_merge_symbols_1 (symtab_node prevailing)
 void
 lto_symtab_merge_symbols (void)
 {
-  symtab_node node;
+  symtab_node *node;
 
   if (!flag_ltrans)
     {
@@ -587,11 +587,11 @@ lto_symtab_merge_symbols (void)
 	{
 	  cgraph_node *cnode, *cnode2;
 	  varpool_node *vnode;
-	  symtab_node node2;
+	  symtab_node *node2;
 
 	  if (!node->analyzed && node->alias_target)
 	    {
-	      symtab_node tgt = symtab_node_for_asm (node->alias_target);
+	      symtab_node *tgt = symtab_node_for_asm (node->alias_target);
 	      gcc_assert (node->weakref);
 	      if (tgt)
 		symtab_resolve_alias (node, tgt);
@@ -639,7 +639,7 @@ lto_symtab_merge_symbols (void)
 tree
 lto_symtab_prevailing_decl (tree decl)
 {
-  symtab_node ret;
+  symtab_node *ret;
 
   /* Builtins and local symbols are their own prevailing decl.  */
   if ((!TREE_PUBLIC (decl) && !DECL_EXTERNAL (decl)) || is_builtin_fn (decl))
diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c
index 7015f54..88d9d00 100644
--- a/gcc/lto/lto.c
+++ b/gcc/lto/lto.c
@@ -3098,14 +3098,14 @@ lto_wpa_write_files (void)
 	  for (lsei = lsei_start_in_partition (part->encoder); !lsei_end_p (lsei);
 	       lsei_next_in_partition (&lsei))
 	    {
-	      symtab_node node = lsei_node (lsei);
+	      symtab_node *node = lsei_node (lsei);
 	      fprintf (cgraph_dump_file, "%s ", symtab_node_asm_name (node));
 	    }
 	  fprintf (cgraph_dump_file, "\n  Symbols in boundary: ");
 	  for (lsei = lsei_start (part->encoder); !lsei_end_p (lsei);
 	       lsei_next (&lsei))
 	    {
-	      symtab_node node = lsei_node (lsei);
+	      symtab_node *node = lsei_node (lsei);
 	      if (!lto_symtab_encoder_in_partition_p (part->encoder, node))
 		{
 	          fprintf (cgraph_dump_file, "%s ", symtab_node_asm_name (node));
@@ -3369,7 +3369,7 @@ read_cgraph_and_symbols (unsigned nfiles, const char **fnames)
   int count = 0;
   struct lto_file_decl_data **decl_data;
   void **res;
-  symtab_node snode;
+  symtab_node *snode;
 
   init_cgraph ();
 
@@ -3675,7 +3675,7 @@ print_lto_report_1 (void)
 static void
 do_whole_program_analysis (void)
 {
-  symtab_node node;
+  symtab_node *node;
 
   timevar_start (TV_PHASE_OPT_GEN);
 
diff --git a/gcc/symtab.c b/gcc/symtab.c
index 2b612b3..e10906c 100644
--- a/gcc/symtab.c
+++ b/gcc/symtab.c
@@ -48,12 +48,12 @@ const char * const ld_plugin_symbol_resolution_names[]=
 };
 
 /* Hash table used to convert declarations into nodes.  */
-static GTY((param_is (symtab_node_base))) htab_t symtab_hash;
+static GTY((param_is (symtab_node))) htab_t symtab_hash;
 /* Hash table used to convert assembler names into nodes.  */
-static GTY((param_is (symtab_node_base))) htab_t assembler_name_hash;
+static GTY((param_is (symtab_node))) htab_t assembler_name_hash;
 
 /* Linked list of symbol table nodes.  */
-symtab_node symtab_nodes;
+symtab_node *symtab_nodes;
 
 /* The order index of the next symtab node to be created.  This is
    used so that we can sort the cgraph nodes in order by when we saw
@@ -65,7 +65,7 @@ int symtab_order;
 static hashval_t
 hash_node (const void *p)
 {
-  const_symtab_node n = (const_symtab_node ) p;
+  const symtab_node *n = (const symtab_node *) p;
   return (hashval_t) DECL_UID (n->decl);
 }
 
@@ -75,8 +75,8 @@ hash_node (const void *p)
 static int
 eq_node (const void *p1, const void *p2)
 {
-  const_symtab_node n1 = (const_symtab_node) p1;
-  const_symtab_node n2 = (const_symtab_node) p2;
+  const symtab_node *n1 = (const symtab_node *) p1;
+  const symtab_node *n2 = (const symtab_node *) p2;
   return DECL_UID (n1->decl) == DECL_UID (n2->decl);
 }
 
@@ -85,7 +85,7 @@ eq_node (const void *p1, const void *p2)
 static hashval_t
 hash_node_by_assembler_name (const void *p)
 {
-  const_symtab_node n = (const_symtab_node) p;
+  const symtab_node *n = (const symtab_node *) p;
   return (hashval_t) decl_assembler_name_hash (DECL_ASSEMBLER_NAME (n->decl));
 }
 
@@ -94,7 +94,7 @@ hash_node_by_assembler_name (const void *p)
 static int
 eq_assembler_name (const void *p1, const void *p2)
 {
-  const_symtab_node n1 = (const_symtab_node) p1;
+  const symtab_node *n1 = (const symtab_node *) p1;
   const_tree name = (const_tree)p2;
   return (decl_assembler_name_equal (n1->decl, name));
 }
@@ -102,7 +102,7 @@ eq_assembler_name (const void *p1, const void *p2)
 /* Insert NODE to assembler name hash.  */
 
 static void
-insert_to_assembler_name_hash (symtab_node node, bool with_clones)
+insert_to_assembler_name_hash (symtab_node *node, bool with_clones)
 {
   if (is_a <varpool_node> (node) && DECL_HARD_REGISTER (node->decl))
     return;
@@ -120,9 +120,9 @@ insert_to_assembler_name_hash (symtab_node node, bool with_clones)
 					decl_assembler_name_hash (name),
 					INSERT);
       gcc_assert (*aslot != node);
-      node->next_sharing_asm_name = (symtab_node)*aslot;
+      node->next_sharing_asm_name = (symtab_node *)*aslot;
       if (*aslot != NULL)
-	((symtab_node)*aslot)->previous_sharing_asm_name = node;
+	((symtab_node *)*aslot)->previous_sharing_asm_name = node;
       *aslot = node;
 
       /* Update also possible inline clones sharing a decl.  */
@@ -138,7 +138,7 @@ insert_to_assembler_name_hash (symtab_node node, bool with_clones)
 /* Remove NODE from assembler name hash.  */
 
 static void
-unlink_from_assembler_name_hash (symtab_node node, bool with_clones)
+unlink_from_assembler_name_hash (symtab_node *node, bool with_clones)
 {
   if (assembler_name_hash)
     {
@@ -181,7 +181,7 @@ unlink_from_assembler_name_hash (symtab_node node, bool with_clones)
 /* Arrange node to be first in its entry of assembler_name_hash.  */
 
 void
-symtab_prevail_in_asm_name_hash (symtab_node node)
+symtab_prevail_in_asm_name_hash (symtab_node *node)
 {
   unlink_from_assembler_name_hash (node, false);
   insert_to_assembler_name_hash (node, false);
@@ -192,10 +192,10 @@ symtab_prevail_in_asm_name_hash (symtab_node node)
    cgraph/varpool node creation routines.  */
 
 void
-symtab_register_node (symtab_node node)
+symtab_register_node (symtab_node *node)
 {
-  struct symtab_node_base key;
-  symtab_node *slot;
+  struct symtab_node key;
+  symtab_node **slot;
 
   node->next = symtab_nodes;
   node->previous = NULL;
@@ -206,7 +206,7 @@ symtab_register_node (symtab_node node)
   if (!symtab_hash)
     symtab_hash = htab_create_ggc (10, hash_node, eq_node, NULL);
   key.decl = node->decl;
-  slot = (symtab_node *) htab_find_slot (symtab_hash, &key, INSERT);
+  slot = (symtab_node **) htab_find_slot (symtab_hash, &key, INSERT);
   if (*slot == NULL)
     *slot = node;
 
@@ -223,15 +223,15 @@ symtab_register_node (symtab_node node)
    of inline clones.  */
 
 void
-symtab_insert_node_to_hashtable (symtab_node node)
+symtab_insert_node_to_hashtable (symtab_node *node)
 {
-  struct symtab_node_base key;
-  symtab_node *slot;
+  struct symtab_node key;
+  symtab_node **slot;
 
   if (!symtab_hash)
     symtab_hash = htab_create_ggc (10, hash_node, eq_node, NULL);
   key.decl = node->decl;
-  slot = (symtab_node *) htab_find_slot (symtab_hash, &key, INSERT);
+  slot = (symtab_node **) htab_find_slot (symtab_hash, &key, INSERT);
   *slot = node;
 }
 
@@ -239,7 +239,7 @@ symtab_insert_node_to_hashtable (symtab_node node)
    cgraph/varpool node removal routines.  */
 
 void
-symtab_unregister_node (symtab_node node)
+symtab_unregister_node (symtab_node *node)
 {
   void **slot;
   ipa_remove_all_references (&node->ref_list);
@@ -247,7 +247,7 @@ symtab_unregister_node (symtab_node node)
 
   if (node->same_comdat_group)
     {
-      symtab_node prev;
+      symtab_node *prev;
       for (prev = node->same_comdat_group;
 	   prev->same_comdat_group != node;
 	   prev = prev->same_comdat_group)
@@ -275,7 +275,7 @@ symtab_unregister_node (symtab_node node)
   gcc_assert ((slot && *slot) || in_lto_p);
   if (slot && *slot && *slot == node)
     {
-      symtab_node replacement_node = NULL;
+      symtab_node *replacement_node = NULL;
       if (cgraph_node *cnode = dyn_cast <cgraph_node> (node))
 	replacement_node = cgraph_find_replacement_node (cnode);
       if (!replacement_node)
@@ -290,11 +290,11 @@ symtab_unregister_node (symtab_node node)
 /* Return symbol table node associated with DECL, if any,
    and NULL otherwise.  */
 
-symtab_node
+symtab_node *
 symtab_get_node (const_tree decl)
 {
-  symtab_node *slot;
-  struct symtab_node_base key;
+  symtab_node **slot;
+  struct symtab_node key;
 
 #ifdef ENABLE_CHECKING
   /* Check that we are called for sane type of object - functions
@@ -310,7 +310,7 @@ symtab_get_node (const_tree decl)
 
   key.decl = CONST_CAST2 (tree, const_tree, decl);
 
-  slot = (symtab_node *) htab_find_slot (symtab_hash, &key,
+  slot = (symtab_node **) htab_find_slot (symtab_hash, &key,
 					 NO_INSERT);
 
   if (slot)
@@ -321,7 +321,7 @@ symtab_get_node (const_tree decl)
 /* Remove symtab NODE from the symbol table.  */
 
 void
-symtab_remove_node (symtab_node node)
+symtab_remove_node (symtab_node *node)
 {
   if (cgraph_node *cnode = dyn_cast <cgraph_node> (node))
     cgraph_remove_node (cnode);
@@ -334,7 +334,7 @@ symtab_remove_node (symtab_node node)
 void
 symtab_initialize_asm_name_hash (void)
 {
-  symtab_node node;
+  symtab_node *node;
   if (!assembler_name_hash)
     {
       assembler_name_hash =
@@ -348,10 +348,10 @@ symtab_initialize_asm_name_hash (void)
 /* Return the cgraph node that has ASMNAME for its DECL_ASSEMBLER_NAME.
    Return NULL if there's no such node.  */
 
-symtab_node
+symtab_node *
 symtab_node_for_asm (const_tree asmname)
 {
-  symtab_node node;
+  symtab_node *node;
   void **slot;
 
   symtab_initialize_asm_name_hash ();
@@ -361,7 +361,7 @@ symtab_node_for_asm (const_tree asmname)
 
   if (slot)
     {
-      node = (symtab_node) *slot;
+      node = (symtab_node *) *slot;
       return node;
     }
   return NULL;
@@ -372,7 +372,7 @@ symtab_node_for_asm (const_tree asmname)
 void
 change_decl_assembler_name (tree decl, tree name)
 {
-  symtab_node node = NULL;
+  symtab_node *node = NULL;
 
   /* We can have user ASM names on things, like global register variables, that
      are not in the symbol table.  */
@@ -414,8 +414,8 @@ change_decl_assembler_name (tree decl, tree name)
 /* Add NEW_ to the same comdat group that OLD is in.  */
 
 void
-symtab_add_to_same_comdat_group (symtab_node new_node,
-				 symtab_node old_node)
+symtab_add_to_same_comdat_group (symtab_node *new_node,
+				 symtab_node *old_node)
 {
   gcc_assert (DECL_ONE_ONLY (old_node->decl));
   gcc_assert (!new_node->same_comdat_group);
@@ -427,7 +427,7 @@ symtab_add_to_same_comdat_group (symtab_node new_node,
     old_node->same_comdat_group = new_node;
   else
     {
-      symtab_node n;
+      symtab_node *n;
       for (n = old_node->same_comdat_group;
 	   n->same_comdat_group != old_node;
 	   n = n->same_comdat_group)
@@ -439,10 +439,10 @@ symtab_add_to_same_comdat_group (symtab_node new_node,
 /* Dissolve the same_comdat_group list in which NODE resides.  */
 
 void
-symtab_dissolve_same_comdat_group_list (symtab_node node)
+symtab_dissolve_same_comdat_group_list (symtab_node *node)
 {
-  symtab_node n = node;
-  symtab_node next;
+  symtab_node *n = node;
+  symtab_node *next;
 
   if (!node->same_comdat_group)
     return;
@@ -460,7 +460,7 @@ symtab_dissolve_same_comdat_group_list (symtab_node node)
    is unknown go with identifier name.  */
 
 const char *
-symtab_node_asm_name (symtab_node node)
+symtab_node_asm_name (symtab_node *node)
 {
   if (!DECL_ASSEMBLER_NAME_SET_P (node->decl))
     return lang_hooks.decl_printable_name (node->decl, 2);
@@ -470,7 +470,7 @@ symtab_node_asm_name (symtab_node node)
 /* Return printable identifier name.  */
 
 const char *
-symtab_node_name (symtab_node node)
+symtab_node_name (symtab_node *node)
 {
   return lang_hooks.decl_printable_name (node->decl, 2);
 }
@@ -480,7 +480,7 @@ static const char * const symtab_type_names[] = {"symbol", "function", "variable
 /* Dump base fields of symtab nodes.  Not to be used directly.  */
 
 void
-dump_symtab_base (FILE *f, symtab_node node)
+dump_symtab_base (FILE *f, symtab_node *node)
 {
   static const char * const visibility_types[] = {
     "default", "protected", "hidden", "internal"
@@ -594,7 +594,7 @@ dump_symtab_base (FILE *f, symtab_node node)
 /* Dump symtab node.  */
 
 void
-dump_symtab_node (FILE *f, symtab_node node)
+dump_symtab_node (FILE *f, symtab_node *node)
 {
   if (cgraph_node *cnode = dyn_cast <cgraph_node> (node))
     dump_cgraph_node (f, cnode);
@@ -607,7 +607,7 @@ dump_symtab_node (FILE *f, symtab_node node)
 void
 dump_symtab (FILE *f)
 {
-  symtab_node node;
+  symtab_node *node;
   fprintf (f, "Symbol table:\n\n");
   FOR_EACH_SYMBOL (node)
     dump_symtab_node (f, node);
@@ -616,7 +616,7 @@ dump_symtab (FILE *f)
 /* Dump symtab node NODE to stderr.  */
 
 DEBUG_FUNCTION void
-debug_symtab_node (symtab_node node)
+debug_symtab_node (symtab_node *node)
 {
   dump_symtab_node (stderr, node);
 }
@@ -632,10 +632,10 @@ debug_symtab (void)
 /* Verify common part of symtab nodes.  */
 
 DEBUG_FUNCTION bool
-verify_symtab_base (symtab_node node)
+verify_symtab_base (symtab_node *node)
 {
   bool error_found = false;
-  symtab_node hashed_node;
+  symtab_node *hashed_node;
 
   if (is_a <cgraph_node> (node))
     {
@@ -728,7 +728,7 @@ verify_symtab_base (symtab_node node)
     }
   if (node->same_comdat_group)
     {
-      symtab_node n = node->same_comdat_group;
+      symtab_node *n = node->same_comdat_group;
 
       if (!DECL_ONE_ONLY (n->decl))
 	{
@@ -763,7 +763,7 @@ verify_symtab_base (symtab_node node)
 /* Verify consistency of NODE.  */
 
 DEBUG_FUNCTION void
-verify_symtab_node (symtab_node node)
+verify_symtab_node (symtab_node *node)
 {
   if (seen_error ())
     return;
@@ -785,7 +785,7 @@ verify_symtab_node (symtab_node node)
 DEBUG_FUNCTION void
 verify_symtab (void)
 {
-  symtab_node node;
+  symtab_node *node;
   FOR_EACH_SYMBOL (node)
    verify_symtab_node (node);
 }
@@ -806,7 +806,7 @@ resolution_used_from_other_file_p (enum ld_plugin_symbol_resolution resolution)
    Known only when doing LTO via linker plugin.  */
 
 bool
-symtab_used_from_object_file_p (symtab_node node)
+symtab_used_from_object_file_p (symtab_node *node)
 {
   if (!TREE_PUBLIC (node->decl) || DECL_EXTERNAL (node->decl))
     return false;
@@ -858,7 +858,7 @@ symtab_make_decl_local (tree decl)
 /* Return availability of NODE.  */
 
 enum availability
-symtab_node_availability (symtab_node node)
+symtab_node_availability (symtab_node *node)
 {
   if (is_a <cgraph_node> (node))
     return cgraph_function_body_availability (cgraph (node));
@@ -870,8 +870,8 @@ symtab_node_availability (symtab_node node)
    If NODE is not an alias, return NODE.
    When AVAILABILITY is non-NULL, get minimal availability in the chain.  */
 
-symtab_node
-symtab_alias_ultimate_target (symtab_node node, enum availability *availability)
+symtab_node *
+symtab_alias_ultimate_target (symtab_node *node, enum availability *availability)
 {
   bool weakref_p = false;
 
@@ -946,7 +946,7 @@ symtab_alias_ultimate_target (symtab_node node, enum availability *availability)
    copy the visibility from the target to get things right.  */
 
 void
-fixup_same_cpp_alias_visibility (symtab_node node, symtab_node target)
+fixup_same_cpp_alias_visibility (symtab_node *node, symtab_node *target)
 {
   if (is_a <cgraph_node> (node))
     {
@@ -982,9 +982,9 @@ fixup_same_cpp_alias_visibility (symtab_node node, symtab_node target)
    it returns false.  */
 
 bool
-symtab_resolve_alias (symtab_node node, symtab_node target)
+symtab_resolve_alias (symtab_node *node, symtab_node *target)
 {
-  symtab_node n;
+  symtab_node *n;
 
   gcc_assert (!node->analyzed
 	      && !vec_safe_length (node->ref_list.references));
@@ -1030,8 +1030,8 @@ symtab_resolve_alias (symtab_node node, symtab_node target)
    skipped. */
 
 bool
-symtab_for_node_and_aliases (symtab_node node,
-			     bool (*callback) (symtab_node, void *),
+symtab_for_node_and_aliases (symtab_node *node,
+			     bool (*callback) (symtab_node *, void *),
 			     void *data,
 			     bool include_overwritable)
 {
@@ -1043,7 +1043,7 @@ symtab_for_node_and_aliases (symtab_node node,
   for (i = 0; ipa_ref_list_referring_iterate (&node->ref_list, i, ref); i++)
     if (ref->use == IPA_REF_ALIAS)
       {
-	symtab_node alias = ref->referring;
+	symtab_node *alias = ref->referring;
 	if (include_overwritable
 	    || symtab_node_availability (alias) > AVAIL_OVERWRITABLE)
           if (symtab_for_node_and_aliases (alias, callback, data,
@@ -1056,11 +1056,11 @@ symtab_for_node_and_aliases (symtab_node node,
 /* Worker searching nonoverwritable alias.  */
 
 static bool
-symtab_nonoverwritable_alias_1 (symtab_node node, void *data)
+symtab_nonoverwritable_alias_1 (symtab_node *node, void *data)
 {
   if (decl_binds_to_current_def_p (node->decl))
     {
-      *(symtab_node *)data = node;
+      *(symtab_node **)data = node;
       return true;
     }
   return false;
@@ -1070,11 +1070,11 @@ symtab_nonoverwritable_alias_1 (symtab_node node, void *data)
    definition, return NODE. Otherwise look for alias with such property and if
    none exists, introduce new one.  */
 
-symtab_node
-symtab_nonoverwritable_alias (symtab_node node)
+symtab_node *
+symtab_nonoverwritable_alias (symtab_node *node)
 {
   tree new_decl;
-  symtab_node new_node = NULL;
+  symtab_node *new_node = NULL;
 
   /* First try to look up existing alias or base object
      (if that is already non-overwritable).  */
@@ -1121,12 +1121,12 @@ symtab_nonoverwritable_alias (symtab_node node)
 /* Return true if A and B represents semantically equivalent symbols.  */
 
 bool
-symtab_semantically_equivalent_p (symtab_node a,
-				  symtab_node b)
+symtab_semantically_equivalent_p (symtab_node *a,
+				  symtab_node *b)
 {
   enum availability avail;
-  symtab_node ba;
-  symtab_node bb;
+  symtab_node *ba;
+  symtab_node *bb;
 
   /* Equivalent functions are equivalent.  */
   if (a->decl == b->decl)
diff --git a/gcc/value-prof.c b/gcc/value-prof.c
index 75692c0..18360e5 100644
--- a/gcc/value-prof.c
+++ b/gcc/value-prof.c
@@ -1205,8 +1205,8 @@ init_node_map (bool local)
 			   n->profile_id,
 			   cgraph_node_name (n),
 			   n->order,
-			   symtab_node_name (*(symtab_node*)val),
-			   (*(symtab_node *)val)->order);
+			   symtab_node_name (*(symtab_node **)val),
+			   (*(symtab_node **)val)->order);
 		n->profile_id = (n->profile_id + 1) & 0x7fffffff;
 	      }
 	  }
diff --git a/gcc/varasm.c b/gcc/varasm.c
index a624851..e976c5c 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -5400,7 +5400,7 @@ weak_finish_1 (tree decl)
 static tree
 find_decl (tree target)
 {
-  symtab_node node = symtab_node_for_asm (target);
+  symtab_node *node = symtab_node_for_asm (target);
   if (node)
     return node->decl;
   return NULL_TREE;
diff --git a/gcc/varpool.c b/gcc/varpool.c
index e14c811..f847577 100644
--- a/gcc/varpool.c
+++ b/gcc/varpool.c
@@ -140,7 +140,7 @@ debug_varpool (void)
 struct varpool_node *
 varpool_node_for_asm (tree asmname)
 {
-  if (symtab_node node = symtab_node_for_asm (asmname))
+  if (symtab_node *node = symtab_node_for_asm (asmname))
     return dyn_cast <varpool_node> (node);
   else
     return NULL;
@@ -417,7 +417,7 @@ varpool_remove_unreferenced_decls (void)
 
       if (node->same_comdat_group)
 	{
-	  symtab_node next;
+	  symtab_node *next;
 	  for (next = node->same_comdat_group;
 	       next != node;
 	       next = next->same_comdat_group)
-- 
1.7.11.7

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v2 1/6] Convert symtab, cgraph and varpool nodes into a real class hierarchy
  2013-09-09 19:33     ` [PATCH v2 1/6] Convert symtab, cgraph and varpool nodes into a real class hierarchy David Malcolm
@ 2013-09-10  9:14       ` Richard Biener
  2013-09-10 13:36       ` Jan Hubicka
  1 sibling, 0 replies; 39+ messages in thread
From: Richard Biener @ 2013-09-10  9:14 UTC (permalink / raw)
  To: David Malcolm; +Cc: GCC Patches, Jan Hubicka

On Mon, Sep 9, 2013 at 9:32 PM, David Malcolm <dmalcolm@redhat.com> wrote:
> This patch is the handwritten part of the conversion of these types
> to C++; it requires the followup patch, which is autogenerated.
>
> It converts:
>   struct GTY(()) symtab_node_base
> to:
>   class GTY((user)) symtab_node_base
>
> and converts:
>   struct GTY(()) cgraph_node
> to:
>   struct GTY((user)) cgraph_node : public symtab_node_base
>
> and:
>   struct GTY(()) varpool_node
> to:
>   class GTY((user)) varpool_node : public symtab_node_base
>
> dropping the symtab_node_def union.
>
> Since gengtype is unable to cope with inheritance, we have to mark the
> types with GTY((user)), and handcode the gty field-visiting functions.
> Given the simple hierarchy, we don't need virtual functions for this.
>
> Unfortunately doing so runs into various bugs in gengtype's handling
> of GTY((user)), so the patch also includes workarounds for these bugs.
>
> gengtype walks the graph of the *types* in the code, and produces
> functions in gtype-desc.[ch] for all types that are reachable from a
> GTY root.
>
> However, it ignores the contents of GTY((user)) types when walking
> this graph.
>
> Hence if you have a subgraph of types that are only reachable
> via fields in GTY((user)) types, gengtype won't generate helper code
> for those types.

In this case, which are the types not processed and which are the
helpers that are missing?

> Ideally there would be some way to mark a GTY((user)) type to say
> which types it references, to avoid having to mark these types as
> GTY((user)).

All types that are supposed to be tracked by gengtype need to be
marked with GTY(()) in their definition.  So maybe we are simply
missing such annotations?

Richard.

> For now, work around this issue by providing explicit roots of the
> missing types, of dummy variables (see the bottom of cgraph.c)
>
> gcc/
>
>         * cgraph.c (gt_ggc_mx): New.
>         (gt_pch_nx (symtab_node_base *)): New.
>         (gt_pch_nx (symtab_node_base *, gt_pointer_operator, void *)): New.
>         (dummy_call_site_hash): New.
>         (dummy_ipa_ref_list): New.
>         (dummy_cgraph_clone_info): New.
>         (dummy_ipa_replace_map_pointer): New.
>         (dummy_varpool_node_ptr): New.
>
>         * cgraph.h (symtab_node_base): Convert to a class;
>         add GTY((user)).
>         (gt_ggc_mx): New.
>         (gt_pch_nx (symtab_node_base *p)): New.
>         (gt_pch_nx (symtab_node_base *p, gt_pointer_operator op,
>         void *cookie)): New.
>         (cgraph_node): Inherit from symtab_node; convert to GTY((user)).
>         (varpool_node): Likewise.
>         (symtab_node_def): Remove.
>         (is_a_helper <cgraph_node>::test (symtab_node_def *)): Convert to...
>         (is_a_helper <cgraph_node>::test (symtab_node_base *)): ...this.
>         (is_a_helper <varpool_node>::test (symtab_node_def *)): Convert to...
>         (is_a_helper <varpool_node>::test (symtab_node_base *)): ...this.
>
>         * ipa-ref.h (symtab_node_def): Drop.
>         (symtab_node): Change underlying type from symtab_node_def to
>         symtab_node_base.
>         (const_symtab_node): Likwise.
>
>         * is-a.h: Update examples in comment.
>
>         * symtab.c (symtab_hash): Change symtab_node_def to symtab_node_base.
>         (assembler_name_hash): Likewise.
> ---
>  gcc/cgraph.c  | 218 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  gcc/cgraph.h  |  48 ++++++-------
>  gcc/ipa-ref.h |   6 +-
>  gcc/is-a.h    |   6 +-
>  gcc/symtab.c  |   4 +-
>  5 files changed, 247 insertions(+), 35 deletions(-)
>
> diff --git a/gcc/cgraph.c b/gcc/cgraph.c
> index f12bf1b..4b12163 100644
> --- a/gcc/cgraph.c
> +++ b/gcc/cgraph.c
> @@ -2994,4 +2994,222 @@ cgraph_get_body (struct cgraph_node *node)
>    return true;
>  }
>
> +/* GTY((user)) hooks for symtab_node_base (and its subclasses).
> +   We could use virtual functions for this, but given the presence of the
> +   "type" field and the trivial size of the class hierarchy, switches are
> +   perhaps simpler and faster.  */
> +
> +void gt_ggc_mx (symtab_node_base *x)
> +{
> +  /* Hand-written equivalent of the chain_next/chain_prev machinery, to
> +     avoid deep call-stacks.
> +
> +     Locate the neighbors of x (within the linked-list) that haven't been
> +     marked yet, so that x through xlimit give a range suitable for marking.
> +     Note that x (on entry) itself has already been marked by the
> +     gtype-desc.c code, so we first try its successor.
> +  */
> +  symtab_node_base * xlimit = x ? x->next : NULL;
> +  while (ggc_test_and_set_mark (xlimit))
> +   xlimit = xlimit->next;
> +  if (x != xlimit)
> +    for (;;)
> +      {
> +        symtab_node_base * const xprev = x->previous;
> +        if (xprev == NULL) break;
> +        x = xprev;
> +        (void) ggc_test_and_set_mark (xprev);
> +      }
> +  while (x != xlimit)
> +    {
> +      /* Code common to all symtab nodes. */
> +      gt_ggc_m_9tree_node (x->decl);
> +      gt_ggc_mx_symtab_node_base (x->next);
> +      gt_ggc_mx_symtab_node_base (x->previous);
> +      gt_ggc_mx_symtab_node_base (x->next_sharing_asm_name);
> +      gt_ggc_mx_symtab_node_base (x->previous_sharing_asm_name);
> +      gt_ggc_mx_symtab_node_base (x->same_comdat_group);
> +      gt_ggc_m_20vec_ipa_ref_t_va_gc_ (x->ref_list.references);
> +      gt_ggc_m_9tree_node (x->alias_target);
> +      gt_ggc_m_18lto_file_decl_data (x->lto_file_data);
> +
> +      /* Extra code, per subclass. */
> +      switch (x->type)
> +        {
> +        case SYMTAB_FUNCTION:
> +          {
> +            cgraph_node *cgn = static_cast <cgraph_node *> (x);
> +            gt_ggc_m_11cgraph_edge (cgn->callees);
> +            gt_ggc_m_11cgraph_edge (cgn->callers);
> +            gt_ggc_m_11cgraph_edge (cgn->indirect_calls);
> +            gt_ggc_m_11cgraph_node (cgn->origin);
> +            gt_ggc_m_11cgraph_node (cgn->nested);
> +            gt_ggc_m_11cgraph_node (cgn->next_nested);
> +            gt_ggc_m_11cgraph_node (cgn->next_sibling_clone);
> +            gt_ggc_m_11cgraph_node (cgn->prev_sibling_clone);
> +            gt_ggc_m_11cgraph_node (cgn->clones);
> +            gt_ggc_m_11cgraph_node (cgn->clone_of);
> +            gt_ggc_m_P11cgraph_edge4htab (cgn->call_site_hash);
> +            gt_ggc_m_9tree_node (cgn->former_clone_of);
> +            gt_ggc_m_11cgraph_node (cgn->global.inlined_to);
> +            gt_ggc_m_28vec_ipa_replace_map_p_va_gc_ (cgn->clone.tree_map);
> +            gt_ggc_m_15bitmap_head_def (cgn->clone.args_to_skip);
> +            gt_ggc_m_15bitmap_head_def (cgn->clone.combined_args_to_skip);
> +            gt_ggc_m_9tree_node (cgn->thunk.alias);
> +          }
> +          break;
> +        default:
> +          break;
> +        }
> +      x = x->next;
> +    }
> +}
> +
> +void gt_pch_nx (symtab_node_base *x)
> +{
> +  symtab_node_base * xlimit = x ? x->next : NULL;
> +  while (gt_pch_note_object (xlimit, xlimit, gt_pch_p_16symtab_node_base))
> +   xlimit = xlimit->next;
> +  if (x != xlimit)
> +    for (;;)
> +      {
> +        symtab_node_base * const xprev = x->previous;
> +        if (xprev == NULL) break;
> +        x = xprev;
> +        (void) gt_pch_note_object (xprev, xprev,
> +                                   gt_pch_p_16symtab_node_base);
> +      }
> +  while (x != xlimit)
> +    {
> +      /* Code common to all symtab nodes. */
> +      gt_pch_n_9tree_node (x->decl);
> +      gt_pch_nx_symtab_node_base (x->next);
> +      gt_pch_nx_symtab_node_base (x->previous);
> +      gt_pch_nx_symtab_node_base (x->next_sharing_asm_name);
> +      gt_pch_nx_symtab_node_base (x->previous_sharing_asm_name);
> +      gt_pch_nx_symtab_node_base (x->same_comdat_group);
> +      gt_pch_n_20vec_ipa_ref_t_va_gc_ (x->ref_list.references);
> +      gt_pch_n_9tree_node (x->alias_target);
> +      gt_pch_n_18lto_file_decl_data (x->lto_file_data);
> +
> +      /* Extra code, per subclass. */
> +      switch (x->type)
> +        {
> +        case SYMTAB_FUNCTION:
> +          {
> +            cgraph_node *cgn = static_cast <cgraph_node *> (x);
> +            gt_pch_n_11cgraph_edge (cgn->callees);
> +            gt_pch_n_11cgraph_edge (cgn->callers);
> +            gt_pch_n_11cgraph_edge (cgn->indirect_calls);
> +            gt_pch_n_11cgraph_node (cgn->origin);
> +            gt_pch_n_11cgraph_node (cgn->nested);
> +            gt_pch_n_11cgraph_node (cgn->next_nested);
> +            gt_pch_n_11cgraph_node (cgn->next_sibling_clone);
> +            gt_pch_n_11cgraph_node (cgn->prev_sibling_clone);
> +            gt_pch_n_11cgraph_node (cgn->clones);
> +            gt_pch_n_11cgraph_node (cgn->clone_of);
> +            gt_pch_n_P11cgraph_edge4htab (cgn->call_site_hash);
> +            gt_pch_n_9tree_node (cgn->former_clone_of);
> +            gt_pch_n_11cgraph_node (cgn->global.inlined_to);
> +            gt_pch_n_28vec_ipa_replace_map_p_va_gc_ (cgn->clone.tree_map);
> +            gt_pch_n_15bitmap_head_def (cgn->clone.args_to_skip);
> +            gt_pch_n_15bitmap_head_def (cgn->clone.combined_args_to_skip);
> +            gt_pch_n_9tree_node (cgn->thunk.alias);
> +          }
> +          break;
> +        default:
> +          break;
> +        }
> +      x = x->next;
> +    }
> +}
> +
> +void gt_pch_nx (symtab_node_base *p, gt_pointer_operator op, void *cookie)
> +{
> +  /* Code common to all symtab nodes. */
> +  op (&(p->decl), cookie);
> +  op (&(p->next), cookie);
> +  op (&(p->previous), cookie);
> +  op (&(p->next_sharing_asm_name), cookie);
> +  op (&(p->previous_sharing_asm_name), cookie);
> +  op (&(p->same_comdat_group), cookie);
> +  op (&(p->ref_list.references), cookie);
> +  op (&(p->alias_target), cookie);
> +  op (&(p->lto_file_data), cookie);
> +
> +  /* Extra code, per subclass. */
> +  switch (p->type)
> +    {
> +    case SYMTAB_FUNCTION:
> +      {
> +        cgraph_node *cgn = static_cast <cgraph_node *> (p);
> +        op (&(cgn->callees), cookie);
> +        op (&(cgn->callers), cookie);
> +        op (&(cgn->indirect_calls), cookie);
> +        op (&(cgn->origin), cookie);
> +        op (&(cgn->nested), cookie);
> +        op (&(cgn->next_nested), cookie);
> +        op (&(cgn->next_sibling_clone), cookie);
> +        op (&(cgn->prev_sibling_clone), cookie);
> +        op (&(cgn->clones), cookie);
> +        op (&(cgn->clone_of), cookie);
> +        op (&(cgn->call_site_hash), cookie);
> +        op (&(cgn->former_clone_of), cookie);
> +        op (&(cgn->global.inlined_to), cookie);
> +        op (&(cgn->clone.tree_map), cookie);
> +        op (&(cgn->clone.args_to_skip), cookie);
> +        op (&(cgn->clone.combined_args_to_skip), cookie);
> +        op (&(cgn->thunk.alias), cookie);
> +      }
> +      break;
> +    default:
> +      break;
> +    }
> +}
> +
> +/* Workarounds for deficiencies in gengtype's handling of GTY((user)).
> +
> +   gengtype walks the graph of the *types* in the code, and produces
> +   functions in gtype-desc.[ch] for all types that are reachable from a
> +   GTY root.
> +
> +   However, it ignores the contents of GTY((user)) types when walking
> +   this graph.
> +
> +   Hence if you have a subgraph of types that are only reachable
> +   via fields in GTY((user)) types, gengtype won't generate helper code
> +   for those types.
> +
> +   Ideally there would be some way to mark a GTY((user)) type to say
> +   which types it references, to avoid having to mark these types as
> +   GTY((user)).
> +
> +   For now, work around this issue by providing explicit roots of the
> +   missing types, of dummy variables.  */
> +
> +/* Force gengtype into providing GTY hooks for the type of this field:
> +     htab_t GTY((param_is (struct cgraph_edge))) call_site_hash;
> +   within cgraph_node.  */
> +static GTY(()) htab_t GTY((param_is (struct cgraph_edge))) dummy_call_site_hash;
> +
> +/* Similarly for this field of symtab_node_base:
> +     struct ipa_ref_list ref_list;
> + */
> +static GTY((deletable)) struct ipa_ref_list *dummy_ipa_ref_list;
> +
> +/* Similarly for this field of cgraph_node:
> +     struct cgraph_clone_info clone;
> +*/
> +static GTY((deletable)) struct cgraph_clone_info *dummy_cgraph_clone_info;
> +
> +/* Non-existent pointer, to trick gengtype into (correctly) realizing that
> +   ipa_replace_map is indeed used in the code, and thus should have ggc_alloc_*
> +   routines.  */
> +static GTY((deletable)) struct ipa_replace_map *dummy_ipa_replace_map_pointer;
> +
> +/* Non-existent pointer, to trick gengtype into (correctly) realizing that
> +   varpool_node is indeed used in the code, and thus should have ggc_alloc_*
> +   routines.  */
> +static GTY((deletable)) varpool_node *dummy_varpool_node_ptr;
> +
>  #include "gt-cgraph.h"
> diff --git a/gcc/cgraph.h b/gcc/cgraph.h
> index 5a7a949..2bd2dc4 100644
> --- a/gcc/cgraph.h
> +++ b/gcc/cgraph.h
> @@ -40,8 +40,9 @@ enum symtab_type
>
>  /* Base of all entries in the symbol table.
>     The symtab_node is inherited by cgraph and varpol nodes.  */
> -struct GTY(()) symtab_node_base
> +class GTY((user)) symtab_node_base
>  {
> +public:
>    /* Type of the symbol.  */
>    ENUM_BITFIELD (symtab_type) type : 8;
>
> @@ -143,6 +144,16 @@ struct GTY(()) symtab_node_base
>    PTR GTY ((skip)) aux;
>  };
>
> +/* These user-provided hooks are called by code in gtype-desc.c
> +   autogenerated by gengtype.c.
> +
> +   They are called the first time that the given object is visited
> +   within a GC/PCH traversal.
> +*/
> +extern void gt_ggc_mx (symtab_node_base *p);
> +extern void gt_pch_nx (symtab_node_base *p);
> +extern void gt_pch_nx (symtab_node_base *p, gt_pointer_operator op, void *cookie);
> +
>  enum availability
>  {
>    /* Not yet set by cgraph_function_body_availability.  */
> @@ -252,25 +263,19 @@ struct GTY(()) cgraph_clone_info
>  /* The cgraph data structure.
>     Each function decl has assigned cgraph_node listing callees and callers.  */
>
> -struct GTY(()) cgraph_node {
> -  struct symtab_node_base symbol;
> +struct GTY((user)) cgraph_node : public symtab_node_base {
> +public:
>    struct cgraph_edge *callees;
>    struct cgraph_edge *callers;
>    /* List of edges representing indirect calls with a yet undetermined
>       callee.  */
>    struct cgraph_edge *indirect_calls;
>    /* For nested functions points to function the node is nested in.  */
> -  struct cgraph_node *
> -    GTY ((nested_ptr (union symtab_node_def, "(struct cgraph_node *)(%h)", "(symtab_node)%h")))
> -    origin;
> +  struct cgraph_node *origin;
>    /* Points to first nested function, if any.  */
> -  struct cgraph_node *
> -    GTY ((nested_ptr (union symtab_node_def, "(struct cgraph_node *)(%h)", "(symtab_node)%h")))
> -    nested;
> +  struct cgraph_node *nested;
>    /* Pointer to the next function with same origin, if any.  */
> -  struct cgraph_node *
> -    GTY ((nested_ptr (union symtab_node_def, "(struct cgraph_node *)(%h)", "(symtab_node)%h")))
> -    next_nested;
> +  struct cgraph_node *next_nested;
>    /* Pointer to the next clone.  */
>    struct cgraph_node *next_sibling_clone;
>    struct cgraph_node *prev_sibling_clone;
> @@ -518,9 +523,8 @@ typedef struct cgraph_edge *cgraph_edge_p;
>  /* The varpool data structure.
>     Each static variable decl has assigned varpool_node.  */
>
> -struct GTY(()) varpool_node {
> -  struct symtab_node_base symbol;
> -
> +class GTY((user)) varpool_node : public symtab_node_base {
> +public:
>    /* Set when variable is scheduled to be assembled.  */
>    unsigned output : 1;
>  };
> @@ -536,22 +540,12 @@ struct GTY(()) asm_node {
>    int order;
>  };
>
> -/* Symbol table entry.  */
> -union GTY((desc ("%h.symbol.type"), chain_next ("%h.symbol.next"),
> -          chain_prev ("%h.symbol.previous"))) symtab_node_def {
> -  struct symtab_node_base GTY ((tag ("SYMTAB_SYMBOL"))) symbol;
> -  /* To access the following fields,
> -     use the use dyn_cast or as_a to obtain the concrete type.  */
> -  struct cgraph_node GTY ((tag ("SYMTAB_FUNCTION"))) x_function;
> -  struct varpool_node GTY ((tag ("SYMTAB_VARIABLE"))) x_variable;
> -};
> -
>  /* Report whether or not THIS symtab node is a function, aka cgraph_node.  */
>
>  template <>
>  template <>
>  inline bool
> -is_a_helper <cgraph_node>::test (symtab_node_def *p)
> +is_a_helper <cgraph_node>::test (symtab_node_base *p)
>  {
>    return p->symbol.type == SYMTAB_FUNCTION;
>  }
> @@ -561,7 +555,7 @@ is_a_helper <cgraph_node>::test (symtab_node_def *p)
>  template <>
>  template <>
>  inline bool
> -is_a_helper <varpool_node>::test (symtab_node_def *p)
> +is_a_helper <varpool_node>::test (symtab_node_base *p)
>  {
>    return p->symbol.type == SYMTAB_VARIABLE;
>  }
> diff --git a/gcc/ipa-ref.h b/gcc/ipa-ref.h
> index e0553bb..dc6e238 100644
> --- a/gcc/ipa-ref.h
> +++ b/gcc/ipa-ref.h
> @@ -20,9 +20,9 @@ along with GCC; see the file COPYING3.  If not see
>
>  struct cgraph_node;
>  struct varpool_node;
> -union symtab_node_def;
> -typedef union symtab_node_def *symtab_node;
> -typedef const union symtab_node_def *const_symtab_node;
> +class symtab_node_base;
> +typedef symtab_node_base *symtab_node;
> +typedef const symtab_node_base *const_symtab_node;
>
>
>  /* How the reference is done.  */
> diff --git a/gcc/is-a.h b/gcc/is-a.h
> index b5ee854..ccf12be 100644
> --- a/gcc/is-a.h
> +++ b/gcc/is-a.h
> @@ -31,7 +31,7 @@ bool is_a <TYPE> (pointer)
>
>      Tests whether the pointer actually points to a more derived TYPE.
>
> -    Suppose you have a symtab_node_def *ptr, AKA symtab_node ptr.  You can test
> +    Suppose you have a symtab_node_base *ptr, AKA symtab_node ptr.  You can test
>      whether it points to a 'derived' cgraph_node as follows.
>
>        if (is_a <cgraph_node> (ptr))
> @@ -110,7 +110,7 @@ example,
>    template <>
>    template <>
>    inline bool
> -  is_a_helper <cgraph_node>::test (symtab_node_def *p)
> +  is_a_helper <cgraph_node>::test (symtab_node_base *p)
>    {
>      return p->symbol.type == SYMTAB_FUNCTION;
>    }
> @@ -122,7 +122,7 @@ when needed may result in a crash.  For example,
>    template <>
>    template <>
>    inline bool
> -  is_a_helper <cgraph_node>::cast (symtab_node_def *p)
> +  is_a_helper <cgraph_node>::cast (symtab_node_base *p)
>    {
>      return &p->x_function;
>    }
> diff --git a/gcc/symtab.c b/gcc/symtab.c
> index 8dc61d0..adc7c90 100644
> --- a/gcc/symtab.c
> +++ b/gcc/symtab.c
> @@ -48,9 +48,9 @@ const char * const ld_plugin_symbol_resolution_names[]=
>  };
>
>  /* Hash table used to convert declarations into nodes.  */
> -static GTY((param_is (union symtab_node_def))) htab_t symtab_hash;
> +static GTY((param_is (symtab_node_base))) htab_t symtab_hash;
>  /* Hash table used to convert assembler names into nodes.  */
> -static GTY((param_is (union symtab_node_def))) htab_t assembler_name_hash;
> +static GTY((param_is (symtab_node_base))) htab_t assembler_name_hash;
>
>  /* Linked list of symbol table nodes.  */
>  symtab_node symtab_nodes;
> --
> 1.7.11.7
>

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v2 0/6] Port symtab/cgraph/varpool nodes to use C++ inheritance; rename types.
  2013-09-09 19:32   ` [PATCH v2 0/6] Port symtab/cgraph/varpool nodes to use C++ inheritance; rename types David Malcolm
                       ` (5 preceding siblings ...)
  2013-09-09 20:49     ` [PATCH v2 5/6] Automated renaming of symtab types David Malcolm
@ 2013-09-10 13:04     ` Jan Hubicka
  2013-09-11  1:34       ` David Malcolm
  6 siblings, 1 reply; 39+ messages in thread
From: Jan Hubicka @ 2013-09-10 13:04 UTC (permalink / raw)
  To: David Malcolm; +Cc: gcc-patches, Jan Hubicka

> Here's version 2 of this patch series.
> 
> This is now 6 patches.
> 
> The first two patches correspond to the two patches from the original
> patch series (and must both be applied together to make sense).  They
> convert cgraph_node and varpool_node to inherit from symtab_node_base,
> eliminating union symtab_node_def, and the "symbol" fields at the
> top of the two subclasses.
> 
> Specifically:
> 
>   * Patch 1 of 6 is the hand-written part of the conversion to a C++
>     inheritance hierarchy, plus various workarounds for dealing with
>     issues in how gengtype handles GTY((user)).  It corresponds to
>     "patch 1/2" in the original patch series.  It is largely unchanged
>     from the previous submission.
> 
>   * Patch 2 of 6 is the automated part of the conversion to C++
>     inheritance, corresponding to "patch 2/2" in the original series.
>     The main improvement is that the script now removes casts to
>     (symtab_node) where these are unnecessary i.e. almost all of them,
>     apart from a few that I whitelisted.  See refactor_symtab.py
>     within https://github.com/davidmalcolm/gcc-refactoring-scripts for
>     details.
> 
> The remaining 4 patches rename some types:
> 
> "symtab_node_base" becomes "symtab_node" (Honza's preferred name, AIUI).
> 
> This would clash with the pre-existing "symtab_node", which was a
> typedef for:
>   union symtab_node_def *
> before patch 1, and for:
>   symtab_node_base *
> after it.
> 
> So we eliminate this typedef, and all uses become simply a
> "symtab_node *", which is the bulk of the renaming.  There is also
> a "const_symtab_node" typedef, which is eliminated; all uses become
> simply a "const symtab_node *".

yes, having symtab_node * and then cgraph_node */varpool_node * that will
later renamed to something like function_node/variable_node seems fine.
We can also drop _node and make it symbol that would be more descriptive.

Honza

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v2 1/6] Convert symtab, cgraph and varpool nodes into a real class hierarchy
  2013-09-09 19:33     ` [PATCH v2 1/6] Convert symtab, cgraph and varpool nodes into a real class hierarchy David Malcolm
  2013-09-10  9:14       ` Richard Biener
@ 2013-09-10 13:36       ` Jan Hubicka
  2013-09-17 21:10         ` David Malcolm
  1 sibling, 1 reply; 39+ messages in thread
From: Jan Hubicka @ 2013-09-10 13:36 UTC (permalink / raw)
  To: David Malcolm; +Cc: gcc-patches, Jan Hubicka

> This patch is the handwritten part of the conversion of these types
> to C++; it requires the followup patch, which is autogenerated.
> 
> It converts:
>   struct GTY(()) symtab_node_base
> to:
>   class GTY((user)) symtab_node_base
> 
> and converts:
>   struct GTY(()) cgraph_node
> to:
>   struct GTY((user)) cgraph_node : public symtab_node_base
> 
> and:
>   struct GTY(()) varpool_node
> to:
>   class GTY((user)) varpool_node : public symtab_node_base
> 
> dropping the symtab_node_def union.
> 
> Since gengtype is unable to cope with inheritance, we have to mark the
> types with GTY((user)), and handcode the gty field-visiting functions.
> Given the simple hierarchy, we don't need virtual functions for this.
> 
> Unfortunately doing so runs into various bugs in gengtype's handling
> of GTY((user)), so the patch also includes workarounds for these bugs.
> 
> gengtype walks the graph of the *types* in the code, and produces
> functions in gtype-desc.[ch] for all types that are reachable from a
> GTY root.
> 
> However, it ignores the contents of GTY((user)) types when walking
> this graph.
> 
> Hence if you have a subgraph of types that are only reachable
> via fields in GTY((user)) types, gengtype won't generate helper code
> for those types.
> 
> Ideally there would be some way to mark a GTY((user)) type to say
> which types it references, to avoid having to mark these types as
> GTY((user)).
> 
> For now, work around this issue by providing explicit roots of the
> missing types, of dummy variables (see the bottom of cgraph.c)
> 
> gcc/
> 
> 	* cgraph.c (gt_ggc_mx): New.
> 	(gt_pch_nx (symtab_node_base *)): New.
> 	(gt_pch_nx (symtab_node_base *, gt_pointer_operator, void *)): New.
> 	(dummy_call_site_hash): New.
> 	(dummy_ipa_ref_list): New.
> 	(dummy_cgraph_clone_info): New.
> 	(dummy_ipa_replace_map_pointer): New.
> 	(dummy_varpool_node_ptr): New.
> 
> 	* cgraph.h (symtab_node_base): Convert to a class;
> 	add GTY((user)).
> 	(gt_ggc_mx): New.
> 	(gt_pch_nx (symtab_node_base *p)): New.
> 	(gt_pch_nx (symtab_node_base *p, gt_pointer_operator op,
> 	void *cookie)): New.
> 	(cgraph_node): Inherit from symtab_node; convert to GTY((user)).
> 	(varpool_node): Likewise.
> 	(symtab_node_def): Remove.
> 	(is_a_helper <cgraph_node>::test (symtab_node_def *)): Convert to...
> 	(is_a_helper <cgraph_node>::test (symtab_node_base *)): ...this.
> 	(is_a_helper <varpool_node>::test (symtab_node_def *)): Convert to...
> 	(is_a_helper <varpool_node>::test (symtab_node_base *)): ...this.
> 
> 	* ipa-ref.h (symtab_node_def): Drop.
> 	(symtab_node): Change underlying type from symtab_node_def to
> 	symtab_node_base.
> 	(const_symtab_node): Likwise.
> 
> 	* is-a.h: Update examples in comment.
> 
> 	* symtab.c (symtab_hash): Change symtab_node_def to symtab_node_base.
> 	(assembler_name_hash): Likewise.
> ---
>  gcc/cgraph.c  | 218 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  gcc/cgraph.h  |  48 ++++++-------
>  gcc/ipa-ref.h |   6 +-
>  gcc/is-a.h    |   6 +-
>  gcc/symtab.c  |   4 +-
>  5 files changed, 247 insertions(+), 35 deletions(-)
> 
> diff --git a/gcc/cgraph.c b/gcc/cgraph.c
> index f12bf1b..4b12163 100644
> --- a/gcc/cgraph.c
> +++ b/gcc/cgraph.c
> @@ -2994,4 +2994,222 @@ cgraph_get_body (struct cgraph_node *node)
>    return true;
>  }
>  
> +/* GTY((user)) hooks for symtab_node_base (and its subclasses).
> +   We could use virtual functions for this, but given the presence of the
> +   "type" field and the trivial size of the class hierarchy, switches are
> +   perhaps simpler and faster.  */
> +
> +void gt_ggc_mx (symtab_node_base *x)
> +{
> +  /* Hand-written equivalent of the chain_next/chain_prev machinery, to
> +     avoid deep call-stacks.
> +
> +     Locate the neighbors of x (within the linked-list) that haven't been
> +     marked yet, so that x through xlimit give a range suitable for marking.
> +     Note that x (on entry) itself has already been marked by the
> +     gtype-desc.c code, so we first try its successor.
> +  */
> +  symtab_node_base * xlimit = x ? x->next : NULL;
> +  while (ggc_test_and_set_mark (xlimit))
> +   xlimit = xlimit->next;
> +  if (x != xlimit)
> +    for (;;)
> +      {
> +        symtab_node_base * const xprev = x->previous;
> +        if (xprev == NULL) break;
> +        x = xprev;
> +        (void) ggc_test_and_set_mark (xprev);
> +      }
> +  while (x != xlimit)
> +    {
> +      /* Code common to all symtab nodes. */
> +      gt_ggc_m_9tree_node (x->decl);
> +      gt_ggc_mx_symtab_node_base (x->next);
Aren't you marking next twice? Once by xlimit walk and one by recursion?

> +      gt_ggc_mx_symtab_node_base (x->previous);
> +      gt_ggc_mx_symtab_node_base (x->next_sharing_asm_name);
> +      gt_ggc_mx_symtab_node_base (x->previous_sharing_asm_name);
> +      gt_ggc_mx_symtab_node_base (x->same_comdat_group);

You can skip marking these.  They only point within symbol table and
not externally.

> +      gt_ggc_m_20vec_ipa_ref_t_va_gc_ (x->ref_list.references);
> +      gt_ggc_m_9tree_node (x->alias_target);
> +      gt_ggc_m_18lto_file_decl_data (x->lto_file_data);
> +
> +      /* Extra code, per subclass. */
> +      switch (x->type)
Didn't we agreed on the is_a API?
> +        {
> +        case SYMTAB_FUNCTION:
> +          {

> +            cgraph_node *cgn = static_cast <cgraph_node *> (x);
> +            gt_ggc_m_11cgraph_edge (cgn->callees);
> +            gt_ggc_m_11cgraph_edge (cgn->callers);
> +            gt_ggc_m_11cgraph_edge (cgn->indirect_calls);
> +            gt_ggc_m_11cgraph_node (cgn->origin);
> +            gt_ggc_m_11cgraph_node (cgn->nested);
> +            gt_ggc_m_11cgraph_node (cgn->next_nested);
> +            gt_ggc_m_11cgraph_node (cgn->next_sibling_clone);
> +            gt_ggc_m_11cgraph_node (cgn->prev_sibling_clone);
> +            gt_ggc_m_11cgraph_node (cgn->clones);
> +            gt_ggc_m_11cgraph_node (cgn->clone_of);
Same as here.

> +            gt_ggc_m_P11cgraph_edge4htab (cgn->call_site_hash);
Move call site hash out of GGC rather than introducing hack.

> +            gt_ggc_m_9tree_node (cgn->former_clone_of);
> +            gt_ggc_m_11cgraph_node (cgn->global.inlined_to);
And here

> +            gt_ggc_m_28vec_ipa_replace_map_p_va_gc_ (cgn->clone.tree_map);
> +            gt_ggc_m_15bitmap_head_def (cgn->clone.args_to_skip);
> +            gt_ggc_m_15bitmap_head_def (cgn->clone.combined_args_to_skip);
> +            gt_ggc_m_9tree_node (cgn->thunk.alias);
> +          }
> +          break;
> +        default:
> +          break;
> +        }
> +      x = x->next;
> +    }
> +}
> +
> +void gt_pch_nx (symtab_node_base *x)
> +{
> +  symtab_node_base * xlimit = x ? x->next : NULL;
> +  while (gt_pch_note_object (xlimit, xlimit, gt_pch_p_16symtab_node_base))
> +   xlimit = xlimit->next;
> +  if (x != xlimit)
> +    for (;;)
> +      {
> +        symtab_node_base * const xprev = x->previous;
> +        if (xprev == NULL) break;
> +        x = xprev;
> +        (void) gt_pch_note_object (xprev, xprev,
> +                                   gt_pch_p_16symtab_node_base);
> +      }
> +  while (x != xlimit)
> +    {
> +      /* Code common to all symtab nodes. */
> +      gt_pch_n_9tree_node (x->decl);
> +      gt_pch_nx_symtab_node_base (x->next);
> +      gt_pch_nx_symtab_node_base (x->previous);
> +      gt_pch_nx_symtab_node_base (x->next_sharing_asm_name);
> +      gt_pch_nx_symtab_node_base (x->previous_sharing_asm_name);
> +      gt_pch_nx_symtab_node_base (x->same_comdat_group);
> +      gt_pch_n_20vec_ipa_ref_t_va_gc_ (x->ref_list.references);
> +      gt_pch_n_9tree_node (x->alias_target);
> +      gt_pch_n_18lto_file_decl_data (x->lto_file_data);
> +
> +      /* Extra code, per subclass. */
> +      switch (x->type)
> +        {
> +        case SYMTAB_FUNCTION:
> +          {
> +            cgraph_node *cgn = static_cast <cgraph_node *> (x);
> +            gt_pch_n_11cgraph_edge (cgn->callees);
> +            gt_pch_n_11cgraph_edge (cgn->callers);
> +            gt_pch_n_11cgraph_edge (cgn->indirect_calls);
> +            gt_pch_n_11cgraph_node (cgn->origin);
> +            gt_pch_n_11cgraph_node (cgn->nested);
> +            gt_pch_n_11cgraph_node (cgn->next_nested);
> +            gt_pch_n_11cgraph_node (cgn->next_sibling_clone);
> +            gt_pch_n_11cgraph_node (cgn->prev_sibling_clone);
> +            gt_pch_n_11cgraph_node (cgn->clones);
> +            gt_pch_n_11cgraph_node (cgn->clone_of);
> +            gt_pch_n_P11cgraph_edge4htab (cgn->call_site_hash);
> +            gt_pch_n_9tree_node (cgn->former_clone_of);
> +            gt_pch_n_11cgraph_node (cgn->global.inlined_to);
> +            gt_pch_n_28vec_ipa_replace_map_p_va_gc_ (cgn->clone.tree_map);
> +            gt_pch_n_15bitmap_head_def (cgn->clone.args_to_skip);
> +            gt_pch_n_15bitmap_head_def (cgn->clone.combined_args_to_skip);
> +            gt_pch_n_9tree_node (cgn->thunk.alias);

We can skip good part of those. Just small of those is build at PCH time. But lets do that incrementally, PCH is touchy business.

The patch is OK with those changes.  The dummy workarounds are ugly :(
Honza

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v2 2/6] Automated conversion of symtab to class hierarchy
  2013-09-09 19:32     ` [PATCH v2 2/6] Automated conversion of symtab to class hierarchy David Malcolm
@ 2013-09-10 13:37       ` Jan Hubicka
  0 siblings, 0 replies; 39+ messages in thread
From: Jan Hubicka @ 2013-09-10 13:37 UTC (permalink / raw)
  To: David Malcolm; +Cc: gcc-patches, Jan Hubicka

> This patch is 439KB in size, so to avoid mailing-list limitations I've uploaded it to:
> http://dmalcolm.fedorapeople.org/gcc/large-patches/fd607e77883b8d3f8fb7c8091d0626dbbd31b9a5-0002-Automated-conversion-of-symtab-to-class-hierarchy.patch

OK,
thanks!
Honza

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v2 3/6] Split symtab_node declarations onto multiple lines
  2013-09-09 19:32     ` [PATCH v2 3/6] Split symtab_node declarations onto multiple lines David Malcolm
@ 2013-09-10 13:38       ` Jan Hubicka
  2013-10-30 16:12         ` David Malcolm
  0 siblings, 1 reply; 39+ messages in thread
From: Jan Hubicka @ 2013-09-10 13:38 UTC (permalink / raw)
  To: David Malcolm; +Cc: gcc-patches, Jan Hubicka

> Amongst other things, the rename_symtab.py script converts
> "symtab_node" to "symtab_node *".
> 
> This will lead to broken code on declarations that declare
> more than one variable (only the first would get a "*"), so split
> up such declarations.
> 
> gcc/
> 	* cgraphunit.c (analyze_functions): Split symtab_node
> 	declarations onto multiple lines to make things easier
> 	for rename_symtab.py.
> 
> 	* symtab.c (symtab_dissolve_same_comdat_group_list): Likewise.
> 	(symtab_semantically_equivalent_p): Likewise.
> 
> gcc/lto
> 	* lto-symtab.c (lto_symtab_merge_decls_2): Split symtab_node
> 	declarations onto multiple lines to make things easier for
> 	rename_symtab.py.
> 	(lto_symtab_merge_decls_1): Likewise.
> 	(lto_symtab_merge_symbols_1): Likewise.

OK
Honza

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v2 4/6] Remove symtab_node and const_symtab_node typedefs.
  2013-09-09 19:43     ` [PATCH v2 4/6] Remove symtab_node and const_symtab_node typedefs David Malcolm
@ 2013-09-10 13:39       ` Jan Hubicka
  2013-10-31 23:38         ` symtab_node is now a struct, not a pointer (was Re: [PATCH v2 4/6] Remove symtab_node and const_symtab_node typedefs.) David Malcolm
  0 siblings, 1 reply; 39+ messages in thread
From: Jan Hubicka @ 2013-09-10 13:39 UTC (permalink / raw)
  To: David Malcolm; +Cc: gcc-patches, Jan Hubicka

> gcc/
> 
> 	* ipa-ref.h (symtab_node): Remove typedef to pointer type, as it
> 	clashes with the preferred name for the base class.
> 	(const_symtab_node): Remove redundant typedef.

This is OK, too.
Actually it is not only clash - it was really inconsistent to write
symtab_node node;
struct cgraph_node *cnode;

It is good this inconsistency is gone.
Honza

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v2 5/6] Automated renaming of symtab types
  2013-09-09 20:49     ` [PATCH v2 5/6] Automated renaming of symtab types David Malcolm
@ 2013-09-10 13:40       ` Jan Hubicka
  0 siblings, 0 replies; 39+ messages in thread
From: Jan Hubicka @ 2013-09-10 13:40 UTC (permalink / raw)
  To: David Malcolm; +Cc: gcc-patches, Jan Hubicka

> gcc/
> 
> 	Patch autogenerated by rename_symtab.py from
> 	https://github.com/davidmalcolm/gcc-refactoring-scripts
> 	revision 714e57b66b08fb29f47826fbb642707bdfa19520

OK,
thanks!
Honza

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v2 6/6] Update hand-written GTY routines for type renaming
  2013-09-09 19:32     ` [PATCH v2 6/6] Update hand-written GTY routines for type renaming David Malcolm
@ 2013-09-10 13:46       ` Jan Hubicka
  0 siblings, 0 replies; 39+ messages in thread
From: Jan Hubicka @ 2013-09-10 13:46 UTC (permalink / raw)
  To: David Malcolm; +Cc: gcc-patches, Jan Hubicka

> 	* cgraph.c (gt_ggc_mx): Update for renaming of symtab_node_base
> 	to symtab_node
> 	(gt_pch_nx): Likewise.
> ---
>  gcc/cgraph.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/gcc/cgraph.c b/gcc/cgraph.c
> index bb2626d..abbffa1 100644
> --- a/gcc/cgraph.c
> +++ b/gcc/cgraph.c
> @@ -3024,11 +3024,11 @@ void gt_ggc_mx (symtab_node *x)
>      {
>        /* Code common to all symtab nodes. */
>        gt_ggc_m_9tree_node (x->decl);
> -      gt_ggc_mx_symtab_node_base (x->next);
> -      gt_ggc_mx_symtab_node_base (x->previous);
> -      gt_ggc_mx_symtab_node_base (x->next_sharing_asm_name);
> -      gt_ggc_mx_symtab_node_base (x->previous_sharing_asm_name);
> -      gt_ggc_mx_symtab_node_base (x->same_comdat_group);
> +      gt_ggc_mx_symtab_node (x->next);
> +      gt_ggc_mx_symtab_node (x->previous);
> +      gt_ggc_mx_symtab_node (x->next_sharing_asm_name);
> +      gt_ggc_mx_symtab_node (x->previous_sharing_asm_name);
> +      gt_ggc_mx_symtab_node (x->same_comdat_group);

These will go away as dicussed earlier.
Patch is OK with that change.
Honza
>        gt_ggc_m_20vec_ipa_ref_t_va_gc_ (x->ref_list.references);
>        gt_ggc_m_9tree_node (x->alias_target);
>        gt_ggc_m_18lto_file_decl_data (x->lto_file_data);
> @@ -3068,7 +3068,7 @@ void gt_ggc_mx (symtab_node *x)
>  void gt_pch_nx (symtab_node *x)
>  {
>    symtab_node * xlimit = x ? x->next : NULL;
> -  while (gt_pch_note_object (xlimit, xlimit, gt_pch_p_16symtab_node_base))
> +  while (gt_pch_note_object (xlimit, xlimit, gt_pch_p_11symtab_node))
>     xlimit = xlimit->next;
>    if (x != xlimit)
>      for (;;)
> @@ -3077,17 +3077,17 @@ void gt_pch_nx (symtab_node *x)
>          if (xprev == NULL) break;
>          x = xprev;
>          (void) gt_pch_note_object (xprev, xprev,
> -                                   gt_pch_p_16symtab_node_base);
> +                                   gt_pch_p_11symtab_node);
>        }
>    while (x != xlimit)
>      {
>        /* Code common to all symtab nodes. */
>        gt_pch_n_9tree_node (x->decl);
> -      gt_pch_nx_symtab_node_base (x->next);
> -      gt_pch_nx_symtab_node_base (x->previous);
> -      gt_pch_nx_symtab_node_base (x->next_sharing_asm_name);
> -      gt_pch_nx_symtab_node_base (x->previous_sharing_asm_name);
> -      gt_pch_nx_symtab_node_base (x->same_comdat_group);
> +      gt_pch_nx_symtab_node (x->next);
> +      gt_pch_nx_symtab_node (x->previous);
> +      gt_pch_nx_symtab_node (x->next_sharing_asm_name);
> +      gt_pch_nx_symtab_node (x->previous_sharing_asm_name);
> +      gt_pch_nx_symtab_node (x->same_comdat_group);
>        gt_pch_n_20vec_ipa_ref_t_va_gc_ (x->ref_list.references);
>        gt_pch_n_9tree_node (x->alias_target);
>        gt_pch_n_18lto_file_decl_data (x->lto_file_data);
> -- 
> 1.7.11.7

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v2 0/6] Port symtab/cgraph/varpool nodes to use C++ inheritance; rename types.
  2013-09-10 13:04     ` [PATCH v2 0/6] Port symtab/cgraph/varpool nodes to use C++ inheritance; rename types Jan Hubicka
@ 2013-09-11  1:34       ` David Malcolm
  0 siblings, 0 replies; 39+ messages in thread
From: David Malcolm @ 2013-09-11  1:34 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: gcc-patches

On Tue, 2013-09-10 at 14:52 +0200, Jan Hubicka wrote:
> > Here's version 2 of this patch series.
[...]
> > The remaining 4 patches rename some types:
> > 
> > "symtab_node_base" becomes "symtab_node" (Honza's preferred name, AIUI).
> > 
> > This would clash with the pre-existing "symtab_node", which was a
> > typedef for:
> >   union symtab_node_def *
> > before patch 1, and for:
> >   symtab_node_base *
> > after it.
> > 
> > So we eliminate this typedef, and all uses become simply a
> > "symtab_node *", which is the bulk of the renaming.  There is also
> > a "const_symtab_node" typedef, which is eliminated; all uses become
> > simply a "const symtab_node *".
> 
> yes, having symtab_node * and then cgraph_node */varpool_node * that will
> later renamed to something like function_node/variable_node seems fine.
> We can also drop _node and make it symbol that would be more descriptive.

(nods).   Note that "symbol" is used as a variable name throughout the
source tree, which would complicate such a renaming, so let's defer that
to later.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v2 1/6] Convert symtab, cgraph and varpool nodes into a real class hierarchy
  2013-09-10 13:36       ` Jan Hubicka
@ 2013-09-17 21:10         ` David Malcolm
  2013-09-18  8:05           ` Jan Hubicka
  0 siblings, 1 reply; 39+ messages in thread
From: David Malcolm @ 2013-09-17 21:10 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: gcc-patches

On Tue, 2013-09-10 at 15:34 +0200, Jan Hubicka wrote:

Thanks for reviewing this, and sorry for the late response (I lost most
of last week to illness).  Some questions inline below...

> > This patch is the handwritten part of the conversion of these types
> > to C++; it requires the followup patch, which is autogenerated.
> > 
> > It converts:
> >   struct GTY(()) symtab_node_base
> > to:
> >   class GTY((user)) symtab_node_base
> > 
> > and converts:
> >   struct GTY(()) cgraph_node
> > to:
> >   struct GTY((user)) cgraph_node : public symtab_node_base
> > 
> > and:
> >   struct GTY(()) varpool_node
> > to:
> >   class GTY((user)) varpool_node : public symtab_node_base
> > 
> > dropping the symtab_node_def union.
> > 
> > Since gengtype is unable to cope with inheritance, we have to mark the
> > types with GTY((user)), and handcode the gty field-visiting functions.
> > Given the simple hierarchy, we don't need virtual functions for this.
> > 
> > Unfortunately doing so runs into various bugs in gengtype's handling
> > of GTY((user)), so the patch also includes workarounds for these bugs.
> > 
> > gengtype walks the graph of the *types* in the code, and produces
> > functions in gtype-desc.[ch] for all types that are reachable from a
> > GTY root.
> > 
> > However, it ignores the contents of GTY((user)) types when walking
> > this graph.
> > 
> > Hence if you have a subgraph of types that are only reachable
> > via fields in GTY((user)) types, gengtype won't generate helper code
> > for those types.
> > 
> > Ideally there would be some way to mark a GTY((user)) type to say
> > which types it references, to avoid having to mark these types as
> > GTY((user)).
> > 
> > For now, work around this issue by providing explicit roots of the
> > missing types, of dummy variables (see the bottom of cgraph.c)
> > 
[..]

> > diff --git a/gcc/cgraph.c b/gcc/cgraph.c
> > index f12bf1b..4b12163 100644
> > --- a/gcc/cgraph.c
> > +++ b/gcc/cgraph.c
> > @@ -2994,4 +2994,222 @@ cgraph_get_body (struct cgraph_node *node)
> >    return true;
> >  }
> >  
> > +/* GTY((user)) hooks for symtab_node_base (and its subclasses).
> > +   We could use virtual functions for this, but given the presence of the
> > +   "type" field and the trivial size of the class hierarchy, switches are
> > +   perhaps simpler and faster.  */
> > +
> > +void gt_ggc_mx (symtab_node_base *x)
> > +{
> > +  /* Hand-written equivalent of the chain_next/chain_prev machinery, to
> > +     avoid deep call-stacks.
> > +
> > +     Locate the neighbors of x (within the linked-list) that haven't been
> > +     marked yet, so that x through xlimit give a range suitable for marking.
> > +     Note that x (on entry) itself has already been marked by the
> > +     gtype-desc.c code, so we first try its successor.
> > +  */
> > +  symtab_node_base * xlimit = x ? x->next : NULL;
> > +  while (ggc_test_and_set_mark (xlimit))
> > +   xlimit = xlimit->next;
> > +  if (x != xlimit)
> > +    for (;;)
> > +      {
> > +        symtab_node_base * const xprev = x->previous;
> > +        if (xprev == NULL) break;
> > +        x = xprev;
> > +        (void) ggc_test_and_set_mark (xprev);
> > +      }
> > +  while (x != xlimit)
> > +    {
> > +      /* Code common to all symtab nodes. */
> > +      gt_ggc_m_9tree_node (x->decl);
> > +      gt_ggc_mx_symtab_node_base (x->next);
> Aren't you marking next twice? Once by xlimit walk and one by recursion?
Good catch; removed.

> > +      gt_ggc_mx_symtab_node_base (x->previous);
The comment above also applies to "previous", so I've removed this also.

> > +      gt_ggc_mx_symtab_node_base (x->next_sharing_asm_name);
> > +      gt_ggc_mx_symtab_node_base (x->previous_sharing_asm_name);
> > +      gt_ggc_mx_symtab_node_base (x->same_comdat_group);
> 
> You can skip marking these.  They only point within symbol table and
> not externally.
OK; removed.

> > +      gt_ggc_m_20vec_ipa_ref_t_va_gc_ (x->ref_list.references);
> > +      gt_ggc_m_9tree_node (x->alias_target);
> > +      gt_ggc_m_18lto_file_decl_data (x->lto_file_data);
> > +
> > +      /* Extra code, per subclass. */
> > +      switch (x->type)
> Didn't we agreed on the is_a API?

There's just one interesting subclass here, so I've converted this to:

          if (cgraph_node *cgn = dyn_cast <cgraph_node *> (x))
            {

eliminating the switch and static_cast.

> > +        {
> > +        case SYMTAB_FUNCTION:
> > +          {
> 
> > +            cgraph_node *cgn = static_cast <cgraph_node *> (x);
> > +            gt_ggc_m_11cgraph_edge (cgn->callees);
> > +            gt_ggc_m_11cgraph_edge (cgn->callers);
> > +            gt_ggc_m_11cgraph_edge (cgn->indirect_calls);
> > +            gt_ggc_m_11cgraph_node (cgn->origin);
> > +            gt_ggc_m_11cgraph_node (cgn->nested);
> > +            gt_ggc_m_11cgraph_node (cgn->next_nested);
> > +            gt_ggc_m_11cgraph_node (cgn->next_sibling_clone);
> > +            gt_ggc_m_11cgraph_node (cgn->prev_sibling_clone);
> > +            gt_ggc_m_11cgraph_node (cgn->clones);
> > +            gt_ggc_m_11cgraph_node (cgn->clone_of);
> Same as here.

Sorry, it's not clear to me what you meant by "Same as here." here.  Do
you mean that I can skip marking them because they're within the symbol
table?   If so, are you referring to all 10 fields above ("callees"
through "clone_of")?


> 
> > +            gt_ggc_m_P11cgraph_edge4htab (cgn->call_site_hash);
> Move call site hash out of GGC rather than introducing hack.

I see that this is allocated in cgraph_edge (), and it appears to be an
index.  I can create it with htab_create rather than htab_create_ggc,
but if so, there doesn't seem a natural place to call htab_delete.  Is
that OK?


> > +            gt_ggc_m_9tree_node (cgn->former_clone_of);
> > +            gt_ggc_m_11cgraph_node (cgn->global.inlined_to);
> And here

Again, do you mean that "inlined_to" can be skipped since it's in the
symbol table?


> > +            gt_ggc_m_28vec_ipa_replace_map_p_va_gc_ (cgn->clone.tree_map);
> > +            gt_ggc_m_15bitmap_head_def (cgn->clone.args_to_skip);
> > +            gt_ggc_m_15bitmap_head_def (cgn->clone.combined_args_to_skip);
> > +            gt_ggc_m_9tree_node (cgn->thunk.alias);
> > +          }
> > +          break;
> > +        default:
> > +          break;
> > +        }
> > +      x = x->next;
> > +    }
> > +}
> > +
> > +void gt_pch_nx (symtab_node_base *x)
> > +{
> > +  symtab_node_base * xlimit = x ? x->next : NULL;
> > +  while (gt_pch_note_object (xlimit, xlimit, gt_pch_p_16symtab_node_base))
> > +   xlimit = xlimit->next;
> > +  if (x != xlimit)
> > +    for (;;)
> > +      {
> > +        symtab_node_base * const xprev = x->previous;
> > +        if (xprev == NULL) break;
> > +        x = xprev;
> > +        (void) gt_pch_note_object (xprev, xprev,
> > +                                   gt_pch_p_16symtab_node_base);
> > +      }
> > +  while (x != xlimit)
> > +    {
> > +      /* Code common to all symtab nodes. */
> > +      gt_pch_n_9tree_node (x->decl);
> > +      gt_pch_nx_symtab_node_base (x->next);
> > +      gt_pch_nx_symtab_node_base (x->previous);
> > +      gt_pch_nx_symtab_node_base (x->next_sharing_asm_name);
> > +      gt_pch_nx_symtab_node_base (x->previous_sharing_asm_name);
> > +      gt_pch_nx_symtab_node_base (x->same_comdat_group);
> > +      gt_pch_n_20vec_ipa_ref_t_va_gc_ (x->ref_list.references);
> > +      gt_pch_n_9tree_node (x->alias_target);
> > +      gt_pch_n_18lto_file_decl_data (x->lto_file_data);
> > +
> > +      /* Extra code, per subclass. */
> > +      switch (x->type)
> > +        {
> > +        case SYMTAB_FUNCTION:
> > +          {
> > +            cgraph_node *cgn = static_cast <cgraph_node *> (x);
> > +            gt_pch_n_11cgraph_edge (cgn->callees);
> > +            gt_pch_n_11cgraph_edge (cgn->callers);
> > +            gt_pch_n_11cgraph_edge (cgn->indirect_calls);
> > +            gt_pch_n_11cgraph_node (cgn->origin);
> > +            gt_pch_n_11cgraph_node (cgn->nested);
> > +            gt_pch_n_11cgraph_node (cgn->next_nested);
> > +            gt_pch_n_11cgraph_node (cgn->next_sibling_clone);
> > +            gt_pch_n_11cgraph_node (cgn->prev_sibling_clone);
> > +            gt_pch_n_11cgraph_node (cgn->clones);
> > +            gt_pch_n_11cgraph_node (cgn->clone_of);
> > +            gt_pch_n_P11cgraph_edge4htab (cgn->call_site_hash);
> > +            gt_pch_n_9tree_node (cgn->former_clone_of);
> > +            gt_pch_n_11cgraph_node (cgn->global.inlined_to);
> > +            gt_pch_n_28vec_ipa_replace_map_p_va_gc_ (cgn->clone.tree_map);
> > +            gt_pch_n_15bitmap_head_def (cgn->clone.args_to_skip);
> > +            gt_pch_n_15bitmap_head_def (cgn->clone.combined_args_to_skip);
> > +            gt_pch_n_9tree_node (cgn->thunk.alias);
> 
> We can skip good part of those. Just small of those is build at PCH time. But lets do that incrementally, PCH is touchy business.

OK.  I'll just make analogous changes here to those made to the
gt_ggc_mx function.

> 
> The patch is OK with those changes.  The dummy workarounds are ugly :(
> Honza

Thanks.


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v2 1/6] Convert symtab, cgraph and varpool nodes into a real class hierarchy
  2013-09-17 21:10         ` David Malcolm
@ 2013-09-18  8:05           ` Jan Hubicka
  2013-09-18 10:37             ` Richard Biener
  0 siblings, 1 reply; 39+ messages in thread
From: Jan Hubicka @ 2013-09-18  8:05 UTC (permalink / raw)
  To: David Malcolm; +Cc: Jan Hubicka, gcc-patches

> > > +            cgraph_node *cgn = static_cast <cgraph_node *> (x);
> > > +            gt_ggc_m_11cgraph_edge (cgn->callers);
> > > +            gt_ggc_m_11cgraph_node (cgn->origin);
> > > +            gt_ggc_m_11cgraph_node (cgn->nested);
> > > +            gt_ggc_m_11cgraph_node (cgn->next_nested);
> > > +            gt_ggc_m_11cgraph_node (cgn->next_sibling_clone);
> > > +            gt_ggc_m_11cgraph_node (cgn->prev_sibling_clone);
> > > +            gt_ggc_m_11cgraph_node (cgn->clones);
> > > +            gt_ggc_m_11cgraph_node (cgn->clone_of);
> > Same as here.
> 
> Sorry, it's not clear to me what you meant by "Same as here." here.  Do
> you mean that I can skip marking them because they're within the symbol
> table?   If so, are you referring to all 10 fields above ("callees"
> through "clone_of")?

All those pointers above points inside symbol table, so none of them needs
to be marked.  Actually those two needs however, I missed them with prevoius
reading:
> > > +            gt_ggc_m_11cgraph_edge (cgn->indirect_calls);
> > > +            gt_ggc_m_11cgraph_edge (cgn->callees);

Otherwise edges will probably get lost.
> 
> 
> > 
> > > +            gt_ggc_m_P11cgraph_edge4htab (cgn->call_site_hash);
> > Move call site hash out of GGC rather than introducing hack.
> 
> I see that this is allocated in cgraph_edge (), and it appears to be an
> index.  I can create it with htab_create rather than htab_create_ggc,
> but if so, there doesn't seem a natural place to call htab_delete.  Is
> that OK?

Delete it in cgraph_remove_node.
> 
> 
> > > +            gt_ggc_m_9tree_node (cgn->former_clone_of);
> > > +            gt_ggc_m_11cgraph_node (cgn->global.inlined_to);
> > And here
> 
> Again, do you mean that "inlined_to" can be skipped since it's in the
> symbol table?

yes.
> > > +            cgraph_node *cgn = static_cast <cgraph_node *> (x);
> > > +            gt_pch_n_11cgraph_edge (cgn->callees);
> > > +            gt_pch_n_11cgraph_edge (cgn->callers);
> > > +            gt_pch_n_11cgraph_edge (cgn->indirect_calls);
> > > +            gt_pch_n_11cgraph_node (cgn->origin);
> > > +            gt_pch_n_11cgraph_node (cgn->nested);
> > > +            gt_pch_n_11cgraph_node (cgn->next_nested);
> > > +            gt_pch_n_11cgraph_node (cgn->next_sibling_clone);
> > > +            gt_pch_n_11cgraph_node (cgn->prev_sibling_clone);
> > > +            gt_pch_n_11cgraph_node (cgn->clones);
> > > +            gt_pch_n_11cgraph_node (cgn->clone_of);
> > > +            gt_pch_n_P11cgraph_edge4htab (cgn->call_site_hash);
> > > +            gt_pch_n_9tree_node (cgn->former_clone_of);
> > > +            gt_pch_n_11cgraph_node (cgn->global.inlined_to);
> > > +            gt_pch_n_28vec_ipa_replace_map_p_va_gc_ (cgn->clone.tree_map);
> > > +            gt_pch_n_15bitmap_head_def (cgn->clone.args_to_skip);
> > > +            gt_pch_n_15bitmap_head_def (cgn->clone.combined_args_to_skip);
> > > +            gt_pch_n_9tree_node (cgn->thunk.alias);
> > 
> > We can skip good part of those. Just small of those is build at PCH time. But lets do that incrementally, PCH is touchy business.
> 
> OK.  I'll just make analogous changes here to those made to the
> gt_ggc_mx function.

I think some of the pointers that do not need to be marked still needs to be
streamed and fixed by PCH, so we probably want to keep them.  All the cloning
pointers above are not live at PCH time (they are always NULL).  Only reason
why PCH lives at that point is that C++ FE produces Cgraph nodes early for
funny reason. The nodes are not analyzed at that point and call edges do not
exist (if I recall right) Probably I can do this incrementally - we do not want
to break PCH with a large patch and then spend weeks analyzing it.  That things
can bite ;)

Honza

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v2 1/6] Convert symtab, cgraph and varpool nodes into a real class hierarchy
  2013-09-18  8:05           ` Jan Hubicka
@ 2013-09-18 10:37             ` Richard Biener
  0 siblings, 0 replies; 39+ messages in thread
From: Richard Biener @ 2013-09-18 10:37 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: David Malcolm, GCC Patches

On Wed, Sep 18, 2013 at 9:24 AM, Jan Hubicka <hubicka@ucw.cz> wrote:
>> > > +            cgraph_node *cgn = static_cast <cgraph_node *> (x);
>> > > +            gt_ggc_m_11cgraph_edge (cgn->callers);
>> > > +            gt_ggc_m_11cgraph_node (cgn->origin);
>> > > +            gt_ggc_m_11cgraph_node (cgn->nested);
>> > > +            gt_ggc_m_11cgraph_node (cgn->next_nested);
>> > > +            gt_ggc_m_11cgraph_node (cgn->next_sibling_clone);
>> > > +            gt_ggc_m_11cgraph_node (cgn->prev_sibling_clone);
>> > > +            gt_ggc_m_11cgraph_node (cgn->clones);
>> > > +            gt_ggc_m_11cgraph_node (cgn->clone_of);
>> > Same as here.
>>
>> Sorry, it's not clear to me what you meant by "Same as here." here.  Do
>> you mean that I can skip marking them because they're within the symbol
>> table?   If so, are you referring to all 10 fields above ("callees"
>> through "clone_of")?
>
> All those pointers above points inside symbol table, so none of them needs
> to be marked.  Actually those two needs however, I missed them with prevoius
> reading:
>> > > +            gt_ggc_m_11cgraph_edge (cgn->indirect_calls);
>> > > +            gt_ggc_m_11cgraph_edge (cgn->callees);
>
> Otherwise edges will probably get lost.
>>
>>
>> >
>> > > +            gt_ggc_m_P11cgraph_edge4htab (cgn->call_site_hash);
>> > Move call site hash out of GGC rather than introducing hack.
>>
>> I see that this is allocated in cgraph_edge (), and it appears to be an
>> index.  I can create it with htab_create rather than htab_create_ggc,
>> but if so, there doesn't seem a natural place to call htab_delete.  Is
>> that OK?
>
> Delete it in cgraph_remove_node.
>>
>>
>> > > +            gt_ggc_m_9tree_node (cgn->former_clone_of);
>> > > +            gt_ggc_m_11cgraph_node (cgn->global.inlined_to);
>> > And here
>>
>> Again, do you mean that "inlined_to" can be skipped since it's in the
>> symbol table?
>
> yes.
>> > > +            cgraph_node *cgn = static_cast <cgraph_node *> (x);
>> > > +            gt_pch_n_11cgraph_edge (cgn->callees);
>> > > +            gt_pch_n_11cgraph_edge (cgn->callers);
>> > > +            gt_pch_n_11cgraph_edge (cgn->indirect_calls);
>> > > +            gt_pch_n_11cgraph_node (cgn->origin);
>> > > +            gt_pch_n_11cgraph_node (cgn->nested);
>> > > +            gt_pch_n_11cgraph_node (cgn->next_nested);
>> > > +            gt_pch_n_11cgraph_node (cgn->next_sibling_clone);
>> > > +            gt_pch_n_11cgraph_node (cgn->prev_sibling_clone);
>> > > +            gt_pch_n_11cgraph_node (cgn->clones);
>> > > +            gt_pch_n_11cgraph_node (cgn->clone_of);
>> > > +            gt_pch_n_P11cgraph_edge4htab (cgn->call_site_hash);
>> > > +            gt_pch_n_9tree_node (cgn->former_clone_of);
>> > > +            gt_pch_n_11cgraph_node (cgn->global.inlined_to);
>> > > +            gt_pch_n_28vec_ipa_replace_map_p_va_gc_ (cgn->clone.tree_map);
>> > > +            gt_pch_n_15bitmap_head_def (cgn->clone.args_to_skip);
>> > > +            gt_pch_n_15bitmap_head_def (cgn->clone.combined_args_to_skip);
>> > > +            gt_pch_n_9tree_node (cgn->thunk.alias);
>> >
>> > We can skip good part of those. Just small of those is build at PCH time. But lets do that incrementally, PCH is touchy business.
>>
>> OK.  I'll just make analogous changes here to those made to the
>> gt_ggc_mx function.
>
> I think some of the pointers that do not need to be marked still needs to be
> streamed and fixed by PCH, so we probably want to keep them.  All the cloning
> pointers above are not live at PCH time (they are always NULL).  Only reason
> why PCH lives at that point is that C++ FE produces Cgraph nodes early for
> funny reason. The nodes are not analyzed at that point and call edges do not
> exist (if I recall right) Probably I can do this incrementally - we do not want
> to break PCH with a large patch and then spend weeks analyzing it.  That things
> can bite ;)

Debugging omissions / errors in manually written markers will indeed be a
PITA :/

Richard.

> Honza

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v2 3/6] Split symtab_node declarations onto multiple lines
  2013-09-10 13:38       ` Jan Hubicka
@ 2013-10-30 16:12         ` David Malcolm
  0 siblings, 0 replies; 39+ messages in thread
From: David Malcolm @ 2013-10-30 16:12 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: gcc-patches

On Tue, 2013-09-10 at 15:36 +0200, Jan Hubicka wrote:
> > Amongst other things, the rename_symtab.py script converts
> > "symtab_node" to "symtab_node *".
> > 
> > This will lead to broken code on declarations that declare
> > more than one variable (only the first would get a "*"), so split
> > up such declarations.
> > 
> > gcc/
> > 	* cgraphunit.c (analyze_functions): Split symtab_node
> > 	declarations onto multiple lines to make things easier
> > 	for rename_symtab.py.
> > 
> > 	* symtab.c (symtab_dissolve_same_comdat_group_list): Likewise.
> > 	(symtab_semantically_equivalent_p): Likewise.
> > 
> > gcc/lto
> > 	* lto-symtab.c (lto_symtab_merge_decls_2): Split symtab_node
> > 	declarations onto multiple lines to make things easier for
> > 	rename_symtab.py.
> > 	(lto_symtab_merge_decls_1): Likewise.
> > 	(lto_symtab_merge_symbols_1): Likewise.
> 
> OK
Thanks; committed to trunk as r204216.


^ permalink raw reply	[flat|nested] 39+ messages in thread

* symtab_node is now a struct, not a pointer (was Re: [PATCH v2 4/6] Remove symtab_node and const_symtab_node typedefs.)
  2013-09-10 13:39       ` Jan Hubicka
@ 2013-10-31 23:38         ` David Malcolm
  0 siblings, 0 replies; 39+ messages in thread
From: David Malcolm @ 2013-10-31 23:38 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: gcc-patches

On Tue, 2013-09-10 at 15:37 +0200, Jan Hubicka wrote:
> > gcc/
> > 
> > 	* ipa-ref.h (symtab_node): Remove typedef to pointer type, as it
> > 	clashes with the preferred name for the base class.
> > 	(const_symtab_node): Remove redundant typedef.
> 
> This is OK, too.
> Actually it is not only clash - it was really inconsistent to write
> symtab_node node;
> struct cgraph_node *cnode;
> 
> It is good this inconsistency is gone.

I've (finally) committed this to trunk (as r204278), followed by the
automated renaming patch (as r204279), having rechecked the bootstrap
and regrtest on x86_64-unknown-linux-gnu (RHEL 6.4, in fact).

So (at long last), the base class is symtab_node, with cgraph_node and
varpool_node as C++ subclasses, and the "pointerness" of these types is
consistent (i.e. none of them are pointers).

Dave

^ permalink raw reply	[flat|nested] 39+ messages in thread

end of thread, other threads:[~2013-10-31 21:32 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-16  0:58 [PATCH 0/2] Port symtab/cgraph/varpool nodes to use C++ inheritance David Malcolm
2013-08-16  0:58 ` [PATCH 2/2] Autogenerated fixes of "->symbol." to "->" David Malcolm
2013-08-16  0:58 ` [PATCH 1/2] Convert symtab, cgraph and varpool nodes into a real class hierarchy David Malcolm
2013-08-20 21:26   ` Jan Hubicka
2013-08-20 21:31     ` Steven Bosscher
2013-08-20 21:34       ` Jan Hubicka
2013-08-20 21:42         ` Jan Hubicka
2013-08-27 11:10   ` Richard Biener
2013-08-27 11:48     ` Jan Hubicka
2013-08-27 12:17       ` Richard Biener
2013-08-27 12:50         ` Jan Hubicka
2013-08-27 15:25     ` Mike Stump
2013-08-28  9:37       ` Richard Biener
2013-08-28 17:06         ` Mike Stump
2013-08-29 10:16           ` Richard Biener
2013-08-20 21:06 ` [PATCH 0/2] Port symtab/cgraph/varpool nodes to use C++ inheritance Jan Hubicka
2013-08-21 10:03   ` Martin Jambor
2013-08-26 22:27   ` David Malcolm
2013-09-09 19:32   ` [PATCH v2 0/6] Port symtab/cgraph/varpool nodes to use C++ inheritance; rename types David Malcolm
2013-09-09 19:32     ` [PATCH v2 6/6] Update hand-written GTY routines for type renaming David Malcolm
2013-09-10 13:46       ` Jan Hubicka
2013-09-09 19:32     ` [PATCH v2 2/6] Automated conversion of symtab to class hierarchy David Malcolm
2013-09-10 13:37       ` Jan Hubicka
2013-09-09 19:32     ` [PATCH v2 3/6] Split symtab_node declarations onto multiple lines David Malcolm
2013-09-10 13:38       ` Jan Hubicka
2013-10-30 16:12         ` David Malcolm
2013-09-09 19:33     ` [PATCH v2 1/6] Convert symtab, cgraph and varpool nodes into a real class hierarchy David Malcolm
2013-09-10  9:14       ` Richard Biener
2013-09-10 13:36       ` Jan Hubicka
2013-09-17 21:10         ` David Malcolm
2013-09-18  8:05           ` Jan Hubicka
2013-09-18 10:37             ` Richard Biener
2013-09-09 19:43     ` [PATCH v2 4/6] Remove symtab_node and const_symtab_node typedefs David Malcolm
2013-09-10 13:39       ` Jan Hubicka
2013-10-31 23:38         ` symtab_node is now a struct, not a pointer (was Re: [PATCH v2 4/6] Remove symtab_node and const_symtab_node typedefs.) David Malcolm
2013-09-09 20:49     ` [PATCH v2 5/6] Automated renaming of symtab types David Malcolm
2013-09-10 13:40       ` Jan Hubicka
2013-09-10 13:04     ` [PATCH v2 0/6] Port symtab/cgraph/varpool nodes to use C++ inheritance; rename types Jan Hubicka
2013-09-11  1:34       ` David Malcolm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).