]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Come up with cgraph_node::get_uid and make cgraph_node::uid private.
authorMartin Liska <mliska@suse.cz>
Fri, 8 Jun 2018 12:36:26 +0000 (14:36 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Fri, 8 Jun 2018 12:36:26 +0000 (12:36 +0000)
2018-06-08  Martin Liska  <mliska@suse.cz>

* cgraph.c (function_version_hasher::hash): Use
cgraph_node::get_uid ().
(function_version_hasher::equal):
* cgraph.h (cgraph_node::get_uid): New method.
* ipa-inline.c (update_caller_keys): Use
cgraph_node::get_uid ().
(update_callee_keys): Likewise.
* ipa-utils.c (searchc): Likewise.
(ipa_reduced_postorder): Likewise.
* lto-cgraph.c (input_node): Likewise.
* passes.c (is_pass_explicitly_enabled_or_disabled): Likewise.
* symbol-summary.h (symtab_insertion): Likewise.
(symtab_removal): Likewise.
(symtab_duplication): Likewise.
* tree-pretty-print.c (dump_function_header): Likewise.
* tree-sra.c (convert_callers_for_node): Likewise.

From-SVN: r261320

gcc/ChangeLog
gcc/cgraph.c
gcc/cgraph.h
gcc/ipa-inline.c
gcc/ipa-utils.c
gcc/lto-cgraph.c
gcc/passes.c
gcc/symbol-summary.h
gcc/tree-pretty-print.c
gcc/tree-sra.c

index a7424bb32c961fd9b7952d56df113a78bce49045..27d1b7c12227e104e2d12e9323d93e88f2d324a5 100644 (file)
@@ -1,3 +1,22 @@
+2018-06-08  Martin Liska  <mliska@suse.cz>
+
+       * cgraph.c (function_version_hasher::hash): Use
+       cgraph_node::get_uid ().
+       (function_version_hasher::equal):
+       * cgraph.h (cgraph_node::get_uid): New method.
+       * ipa-inline.c (update_caller_keys): Use
+       cgraph_node::get_uid ().
+       (update_callee_keys): Likewise.
+       * ipa-utils.c (searchc): Likewise.
+       (ipa_reduced_postorder): Likewise.
+       * lto-cgraph.c (input_node): Likewise.
+       * passes.c (is_pass_explicitly_enabled_or_disabled): Likewise.
+       * symbol-summary.h (symtab_insertion): Likewise.
+       (symtab_removal): Likewise.
+       (symtab_duplication): Likewise.
+       * tree-pretty-print.c (dump_function_header): Likewise.
+       * tree-sra.c (convert_callers_for_node): Likewise.
+
 2018-06-08  Martin Liska  <mliska@suse.cz>
 
        * cgraph.c (symbol_table::create_edge): Always assign a new
index cf6b35a1c83390af9e3e237c62796b0b55481218..bafbed7f13d9fbb1ad5991d1226f0520271a7fe8 100644 (file)
@@ -120,7 +120,7 @@ static GTY(()) hash_table<function_version_hasher> *cgraph_fnver_htab = NULL;
 hashval_t
 function_version_hasher::hash (cgraph_function_version_info *ptr)
 {
-  int uid = ptr->this_node->uid;
+  int uid = ptr->this_node->get_uid ();
   return (hashval_t)(uid);
 }
 
@@ -129,7 +129,7 @@ bool
 function_version_hasher::equal (cgraph_function_version_info *n1,
                                cgraph_function_version_info *n2)
 {
-  return n1->this_node->uid == n2->this_node->uid;
+  return n1->this_node->get_uid () == n2->this_node->get_uid ();
 }
 
 /* Mark as GC root all allocated nodes.  */
index 6d5a2b898a9d683d2fab2f2002a075bb5da15d47..a8b1b4cb3c38f5d8fe1160366fff26388c376dc9 100644 (file)
@@ -97,6 +97,8 @@ class GTY((desc ("%h.type"), tag ("SYMTAB_SYMBOL"),
   symtab_node
 {
 public:
+  friend class symbol_table;
+
   /* Return name.  */
   const char *name () const;
 
@@ -893,6 +895,8 @@ struct cgraph_edge_hasher : ggc_ptr_hash<cgraph_edge>
 
 struct GTY((tag ("SYMTAB_FUNCTION"))) cgraph_node : public symtab_node {
 public:
+  friend class symbol_table;
+
   /* Remove the node from cgraph and all inline clones inlined into it.
      Skip however removal of FORBIDDEN_NODE and return true if it needs to be
      removed.  This allows to call the function from outer loop walking clone
@@ -1271,6 +1275,12 @@ public:
     dump_cgraph (stderr);
   }
 
+  /* Get unique identifier of the node.  */
+  inline int get_uid ()
+  {
+    return m_uid;
+  }
+
   /* Record that DECL1 and DECL2 are semantically identical function
      versions.  */
   static void record_function_versions (tree decl1, tree decl2);
@@ -1390,8 +1400,6 @@ public:
   /* How to scale counts at materialization time; used to merge
      LTO units with different number of profile runs.  */
   int count_materialization_scale;
-  /* Unique id of the node.  */
-  int uid;
   /* ID assigned by the profiling.  */
   unsigned int profile_id;
   /* Time profiler: first run of function.  */
@@ -1438,6 +1446,9 @@ public:
   unsigned indirect_call_target : 1;
 
 private:
+  /* Unique id of the node.  */
+  int m_uid;
+
   /* Worker for call_for_symbol_and_aliases.  */
   bool call_for_symbol_and_aliases_1 (bool (*callback) (cgraph_node *,
                                                        void *),
@@ -2617,7 +2628,7 @@ symbol_table::allocate_cgraph_symbol (void)
   else
     node = ggc_cleared_alloc<cgraph_node> ();
 
-  node->uid = cgraph_max_uid++;
+  node->m_uid = cgraph_max_uid++;
   return node;
 }
 
index 0d8c6f0af20216752fbb3c4f55eb33837cc1c150..7e4468a7331db3c0cc11fcd62a82c92812e5387e 100644 (file)
@@ -1337,7 +1337,7 @@ update_caller_keys (edge_heap_t *heap, struct cgraph_node *node,
   if ((!node->alias && !ipa_fn_summaries->get_create (node)->inlinable)
       || node->global.inlined_to)
     return;
-  if (!bitmap_set_bit (updated_nodes, node->uid))
+  if (!bitmap_set_bit (updated_nodes, node->get_uid ()))
     return;
 
   FOR_EACH_ALIAS (node, ref)
@@ -1395,7 +1395,7 @@ update_callee_keys (edge_heap_t *heap, struct cgraph_node *node,
            && (callee = e->callee->ultimate_alias_target (&avail, e->caller))
            && ipa_fn_summaries->get_create (callee)->inlinable
            && avail >= AVAIL_AVAILABLE
-           && !bitmap_bit_p (updated_nodes, callee->uid))
+           && !bitmap_bit_p (updated_nodes, callee->get_uid ()))
          {
            if (can_inline_edge_p (e, false)
                && want_inline_small_function_p (e, false)
index aa586f5feb2a9d768d28ffaf88c577ea7c361092..9985721f7da795e052f283b3c5ed6430cf9d4a88 100644 (file)
@@ -86,7 +86,7 @@ searchc (struct searchc_env* env, struct cgraph_node *v,
 
   /* mark node as old */
   v_info->new_node = false;
-  splay_tree_remove (env->nodes_marked_new, v->uid);
+  splay_tree_remove (env->nodes_marked_new, v->get_uid ());
 
   v_info->dfn_number = env->count;
   v_info->low_link = env->count;
@@ -195,7 +195,7 @@ ipa_reduced_postorder (struct cgraph_node **order,
          node->aux = info;
 
          splay_tree_insert (env.nodes_marked_new,
-                            (splay_tree_key)node->uid,
+                            (splay_tree_key)node->get_uid (),
                             (splay_tree_value)node);
        }
       else
index a57bda9437db6190c0d272619385e19be43ceed1..d5e390cb5f4cc4dc5061cd6dd7c54bb19dbaa430 100644 (file)
@@ -1268,7 +1268,7 @@ input_node (struct lto_file_decl_data *file_data,
      functions, they are expected to be read more than once.  */
   if (node->aux && !DECL_BUILT_IN (node->decl))
     internal_error ("bytecode stream: found multiple instances of cgraph "
-                   "node with uid %d", node->uid);
+                   "node with uid %d", node->get_uid ());
 
   node->tp_first_run = streamer_read_uhwi (ib);
 
index 537e95aae599dd9ab21b1cd4199779a384d9c62f..6e614029864b1c464085b9940396ea052528c0d0 100644 (file)
@@ -1170,7 +1170,7 @@ is_pass_explicitly_enabled_or_disabled (opt_pass *pass,
   if (!slot)
     return false;
 
-  cgraph_uid = func ? cgraph_node::get (func)->uid : 0;
+  cgraph_uid = func ? cgraph_node::get (func)->get_uid () : 0;
   if (func && DECL_ASSEMBLER_NAME_SET_P (func))
     aname = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (func));
 
@@ -1635,7 +1635,7 @@ do_per_function (void (*callback) (function *, void *data), void *data)
 static int nnodes;
 static GTY ((length ("nnodes"))) cgraph_node **order;
 
-#define uid_hash_t hash_set<int_hash <int, 0, -1>>
+#define uid_hash_t hash_set<int_hash <int, 0, -1> >
 
 /* Hook called when NODE is removed and therefore should be
    excluded from order vector.  DATA is a hash set with removed nodes.  */
@@ -1644,7 +1644,7 @@ static void
 remove_cgraph_node_from_order (cgraph_node *node, void *data)
 {
   uid_hash_t *removed_nodes = (uid_hash_t *)data;
-  removed_nodes->add (node->uid);
+  removed_nodes->add (node->get_uid ());
 }
 
 /* If we are in IPA mode (i.e., current_function_decl is NULL), call
@@ -1675,7 +1675,7 @@ do_per_function_toporder (void (*callback) (function *, void *data), void *data)
          cgraph_node *node = order[i];
 
          /* Function could be inlined and removed as unreachable.  */
-         if (node == NULL || removed_nodes.contains (node->uid))
+         if (node == NULL || removed_nodes.contains (node->get_uid ()))
            continue;
 
          /* Allow possibly removed nodes to be garbage collected.  */
index 8c80f3093726137cfc0fdac1c2c7d193f65dfd2b..ebf4b175e71cb68f8a4ef9ada2eedc62f32fe56e 100644 (file)
@@ -90,13 +90,13 @@ public:
      does not exist it will be created.  */
   T* get_create (cgraph_node *node)
   {
-    return get (node->uid, true);
+    return get (node->get_uid (), true);
   }
 
   /* Getter for summary callgraph node pointer.  */
   T* get (cgraph_node *node)
   {
-    return get (node->uid, false);
+    return get (node->get_uid (), false);
   }
 
   /* Return number of elements handled by data structure.  */
@@ -108,7 +108,7 @@ public:
   /* Return true if a summary for the given NODE already exists.  */
   bool exists (cgraph_node *node)
   {
-    return m_map.get (node->uid) != NULL;
+    return m_map.get (node->get_uid ()) != NULL;
   }
 
   /* Enable insertion hook invocation.  */
@@ -216,7 +216,7 @@ template <typename T>
 void
 function_summary<T *>::symtab_insertion (cgraph_node *node, void *data)
 {
-  gcc_checking_assert (node->uid);
+  gcc_checking_assert (node->get_uid ());
   function_summary *summary = (function_summary <T *> *) (data);
 
   if (summary->m_insertion_enabled)
@@ -227,10 +227,10 @@ template <typename T>
 void
 function_summary<T *>::symtab_removal (cgraph_node *node, void *data)
 {
-  gcc_checking_assert (node->uid);
+  gcc_checking_assert (node->get_uid ());
   function_summary *summary = (function_summary <T *> *) (data);
 
-  int uid = node->uid;
+  int uid = node->get_uid ();
   T **v = summary->m_map.get (uid);
 
   if (v)
@@ -256,7 +256,7 @@ function_summary<T *>::symtab_duplication (cgraph_node *node,
     {
       /* This load is necessary, because we insert a new value!  */
       T *duplicate = summary->allocate_new ();
-      summary->m_map.put (node2->uid, duplicate);
+      summary->m_map.put (node2->get_uid (), duplicate);
       summary->duplicate (node, node2, v, duplicate);
     }
 }
index c5fc04150d83f191289a9c5a0be35ae2042f41d8..94410541e0500032c2a480e02442b81c1d613784 100644 (file)
@@ -4056,7 +4056,7 @@ dump_function_header (FILE *dump_file, tree fdecl, dump_flags_t flags)
     fprintf (dump_file, ", decl_uid=%d", DECL_UID (fdecl));
   if (node)
     {
-      fprintf (dump_file, ", cgraph_uid=%d", node->uid);
+      fprintf (dump_file, ", cgraph_uid=%d", node->get_uid ());
       fprintf (dump_file, ", symbol_order=%d)%s\n\n", node->order,
                node->frequency == NODE_FREQUENCY_HOT
                ? " (hot)"
index 09d56d10e7f304e4558ff1d690bba8ad19a5ec26..494afd830460669ec99631fbd1e8de25840918c0 100644 (file)
@@ -5279,7 +5279,7 @@ convert_callers_for_node (struct cgraph_node *node,
     }
 
   for (cs = node->callers; cs; cs = cs->next_caller)
-    if (bitmap_set_bit (recomputed_callers, cs->caller->uid)
+    if (bitmap_set_bit (recomputed_callers, cs->caller->get_uid ())
        && gimple_in_ssa_p (DECL_STRUCT_FUNCTION (cs->caller->decl)))
       compute_fn_summary (cs->caller, true);
   BITMAP_FREE (recomputed_callers);