]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
IPA C++ refactoring 2/N
authorMartin Liska <mliska@suse.cz>
Thu, 24 Jul 2014 12:25:27 +0000 (14:25 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Thu, 24 Jul 2014 12:25:27 +0000 (12:25 +0000)
  * cgraph.h (varpool_node):
  (availability get_availability (void)):
    created from cgraph_variable_initializer_availability
  (inline varpool_node *ultimate_alias_target (availability *availability = NULL)
    creted from: cgraph_variable_initializer_availability
  (inline varpool_node *get_alias_target (void)): created from varpool_alias_target
  (void finalize_named_section_flags (void)):
    created from varpool_finalize_named_section_flags
  (bool assemble_decl (void)): created from varpool_assemble_decl
  (void analyze (void)): created from varpool_analyze_node
  (bool call_for_node_and_aliases (bool (*callback) (varpool_node *, void *),
    void *data, bool include_overwritable)): created fromvarpool_for_node_and_aliases
  (void remove_initializer (void)): created from varpool_remove_initializer
  (tree get_constructor (void)): created from varpool_get_constructor
  (bool externally_visible_p (void)): created from varpool_externally_visible_p
  (bool ctor_useable_for_folding_p (void)): created from varpool_ctor_useable_for_folding_p
  (inline bool all_refs_explicit_p ()): created from varpool_all_refs_explicit_p
  (inline bool can_remove_if_no_refs_p (void)): created from varpool_can_remove_if_no_refs
  (static inline varpool_node *get (const_tree decl)): created from varpool_get_node
  (static void finalize_decl (tree decl)): created from varpool_finalize_decl
  (static bool output_variables (void)): created from varpool_output_variables
  (static varpool_node * create_extra_name_alias (tree alias, tree decl)):
    created from varpool_extra_name_alias
  (static varpool_node * create_alias (tree, tree)): created from varpool_create_variable_alias
  (static void dump_varpool (FILE *f)): created from dump_varpool
  (static void DEBUG_FUNCTION debug_varpool (void)): created from debug_varpool
  (static varpool_node *create_empty (void)): created from varpool_create_empty_node
  (static varpool_node *get_create (tree decl)): created from varpool_node_for_decl
  (static varpool_node *get_for_asmname (tree asmname)): created from varpool_node_for_asm
  (void assemble_aliases (void)): created from assemble_aliases

From-SVN: r212984

35 files changed:
gcc/ChangeLog
gcc/asan.c
gcc/cgraph.h
gcc/cgraphbuild.c
gcc/cgraphunit.c
gcc/coverage.c
gcc/cp/decl.c
gcc/cp/decl2.c
gcc/cp/mangle.c
gcc/cp/vtable-class-hierarchy.c
gcc/dbxout.c
gcc/dwarf2out.c
gcc/gimple-fold.c
gcc/ipa-devirt.c
gcc/ipa-visibility.c
gcc/ipa.c
gcc/java/resource.c
gcc/lto-cgraph.c
gcc/lto-streamer-out.c
gcc/lto/lto-partition.c
gcc/omp-low.c
gcc/passes.c
gcc/symtab.c
gcc/toplev.c
gcc/trans-mem.c
gcc/tree-cfg.c
gcc/tree-eh.c
gcc/tree-emutls.c
gcc/tree-profile.c
gcc/tree-ssa-structalias.c
gcc/tree-switch-conversion.c
gcc/tree.c
gcc/ubsan.c
gcc/varasm.c
gcc/varpool.c

index 548f4773d67bfdb68583a4529c231b472f4c6e25..291ac7b3e037dcab5870bae7182389e00c439381 100644 (file)
@@ -1,3 +1,36 @@
+2014-07-24  Martin Liska  <mliska@suse.cz>
+
+  * cgraph.h (varpool_node):
+  (availability get_availability (void)):
+    created from cgraph_variable_initializer_availability
+  (inline varpool_node *ultimate_alias_target (availability *availability = NULL)
+    creted from: cgraph_variable_initializer_availability
+  (inline varpool_node *get_alias_target (void)): created from varpool_alias_target
+  (void finalize_named_section_flags (void)):
+    created from varpool_finalize_named_section_flags
+  (bool assemble_decl (void)): created from varpool_assemble_decl
+  (void analyze (void)): created from varpool_analyze_node
+  (bool call_for_node_and_aliases (bool (*callback) (varpool_node *, void *),
+    void *data, bool include_overwritable)): created fromvarpool_for_node_and_aliases
+  (void remove_initializer (void)): created from varpool_remove_initializer
+  (tree get_constructor (void)): created from varpool_get_constructor
+  (bool externally_visible_p (void)): created from varpool_externally_visible_p
+  (bool ctor_useable_for_folding_p (void)): created from varpool_ctor_useable_for_folding_p
+  (inline bool all_refs_explicit_p ()): created from varpool_all_refs_explicit_p
+  (inline bool can_remove_if_no_refs_p (void)): created from varpool_can_remove_if_no_refs
+  (static inline varpool_node *get (const_tree decl)): created from varpool_get_node
+  (static void finalize_decl (tree decl)): created from varpool_finalize_decl
+  (static bool output_variables (void)): created from varpool_output_variables
+  (static varpool_node * create_extra_name_alias (tree alias, tree decl)):
+    created from varpool_extra_name_alias
+  (static varpool_node * create_alias (tree, tree)): created from varpool_create_variable_alias
+  (static void dump_varpool (FILE *f)): created from dump_varpool
+  (static void DEBUG_FUNCTION debug_varpool (void)): created from debug_varpool
+  (static varpool_node *create_empty (void)): created from varpool_create_empty_node
+  (static varpool_node *get_create (tree decl)): created from varpool_node_for_decl
+  (static varpool_node *get_for_asmname (tree asmname)): created from varpool_node_for_asm
+  (void assemble_aliases (void)): created from assemble_aliases
+
 2014-07-24  Martin Liska  <mliska@suse.cz>
 
   * cgraph.h (symtab_node):
index 920f72e978fb3c2a5583a324e7d7f359cad16e53..59ec904ccc3b56f4ebd3d6b4d5764326c5859aa8 100644 (file)
@@ -1931,7 +1931,7 @@ instrument_derefs (gimple_stmt_iterator *iter, tree t,
        {
          /* For static vars if they are known not to be dynamically
             initialized, they will be always accessible.  */
-         varpool_node *vnode = varpool_get_node (inner);
+         varpool_node *vnode = varpool_node::get (inner);
          if (vnode && !vnode->dynamically_initialized)
            return;
        }
@@ -2383,7 +2383,7 @@ asan_add_global (tree decl, tree type, vec<constructor_elt, va_gc> *v)
                          fold_convert (const_ptr_type_node, str_cst));
   CONSTRUCTOR_APPEND_ELT (vinner, NULL_TREE,
                          fold_convert (const_ptr_type_node, module_name_cst));
-  varpool_node *vnode = varpool_get_node (decl);
+  varpool_node *vnode = varpool_node::get (decl);
   int has_dynamic_init = vnode ? vnode->dynamically_initialized : 0;
   CONSTRUCTOR_APPEND_ELT (vinner, NULL_TREE,
                          build_int_cst (uptr, has_dynamic_init));
@@ -2595,7 +2595,7 @@ asan_finish_file (void)
       TREE_CONSTANT (ctor) = 1;
       TREE_STATIC (ctor) = 1;
       DECL_INITIAL (var) = ctor;
-      varpool_finalize_decl (var);
+      varpool_node::finalize_decl (var);
 
       fn = builtin_decl_implicit (BUILT_IN_ASAN_REGISTER_GLOBALS);
       tree gcount_tree = build_int_cst (pointer_sized_int_node, gcount);
index eb80f990241c2c06ef0fbe4d5cacbabdbc755273..f8f76c42d6ca039809a96d7de353f4af888fef4f 100644 (file)
@@ -363,8 +363,8 @@ public:
   /* True when symbol corresponds to a definition in current unit.
      set via cgraph_finalize_function or varpool_finalize_decl  */
   unsigned definition : 1;
-  /* True when symbol is an alias.  
-     Set by assemble_alias.  */
+  /* True when symbol is an alias.
+     Set by ssemble_alias.  */
   unsigned alias : 1;
   /* True when alias is a weakref.  */
   unsigned weakref : 1;
@@ -408,7 +408,7 @@ public:
 
   /* Set when variable is used from other LTRANS partition.  */
   unsigned used_from_other_partition : 1;
-  /* Set when function is available in the other LTRANS partition.  
+  /* Set when function is available in the other LTRANS partition.
      During WPA output it is used to mark nodes that are present in
      multiple partitions.  */
   unsigned in_other_partition : 1;
@@ -1336,6 +1336,103 @@ struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"))) cgrap
 
 class GTY((tag ("SYMTAB_VARIABLE"))) varpool_node : public symtab_node {
 public:
+  /* Dump given varpool node to F.  */
+  void dump (FILE *f);
+
+  /* Dump given varpool node to stderr.  */
+  void DEBUG_FUNCTION debug (void);
+
+  /* Remove variable from symbol table.  */
+  void remove (void);
+
+  /* Remove node initializer when it is no longer needed.  */
+  void remove_initializer (void);
+
+  void analyze (void);
+
+  /* Return variable availability.  */
+  availability get_availability (void);
+
+  /* When doing LTO, read variable's constructor from disk if
+     it is not already present.  */
+  tree get_constructor (void);
+
+  /* Return true if variable has constructor that can be used for folding.  */
+  bool ctor_useable_for_folding_p (void);
+
+  /* For given variable pool node, walk the alias chain to return the function
+     the variable is alias of. Do not walk through thunks.
+     When AVAILABILITY is non-NULL, get minimal availability in the chain.  */
+  inline varpool_node *ultimate_alias_target
+    (availability *availability = NULL);
+
+  /* Return node that alias is aliasing.  */
+  inline varpool_node *get_alias_target (void);
+
+  /* Output one variable, if necessary.  Return whether we output it.  */
+  bool assemble_decl (void);
+
+  /* For variables in named sections make sure get_variable_section
+     is called before we switch to those sections.  Then section
+     conflicts between read-only and read-only requiring relocations
+     sections can be resolved.  */
+  void finalize_named_section_flags (void);
+
+  /* Call calback on varpool symbol and aliases associated to varpool symbol.
+     When INCLUDE_OVERWRITABLE is false, overwritable aliases and thunks are
+     skipped. */
+  bool call_for_node_and_aliases (bool (*callback) (varpool_node *, void *),
+                                 void *data,
+                                  bool include_overwritable);
+
+  /* Return true when variable should be considered externally visible.  */
+  bool externally_visible_p (void);
+
+  /* Return true when all references to variable must be visible
+     in ipa_ref_list.
+     i.e. if the variable is not externally visible or not used in some magic
+     way (asm statement or such).
+     The magic uses are all summarized in force_output flag.  */
+  inline bool all_refs_explicit_p ();
+
+  /* Return true when variable can be removed from variable pool
+     if all direct calls are eliminated.  */
+  inline bool can_remove_if_no_refs_p (void);
+
+  /* Return varpool node for given symbol and check it is a function. */
+  static inline varpool_node *get (const_tree decl);
+
+  /* Mark DECL as finalized.  By finalizing the declaration, frontend instruct
+     the middle end to output the variable to asm file, if needed or externally
+     visible.  */
+  static void finalize_decl (tree decl);
+
+  /* Output all variables enqueued to be assembled.  */
+  static bool output_variables (void);
+
+  /* Attempt to mark ALIAS as an alias to DECL.  Return TRUE if successful.
+     Extra name aliases are output whenever DECL is output.  */
+  static varpool_node * create_extra_name_alias (tree alias, tree decl);
+
+  /* Attempt to mark ALIAS as an alias to DECL.  Return TRUE if successful.
+     Extra name aliases are output whenever DECL is output.  */
+  static varpool_node * create_alias (tree, tree);
+
+  /* Dump the variable pool to F.  */
+  static void dump_varpool (FILE *f);
+
+  /* Dump the variable pool to stderr.  */
+  static void DEBUG_FUNCTION debug_varpool (void);
+
+  /* Allocate new callgraph node and insert it into basic data structures.  */
+  static varpool_node *create_empty (void);
+
+  /* Return varpool node assigned to DECL.  Create new one when needed.  */
+  static varpool_node *get_create (tree decl);
+
+  /* Given an assembler name, lookup node.  */
+  static varpool_node *get_for_asmname (tree asmname);
+
   /* Set when variable is scheduled to be assembled.  */
   unsigned output : 1;
 
@@ -1351,11 +1448,9 @@ public:
      if we did not do any inter-procedural code movement.  */
   unsigned used_by_single_function : 1;
 
-  /* Dump given cgraph node to F.  */
-  void dump (FILE *f);
-
-  /* Remove variable from symbol table.  */
-  void remove (void);
+private:
+  /* Assemble thunks and aliases associated to varpool node.  */
+  void assemble_aliases (void);
 };
 
 /* Every top level asm statement is put into a asm_node.  */
@@ -1538,39 +1633,16 @@ void dump_varpool_node_set (FILE *, varpool_node_set);
 void debug_varpool_node_set (varpool_node_set);
 void free_varpool_node_set (varpool_node_set);
 void ipa_discover_readonly_nonaddressable_vars (void);
-bool varpool_externally_visible_p (varpool_node *);
 
 /* In predict.c  */
 bool cgraph_maybe_hot_edge_p (struct cgraph_edge *e);
 
 /* In varpool.c  */
-varpool_node *varpool_create_empty_node (void);
-varpool_node *varpool_node_for_decl (tree);
-varpool_node *varpool_node_for_asm (tree asmname);
-void varpool_mark_needed_node (varpool_node *);
-void debug_varpool (void);
-void dump_varpool (FILE *);
-
-void varpool_finalize_decl (tree);
-enum availability cgraph_variable_initializer_availability (varpool_node *);
-
-void varpool_finalize_named_section_flags (varpool_node *node);
-bool varpool_output_variables (void);
-bool varpool_assemble_decl (varpool_node *node);
-void varpool_analyze_node (varpool_node *);
-varpool_node * varpool_extra_name_alias (tree, tree);
-varpool_node * varpool_create_variable_alias (tree, tree);
 void varpool_reset_queue (void);
-bool varpool_ctor_useable_for_folding_p (varpool_node *);
 tree ctor_for_folding (tree);
-bool varpool_for_node_and_aliases (varpool_node *,
-                                  bool (*) (varpool_node *, void *),
-                                  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 varpool_remove_initializer (varpool_node *);
-tree varpool_get_constructor (struct varpool_node *node);
 
 /* In cgraph.c */
 extern void change_decl_assembler_name (tree, tree);
@@ -1647,8 +1719,8 @@ symtab_node::next_defined_symbol (void)
 }
 
 /* Return varpool node for given symbol and check it is a function. */
-static inline varpool_node *
-varpool_get_node (const_tree decl)
+inline varpool_node *
+varpool_node::get (const_tree decl)
 {
   gcc_checking_assert (TREE_CODE (decl) == VAR_DECL);
   return dyn_cast<varpool_node *> (symtab_node::get (decl));
@@ -2009,34 +2081,34 @@ cgraph_node::only_called_directly_or_aliased_p (void)
          && !externally_visible);
 }
 
-/* Return true when function NODE can be removed from callgraph
+/* Return true when variable can be removed from variable pool
    if all direct calls are eliminated.  */
 
-static inline bool
-varpool_can_remove_if_no_refs (varpool_node *node)
+inline bool
+varpool_node::can_remove_if_no_refs_p (void)
 {
-  if (DECL_EXTERNAL (node->decl))
+  if (DECL_EXTERNAL (decl))
     return true;
-  return (!node->force_output && !node->used_from_other_partition
-         && ((DECL_COMDAT (node->decl)
-              && !node->forced_by_abi
-              && !node->used_from_object_file_p ())
-             || !node->externally_visible
-             || DECL_HAS_VALUE_EXPR_P (node->decl)));
+  return (!force_output && !used_from_other_partition
+         && ((DECL_COMDAT (decl)
+              && !forced_by_abi
+              && !used_from_object_file_p ())
+             || !externally_visible
+             || DECL_HAS_VALUE_EXPR_P (decl)));
 }
 
-/* Return true when all references to VNODE must be visible in ipa_ref_list.
+/* Return true when all references to variable must be visible in ipa_ref_list.
    i.e. if the variable is not externally visible or not used in some magic
    way (asm statement or such).
    The magic uses are all summarized in force_output flag.  */
 
-static inline bool
-varpool_all_refs_explicit_p (varpool_node *vnode)
+inline bool
+varpool_node::all_refs_explicit_p ()
 {
-  return (vnode->definition
-         && !vnode->externally_visible
-         && !vnode->used_from_other_partition
-         && !vnode->force_output);
+  return (definition
+         && !externally_visible
+         && !used_from_other_partition
+         && !force_output);
 }
 
 /* Constant pool accessor function.  */
@@ -2050,10 +2122,12 @@ cgraph_node::get_alias_target (void)
   return dyn_cast <cgraph_node *> (symtab_node::get_alias_target ());
 }
 
-static inline varpool_node *
-varpool_alias_target (varpool_node *n)
+/* Return node that alias is aliasing.  */
+
+inline varpool_node *
+varpool_node::get_alias_target (void)
 {
-  return dyn_cast <varpool_node *> (n->get_alias_target ());
+  return dyn_cast <varpool_node *> (symtab_node::get_alias_target ());
 }
 
 /* Given function symbol, walk the alias chain to return the function node
@@ -2069,20 +2143,16 @@ cgraph_node::ultimate_alias_target (enum availability *availability)
     *availability = AVAIL_NOT_AVAILABLE;
   return n;
 }
-/* Given NODE, walk the alias chain to return the function NODE is alias of.
-   Do not walk through thunks.
+
+/* For given variable pool node, walk the alias chain to return the function
+   the variable is alias of. Do not walk through thunks.
    When AVAILABILITY is non-NULL, get minimal availability in the chain.  */
 
-static inline varpool_node *
-varpool_variable_node (varpool_node *node,
-                      enum availability *availability = NULL)
+inline varpool_node *
+varpool_node::ultimate_alias_target (availability *availability)
 {
-  varpool_node *n;
-
-  if (node)
-    n = dyn_cast <varpool_node *> (node->ultimate_alias_target (availability));
-  else
-    n = NULL;
+  varpool_node *n = dyn_cast <varpool_node *>
+    (symtab_node::ultimate_alias_target (availability));
 
   if (!n && availability)
     *availability = AVAIL_NOT_AVAILABLE;
index 9f1f244c2a26cf5abdf825d227fdfc2919a175ed..91811d7c2fbcf8d24a4b0657fea569a4b150566f 100644 (file)
@@ -87,7 +87,7 @@ record_reference (tree *tp, int *walk_subtrees, void *data)
 
       if (TREE_CODE (decl) == VAR_DECL)
        {
-         varpool_node *vnode = varpool_node_for_decl (decl);
+         varpool_node *vnode = varpool_node::get_create (decl);
          ctx->varpool_node->add_reference (vnode, IPA_REF_ADDR);
        }
       *walk_subtrees = 0;
@@ -124,7 +124,7 @@ record_type_list (struct cgraph_node *node, tree list)
          type = TREE_OPERAND (type, 0);
          if (TREE_CODE (type) == VAR_DECL)
            {
-             varpool_node *vnode = varpool_node_for_decl (type);
+             varpool_node *vnode = varpool_node::get_create (type);
              node->add_reference (vnode, IPA_REF_ADDR);
            }
        }
@@ -230,7 +230,7 @@ mark_address (gimple stmt, tree addr, tree, void *data)
   else if (addr && TREE_CODE (addr) == VAR_DECL
           && (TREE_STATIC (addr) || DECL_EXTERNAL (addr)))
     {
-      varpool_node *vnode = varpool_node_for_decl (addr);
+      varpool_node *vnode = varpool_node::get_create (addr);
 
       ((symtab_node *)data)->add_reference (vnode, IPA_REF_ADDR, stmt);
     }
@@ -255,7 +255,7 @@ mark_load (gimple stmt, tree t, tree, void *data)
   else if (t && TREE_CODE (t) == VAR_DECL
           && (TREE_STATIC (t) || DECL_EXTERNAL (t)))
     {
-      varpool_node *vnode = varpool_node_for_decl (t);
+      varpool_node *vnode = varpool_node::get_create (t);
 
       ((symtab_node *)data)->add_reference (vnode, IPA_REF_LOAD, stmt);
     }
@@ -271,7 +271,7 @@ mark_store (gimple stmt, tree t, tree, void *data)
   if (t && TREE_CODE (t) == VAR_DECL
       && (TREE_STATIC (t) || DECL_EXTERNAL (t)))
     {
-      varpool_node *vnode = varpool_node_for_decl (t);
+      varpool_node *vnode = varpool_node::get_create (t);
 
       ((symtab_node *)data)->add_reference (vnode, IPA_REF_STORE, stmt);
      }
@@ -383,7 +383,7 @@ pass_build_cgraph_edges::execute (function *fun)
     if (TREE_CODE (decl) == VAR_DECL
        && (TREE_STATIC (decl) && !DECL_EXTERNAL (decl))
        && !DECL_HAS_VALUE_EXPR_P (decl))
-      varpool_finalize_decl (decl);
+      varpool_node::finalize_decl (decl);
   record_eh_tables (node, fun);
 
   pointer_set_destroy (visited_nodes);
@@ -406,7 +406,7 @@ void
 record_references_in_initializer (tree decl, bool only_vars)
 {
   struct pointer_set_t *visited_nodes = pointer_set_create ();
-  varpool_node *node = varpool_node_for_decl (decl);
+  varpool_node *node = varpool_node::get_create (decl);
   struct record_reference_ctx ctx = {false, NULL};
 
   ctx.varpool_node = node;
index 47828d752a9619b34860f2eadff45915f87e3b11..34f4c81eb84e003cfc63a60ff1ddeaa20c0e45d2 100644 (file)
@@ -686,7 +686,7 @@ cgraph_process_same_body_aliases (void)
     if (node->cpp_implicit_alias && !node->analyzed)
       node->resolve_alias
        (TREE_CODE (node->alias_target) == VAR_DECL
-        ? (symtab_node *)varpool_node_for_decl (node->alias_target)
+        ? (symtab_node *)varpool_node::get_create (node->alias_target)
         : (symtab_node *)cgraph_node::get_create (node->alias_target));
   cpp_implicit_aliases_done = true;
 }
@@ -779,7 +779,7 @@ process_function_and_variable_attributes (struct cgraph_node *first,
       tree decl = vnode->decl;
       if (DECL_EXTERNAL (decl)
          && DECL_INITIAL (decl))
-       varpool_finalize_decl (decl);
+       varpool_node::finalize_decl (decl);
       if (DECL_PRESERVE_P (decl))
        vnode->force_output = true;
       else if (lookup_attribute ("externally_visible", DECL_ATTRIBUTES (decl)))
@@ -809,9 +809,9 @@ process_function_and_variable_attributes (struct cgraph_node *first,
    visible.  */
 
 void
-varpool_finalize_decl (tree decl)
+varpool_node::finalize_decl (tree decl)
 {
-  varpool_node *node = varpool_node_for_decl (decl);
+  varpool_node *node = varpool_node::get_create (decl);
 
   gcc_assert (TREE_STATIC (decl) || DECL_EXTERNAL (decl));
 
@@ -831,12 +831,12 @@ varpool_finalize_decl (tree decl)
          || referred_to_p (node)))
     enqueue_node (node);
   if (cgraph_state >= CGRAPH_STATE_IPA_SSA)
-    varpool_analyze_node (node);
+    node->analyze ();
   /* Some frontends produce various interface variables after compilation
      finished.  */
   if (cgraph_state == CGRAPH_STATE_FINISHED
       || (!flag_toplevel_reorder && cgraph_state == CGRAPH_STATE_EXPANSION))
-    varpool_assemble_decl (node);
+    node->assemble_decl ();
 }
 
 /* EDGE is an polymorphic call.  Mark all possible targets as reachable
@@ -1055,7 +1055,7 @@ analyze_functions (void)
            {
              varpool_node *vnode = dyn_cast <varpool_node *> (node);
              if (vnode && vnode->definition && !vnode->analyzed)
-               varpool_analyze_node (vnode);
+               vnode->analyze ();
            }
 
          if (node->same_comdat_group)
@@ -1198,7 +1198,7 @@ handle_alias_pairs (void)
       else if (TREE_CODE (p->decl) == VAR_DECL
               && target_node && is_a <varpool_node *> (target_node))
        {
-         varpool_create_variable_alias (p->decl, target_node->decl);
+         varpool_node::create_alias (p->decl, target_node->decl);
          alias_pairs->unordered_remove (i);
        }
       else
@@ -2004,7 +2004,7 @@ output_in_order (void)
 
   for (i = 0; i < max; ++i)
     if (nodes[i].kind == ORDER_VAR)
-      varpool_finalize_named_section_flags (nodes[i].u.v);
+      nodes[i].u.v->finalize_named_section_flags ();
 
   for (i = 0; i < max; ++i)
     {
@@ -2016,7 +2016,7 @@ output_in_order (void)
          break;
 
        case ORDER_VAR:
-         varpool_assemble_decl (nodes[i].u.v);
+         nodes[i].u.v->assemble_decl ();
          break;
 
        case ORDER_ASM:
@@ -2259,7 +2259,7 @@ compile (void)
       output_asm_statements ();
 
       expand_all_functions ();
-      varpool_output_variables ();
+      varpool_node::output_variables ();
     }
 
   cgraph_process_new_functions ();
index 1e47dd88cd98c89c4c0841ea2e910c4cea683d56..8ac1d5f015f81291a9f52dc08f987db61c3d303a 100644 (file)
@@ -706,7 +706,7 @@ coverage_end_function (unsigned lineno_checksum, unsigned cfg_checksum)
              TREE_TYPE (var) = array_type;
              DECL_SIZE (var) = TYPE_SIZE (array_type);
              DECL_SIZE_UNIT (var) = TYPE_SIZE_UNIT (array_type);
-             varpool_finalize_decl (var);
+             varpool_node::finalize_decl (var);
            }
          
          fn_b_ctrs[i] = fn_n_ctrs[i] = 0;
@@ -1121,7 +1121,7 @@ coverage_obj_fn (vec<constructor_elt, va_gc> *ctor, tree fn,
   tree var = build_var (fn, gcov_fn_info_type, -1);
   
   DECL_INITIAL (var) = init;
-  varpool_finalize_decl (var);
+  varpool_node::finalize_decl (var);
       
   CONSTRUCTOR_APPEND_ELT (ctor, NULL,
                          build1 (ADDR_EXPR, gcov_fn_info_ptr_type, var));
@@ -1146,11 +1146,11 @@ coverage_obj_finish (vec<constructor_elt, va_gc> *ctor)
   ASM_GENERATE_INTERNAL_LABEL (name_buf, "LPBX", 1);
   DECL_NAME (fn_info_ary) = get_identifier (name_buf);
   DECL_INITIAL (fn_info_ary) = build_constructor (fn_info_ary_type, ctor);
-  varpool_finalize_decl (fn_info_ary);
+  varpool_node::finalize_decl (fn_info_ary);
   
   DECL_INITIAL (gcov_info_var)
     = build_info (TREE_TYPE (gcov_info_var), fn_info_ary);
-  varpool_finalize_decl (gcov_info_var);
+  varpool_node::finalize_decl (gcov_info_var);
 }
 
 /* Perform file-level initialization. Read in data file, generate name
index 150c74e2ef775d3fdaef74b49337d55a48cf099d..aafb91751434683106dea32bf43e5585beebe216 100644 (file)
@@ -2076,7 +2076,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
       if (TREE_CODE (olddecl) == FUNCTION_DECL)
        symbol = cgraph_node::get_create (newdecl);
       else
-       symbol = varpool_node_for_decl (newdecl);
+       symbol = varpool_node::get_create (newdecl);
       symbol->set_comdat_group (symtab_node::get
        (olddecl)->get_comdat_group ());
     }
index 90244efab45ed257dab9479a2a73d9919703e8bc..8fa31451c6064ffdb6cc7d24498a7e4ef4bd7871 100644 (file)
@@ -1804,7 +1804,7 @@ maybe_make_one_only (tree decl)
 
       if (VAR_P (decl))
        {
-          varpool_node *node = varpool_node_for_decl (decl);
+         varpool_node *node = varpool_node::get_create (decl);
          DECL_COMDAT (decl) = 1;
          /* Mark it needed so we don't forget to emit it.  */
           node->forced_by_abi = true;
@@ -1912,7 +1912,7 @@ import_export_class (tree ctype)
 static bool
 var_finalized_p (tree var)
 {
-  return varpool_node_for_decl (var)->definition;
+  return varpool_node::get_create (var)->definition;
 }
 
 /* DECL is a VAR_DECL or FUNCTION_DECL which, for whatever reason,
@@ -1933,7 +1933,7 @@ mark_needed (tree decl)
     }
   else if (TREE_CODE (decl) == VAR_DECL)
     {
-      varpool_node *node = varpool_node_for_decl (decl);
+      varpool_node *node = varpool_node::get_create (decl);
       /* C++ frontend use mark_decl_references to force COMDAT variables
          to be output that might appear dead otherwise.  */
       node->forced_by_abi = true;
@@ -2053,7 +2053,7 @@ maybe_emit_vtables (tree ctype)
        TREE_ASM_WRITTEN (vtbl) = 1;
       else if (DECL_ONE_ONLY (vtbl))
        {
-         current = varpool_node_for_decl (vtbl);
+         current = varpool_node::get_create (vtbl);
          if (last)
            current->add_to_same_comdat_group (last);
          last = current;
@@ -3661,7 +3661,7 @@ one_static_initialization_or_destruction (tree decl, tree init, bool initp)
          finish_expr_stmt (init);
          if (flag_sanitize & SANITIZE_ADDRESS)
            {
-             varpool_node *vnode = varpool_get_node (decl);
+             varpool_node *vnode = varpool_node::get (decl);
              if (vnode)
                vnode->dynamically_initialized = 1;
            }
index 8983e0dfa69fceff73c314cba1518f665a03b9b5..40508ab0cc34bcb29ba2bb2526ad92af5655b18d 100644 (file)
@@ -3491,7 +3491,7 @@ mangle_decl (const tree decl)
            n->create_same_body_alias (alias, decl);
        }
       else
-       varpool_extra_name_alias (alias, decl);
+       varpool_node::create_extra_name_alias (alias, decl);
 #endif
     }
 }
index 09e6730b37c3464e229526bc13ce1b5250393e9a..2c10fd37086dcaf34b5fb3da30edf9e907eb73e5 100644 (file)
@@ -799,7 +799,7 @@ insert_call_to_register_set (tree class_name,
   TREE_STATIC (initial) = 1;
   DECL_INITIAL (array_arg) = initial;
   relayout_decl (array_arg);
-  varpool_finalize_decl (array_arg);
+  varpool_node::finalize_decl (array_arg);
 
   arg3 = build1 (ADDR_EXPR, TYPE_POINTER_TO (TREE_TYPE (array_arg)), array_arg);
 
@@ -1253,7 +1253,7 @@ vtable_find_or_create_map_decl (tree base_type)
 
       comdat_linkage (var_decl);
 
-      varpool_finalize_decl (var_decl);
+      varpool_node::finalize_decl (var_decl);
       if (!vtable_map_node)
         vtable_map_node =
                    find_or_create_vtbl_map_node (TYPE_MAIN_VARIANT (base_type));
index 6cb43411917858dbff62ece31dc4944938e27e0e..fc6b13b904a6d6baabbde4676f420fac4b827e2a 100644 (file)
@@ -2429,7 +2429,7 @@ dbxout_expand_expr (tree expr)
          /* If this is a var that might not be actually output,
             return NULL, otherwise stabs might reference an undefined
             symbol.  */
-         varpool_node *node = varpool_get_node (expr);
+         varpool_node *node = varpool_node::get (expr);
          if (!node || !node->definition)
            return NULL;
        }
index 6fa2a7068c6569c12b7ceaf214573150bca1864c..8fd1945cf50557d674fbd3292afd427d9baba6ac 100644 (file)
@@ -15360,7 +15360,7 @@ reference_to_unused (tree * tp, int * walk_subtrees,
     return *tp;
   else if (TREE_CODE (*tp) == VAR_DECL)
     {
-      varpool_node *node = varpool_get_node (*tp);
+      varpool_node *node = varpool_node::get (*tp);
       if (!node || !node->definition)
        return *tp;
     }
@@ -18052,7 +18052,7 @@ premark_types_used_by_global_vars_helper (void **slot,
     {
       /* Ask cgraph if the global variable really is to be emitted.
          If yes, then we'll keep the DIE of ENTRY->TYPE.  */
-      varpool_node *node = varpool_get_node (entry->var_decl);
+      varpool_node *node = varpool_node::get (entry->var_decl);
       if (node && node->definition)
        {
          die->die_perennial_p = 1;
index 5e2cbdaf0c5c49008c2cb4db94fd353ac6a81b04..4e8de8235f8ec0437ec086c21e2a5dbb9776717c 100644 (file)
@@ -112,10 +112,10 @@ can_refer_decl_in_current_unit_p (tree decl, tree from_decl)
   if (!from_decl
       || TREE_CODE (from_decl) != VAR_DECL
       || (!DECL_EXTERNAL (from_decl)
-         && (vnode = varpool_get_node (from_decl)) != NULL
+         && (vnode = varpool_node::get (from_decl)) != NULL
          && vnode->definition)
       || (flag_ltrans
-         && (vnode = varpool_get_node (from_decl)) != NULL
+         && (vnode = varpool_node::get (from_decl)) != NULL
          && vnode->in_other_partition))
     return true;
   /* We are folding reference from external vtable.  The vtable may reffer
index 1bfcfa11ed082a24747c66f4c1a608726b172131..7c4151a1857fc8fed67253089281ff2906f7003a 100644 (file)
@@ -241,7 +241,7 @@ type_possibly_instantiated_p (tree t)
   vtable = BINFO_VTABLE (TYPE_BINFO (t));
   if (TREE_CODE (vtable) == POINTER_PLUS_EXPR)
     vtable = TREE_OPERAND (TREE_OPERAND (vtable, 0), 0);
-  vnode = varpool_get_node (vtable);
+  vnode = varpool_node::get (vtable);
   return vnode && vnode->definition;
 }
 
@@ -1512,7 +1512,7 @@ record_target_from_binfo (vec <cgraph_node *> &nodes,
 
          if (TREE_CODE (vtable) == POINTER_PLUS_EXPR)
            vtable = TREE_OPERAND (TREE_OPERAND (vtable, 0), 0);
-         vnode = varpool_get_node (vtable);
+         vnode = varpool_node::get (vtable);
          if (!vnode || !vnode->definition)
            return;
        }
index ddce77d09491dc8bd5dff8c64132e613bcd1ea31..4720ee9fe27975ce2eb7e04e9482bef9645ab909 100644 (file)
@@ -263,31 +263,31 @@ cgraph_externally_visible_p (struct cgraph_node *node,
   return false;
 }
 
-/* Return true when variable VNODE should be considered externally visible.  */
+/* Return true when variable should be considered externally visible.  */
 
 bool
-varpool_externally_visible_p (varpool_node *vnode)
+varpool_node::externally_visible_p (void)
 {
-  if (DECL_EXTERNAL (vnode->decl))
+  if (DECL_EXTERNAL (decl))
     return true;
 
-  if (!TREE_PUBLIC (vnode->decl))
+  if (!TREE_PUBLIC (decl))
     return false;
 
   /* If linker counts on us, we must preserve the function.  */
-  if (vnode->used_from_object_file_p ())
+  if (used_from_object_file_p ())
     return true;
 
-  if (DECL_HARD_REGISTER (vnode->decl))
+  if (DECL_HARD_REGISTER (decl))
     return true;
-  if (DECL_PRESERVE_P (vnode->decl))
+  if (DECL_PRESERVE_P (decl))
     return true;
   if (lookup_attribute ("externally_visible",
-                       DECL_ATTRIBUTES (vnode->decl)))
+                       DECL_ATTRIBUTES (decl)))
     return true;
   if (TARGET_DLLIMPORT_DECL_ATTRIBUTES
       && lookup_attribute ("dllexport",
-                          DECL_ATTRIBUTES (vnode->decl)))
+                          DECL_ATTRIBUTES (decl)))
     return true;
 
   /* See if we have linker information about symbol not being used or
@@ -296,9 +296,9 @@ varpool_externally_visible_p (varpool_node *vnode)
      Even if the linker clams the symbol is unused, never bring internal
      symbols that are declared by user as used or externally visible.
      This is needed for i.e. references from asm statements.   */
-  if (vnode->used_from_object_file_p ())
+  if (used_from_object_file_p ())
     return true;
-  if (vnode->resolution == LDPR_PREVAILING_DEF_IRONLY)
+  if (resolution == LDPR_PREVAILING_DEF_IRONLY)
     return false;
 
   /* As a special case, the COMDAT virtual tables can be unshared.
@@ -307,17 +307,17 @@ varpool_externally_visible_p (varpool_node *vnode)
      is faster for dynamic linking.  Also this match logic hidding vtables
      from LTO symbol tables.  */
   if ((in_lto_p || flag_whole_program)
-      && DECL_COMDAT (vnode->decl)
-      && comdat_can_be_unshared_p (vnode))
+      && DECL_COMDAT (decl)
+      && comdat_can_be_unshared_p (this))
     return false;
 
   /* When doing link time optimizations, hidden symbols become local.  */
   if (in_lto_p
-      && (DECL_VISIBILITY (vnode->decl) == VISIBILITY_HIDDEN
-         || DECL_VISIBILITY (vnode->decl) == VISIBILITY_INTERNAL)
+      && (DECL_VISIBILITY (decl) == VISIBILITY_HIDDEN
+         || DECL_VISIBILITY (decl) == VISIBILITY_INTERNAL)
       /* Be sure that node is defined in IR file, not in other object
         file.  In that case we don't set used_from_other_object_file.  */
-      && vnode->definition)
+      && definition)
     ;
   else if (!flag_whole_program)
     return true;
@@ -329,7 +329,7 @@ varpool_externally_visible_p (varpool_node *vnode)
      FIXME: We can do so for readonly vars with no address taken and
      possibly also for vtables since no direct pointer comparsion is done.
      It might be interesting to do so to reduce linking overhead.  */
-  if (DECL_COMDAT (vnode->decl) || DECL_WEAK (vnode->decl))
+  if (DECL_COMDAT (decl) || DECL_WEAK (decl))
     return true;
   return false;
 }
@@ -625,7 +625,7 @@ function_and_variable_visibility (bool whole_program)
     {
       if (!vnode->definition)
         continue;
-      if (varpool_externally_visible_p (vnode))
+      if (vnode->externally_visible_p ())
        vnode->externally_visible = true;
       else
        {
@@ -689,7 +689,7 @@ function_and_variable_visibility (bool whole_program)
            {
              struct pointer_set_t *visited_nodes = pointer_set_create ();
 
-             varpool_get_constructor (vnode);
+             vnode->get_constructor ();
              walk_tree (&DECL_INITIAL (vnode->decl),
                         update_vtable_references, NULL, visited_nodes);
              pointer_set_destroy (visited_nodes);
index 42dce671ab38f18e51e814093698526fb6bdd193..8198b174920f97cc2388c57e3fefc47d21f5de4c 100644 (file)
--- a/gcc/ipa.c
+++ b/gcc/ipa.c
@@ -313,7 +313,7 @@ symtab_remove_unreachable_nodes (bool before_inlining_p, FILE *file)
 
   /* Mark variables that are obviously needed.  */
   FOR_EACH_DEFINED_VARIABLE (vnode)
-    if (!varpool_can_remove_if_no_refs (vnode)
+    if (!vnode->can_remove_if_no_refs_p()
        && !vnode->in_other_partition)
       {
        pointer_set_insert (reachable, vnode);
@@ -548,7 +548,7 @@ symtab_remove_unreachable_nodes (bool before_inlining_p, FILE *file)
 
          /* Keep body if it may be useful for constant folding.  */
          if ((init = ctor_for_folding (vnode->decl)) == error_mark_node)
-           varpool_remove_initializer (vnode);
+           vnode->remove_initializer ();
          else
            DECL_INITIAL (vnode->decl) = init;
          vnode->remove_all_references ();
@@ -611,7 +611,7 @@ process_references (varpool_node *vnode,
   int i;
   struct ipa_ref *ref;
 
-  if (!varpool_all_refs_explicit_p (vnode)
+  if (!vnode->all_refs_explicit_p ()
       || TREE_THIS_VOLATILE (vnode->decl))
     *explicit_refs = false;
 
@@ -702,7 +702,7 @@ ipa_discover_readonly_nonaddressable_vars (void)
          {
            if (TREE_ADDRESSABLE (vnode->decl) && dump_file)
              fprintf (dump_file, " %s (non-addressable)", vnode->name ());
-           varpool_for_node_and_aliases (vnode, clear_addressable_bit, NULL, true);
+           vnode->call_for_node_and_aliases (clear_addressable_bit, NULL, true);
          }
        if (!address_taken && !written
            /* Making variable in explicit section readonly can cause section
@@ -712,13 +712,13 @@ ipa_discover_readonly_nonaddressable_vars (void)
          {
            if (!TREE_READONLY (vnode->decl) && dump_file)
              fprintf (dump_file, " %s (read-only)", vnode->name ());
-           varpool_for_node_and_aliases (vnode, set_readonly_bit, NULL, true);
+           vnode->call_for_node_and_aliases (set_readonly_bit, NULL, true);
          }
        if (!vnode->writeonly && !read && !address_taken && written)
          {
            if (dump_file)
              fprintf (dump_file, " %s (write-only)", vnode->name ());
-           varpool_for_node_and_aliases (vnode, set_writeonly_bit, NULL, true);
+           vnode->call_for_node_and_aliases (set_writeonly_bit, NULL, true);
          }
       }
   if (dump_file)
@@ -1143,7 +1143,7 @@ propagate_single_user (varpool_node *vnode, cgraph_node *function,
 
   /* If node is an alias, first meet with its target.  */
   if (vnode->alias)
-    function = meet (function, varpool_alias_target (vnode), single_user_map);
+    function = meet (function, vnode->get_alias_target (), single_user_map);
 
   /* Check all users and see if they correspond to a single function.  */
   for (i = 0; vnode->iterate_referring (i, ref) && function != BOTTOM; i++)
@@ -1176,7 +1176,7 @@ ipa_single_use (void)
   hash_map<varpool_node *, cgraph_node *> single_user_map;
 
   FOR_EACH_DEFINED_VARIABLE (var)
-    if (!varpool_all_refs_explicit_p (var))
+    if (!var->all_refs_explicit_p ())
       var->aux = BOTTOM;
     else
       {
index 8e5702f6fe2aa07a8cee64db8d7e0e0d5cfa1e49..8ae7e4269cd14deb57d2cd3c3fced394f465b904 100644 (file)
@@ -79,7 +79,7 @@ compile_resource_data (const char *name, const char *buffer, int length)
   layout_decl (decl, 0);
   pushdecl (decl);
   rest_of_decl_compilation (decl, global_bindings_p (), 0);
-  varpool_finalize_decl (decl);
+  varpool_node::finalize_decl (decl);
 
   vec_safe_push (resources, decl);
 }
index 223334928a6a9b06157a922bf858e3a9669c1b46..b1fcf67a02584af6ef66f258208c42149662d215 100644 (file)
@@ -853,7 +853,7 @@ compute_ltrans_boundary (lto_symtab_encoder_t in_encoder)
       if (DECL_ABSTRACT_ORIGIN (vnode->decl))
        {
          varpool_node *origin_node
-           = varpool_get_node (DECL_ABSTRACT_ORIGIN (vnode->decl));
+           = varpool_node::get (DECL_ABSTRACT_ORIGIN (vnode->decl));
          lto_set_symtab_encoder_in_partition (encoder, origin_node);
        }
     }
@@ -867,7 +867,7 @@ compute_ltrans_boundary (lto_symtab_encoder_t in_encoder)
        {
          if (!lto_symtab_encoder_encode_initializer_p (encoder,
                                                        vnode)
-             && varpool_ctor_useable_for_folding_p (vnode))
+             && vnode->ctor_useable_for_folding_p ())
            {
              lto_set_symtab_encoder_encode_initializer (encoder, vnode);
              add_references (encoder, vnode);
@@ -1242,7 +1242,7 @@ input_varpool_node (struct lto_file_decl_data *file_data,
   /* Declaration of functions can be already merged with a declaration
      from other input file.  We keep cgraph unmerged until after streaming
      of ipa passes is done.  Alays forcingly create a fresh node.  */
-  node = varpool_create_empty_node ();
+  node = varpool_node::create_empty ();
   node->decl = var_decl;
   node->register_symbol ();
 
index 001df9b96869782c2c37a0a4bd678fa33ef22067..75332f94928323f80de7fe7914348575855c5115 100644 (file)
@@ -335,7 +335,7 @@ get_symbol_initial_value (lto_symtab_encoder_t encoder, tree expr)
       /* Extra section needs about 30 bytes; do not produce it for simple
         scalar values.  */
       if (TREE_CODE (DECL_INITIAL (expr)) == CONSTRUCTOR
-         || !(vnode = varpool_get_node (expr))
+         || !(vnode = varpool_node::get (expr))
          || !lto_symtab_encoder_encode_initializer_p (encoder, vnode))
         initial = error_mark_node;
     }
@@ -2316,7 +2316,7 @@ write_symbol (struct streamer_tree_cache_d *cache,
 
       /* When something is defined, it should have node attached.  */
       gcc_assert (alias || TREE_CODE (t) != VAR_DECL
-                 || varpool_get_node (t)->definition);
+                 || varpool_node::get (t)->definition);
       gcc_assert (alias || TREE_CODE (t) != FUNCTION_DECL
                  || (cgraph_node::get (t)
                      && cgraph_node::get (t)->definition));
index 8f2e236beb1ce4936d9555e7dc59cdc4368ef063..cb08a88ad0e2f306917e0eaf156f978e60dc0f89 100644 (file)
@@ -96,8 +96,8 @@ add_references_to_partition (ltrans_partition part, symtab_node *node)
        Recursively look into the initializers of the constant variable and add
        references, too.  */
     else if (is_a <varpool_node *> (ref->referred)
-            && varpool_ctor_useable_for_folding_p
-              (dyn_cast <varpool_node *> (ref->referred))
+            && dyn_cast <varpool_node *> (ref->referred)
+              ->ctor_useable_for_folding_p ()
             && !lto_symtab_encoder_in_partition_p (part->encoder, ref->referred))
       {
        if (!part->initializers_visited)
@@ -203,7 +203,7 @@ contained_in_symbol (symtab_node *node)
       return cnode;
     }
   else if (varpool_node *vnode = dyn_cast <varpool_node *> (node))
-    return varpool_variable_node (vnode, NULL);
+    return vnode->ultimate_alias_target ();
   return node;
 }
 
@@ -622,7 +622,7 @@ lto_balanced_map (int n_lto_partitions)
                   to be removed.  Coupling with objects they refer to only helps to reduce
                   number of symbols promoted to hidden.  */
                if (!symbol_partitioned_p (vnode) && flag_toplevel_reorder
-                   && !varpool_can_remove_if_no_refs (vnode)
+                   && !vnode->can_remove_if_no_refs_p ()
                    && vnode->get_partitioning_class () == SYMBOL_PARTITION)
                  add_symbol_to_partition (partition, vnode);
                index = lto_symtab_encoder_lookup (partition->encoder,
index ab515cf59f20759bef48c8b1efb7f49d20735377..b46693b48dc035e910781d65adc974e53e1377d0 100644 (file)
@@ -4835,7 +4835,7 @@ expand_omp_taskreg (struct omp_region *region)
        if (TREE_CODE (t) == VAR_DECL
            && TREE_STATIC (t)
            && !DECL_EXTERNAL (t))
-         varpool_finalize_decl (t);
+         varpool_node::finalize_decl (t);
       DECL_SAVED_TREE (child_fn) = NULL;
       /* We'll create a CFG for child_fn, so no gimple body is needed.  */
       gimple_set_body (child_fn, NULL);
@@ -7960,7 +7960,7 @@ expand_omp_target (struct omp_region *region)
        if (TREE_CODE (t) == VAR_DECL
            && TREE_STATIC (t)
            && !DECL_EXTERNAL (t))
-         varpool_finalize_decl (t);
+         varpool_node::finalize_decl (t);
       DECL_SAVED_TREE (child_fn) = NULL;
       /* We'll create a CFG for child_fn, so no gimple body is needed.  */
       gimple_set_body (child_fn, NULL);
@@ -8898,7 +8898,7 @@ lower_omp_critical (gimple_stmt_iterator *gsi_p, omp_context *ctx)
          DECL_COMMON (decl) = 1;
          DECL_ARTIFICIAL (decl) = 1;
          DECL_IGNORED_P (decl) = 1;
-         varpool_finalize_decl (decl);
+         varpool_node::finalize_decl (decl);
 
          splay_tree_insert (critical_name_mutexes, (splay_tree_key) name,
                             (splay_tree_value) decl);
index 96d95ac605a65464197231db0671aeae403e8ad7..38485a75f0c71b359810000458ca2d15fd8e27cb 100644 (file)
@@ -239,7 +239,7 @@ rest_of_decl_compilation (tree decl,
          if (in_lto_p && !at_end)
            ;
          else if (finalize && TREE_CODE (decl) != FUNCTION_DECL)
-           varpool_finalize_decl (decl);
+           varpool_node::finalize_decl (decl);
        }
 
 #ifdef ASM_FINISH_DECLARE_OBJECT
@@ -267,7 +267,7 @@ rest_of_decl_compilation (tree decl,
     ;
   else if (TREE_CODE (decl) == VAR_DECL && !DECL_EXTERNAL (decl)
           && TREE_STATIC (decl))
-    varpool_node_for_decl (decl);
+    varpool_node::get_create (decl);
 }
 
 /* Called after finishing a record, union or enumeral type.  */
index 8f04758da0a94144de2ffc4d4b5cf6145853463c..a93c299ec234cea448b721d0486ce40275c698ee 100644 (file)
@@ -1507,8 +1507,7 @@ enum availability symtab_node::get_availability (void)
   if (is_a <cgraph_node *> (this))
     return dyn_cast <cgraph_node *> (this)->get_availability ();
   else
-    return cgraph_variable_initializer_availability
-      (dyn_cast <varpool_node *> (this));
+    return dyn_cast <varpool_node *> (this)->get_availability ();;
 }
 
 
@@ -1790,7 +1789,7 @@ symtab_node::noninterposable_alias (void)
     {
       TREE_READONLY (new_decl) = TREE_READONLY (node->decl);
       DECL_INITIAL (new_decl) = error_mark_node;
-      new_node = varpool_create_variable_alias (new_decl, node->decl);
+      new_node = varpool_node::create_alias (new_decl, node->decl);
     }
   new_node->resolve_alias (node);
   gcc_assert (decl_binds_to_current_def_p (new_decl)
index 1c9befdaa60ff788f95cc151786d624fcf22bf0a..2886df71bc05325b2501110d446a4fcbcb4af65b 100644 (file)
@@ -393,7 +393,7 @@ wrapup_global_declaration_2 (tree decl)
     {
       varpool_node *node;
       bool needed = true;
-      node = varpool_get_node (decl);
+      node = varpool_node::get (decl);
 
       if (!node && flag_ltrans)
        needed = false;
index f33b52f530549e530a6efd222b9a8c8ac83b26c5..5633398e96b134dddc259ad15dfcabc70f8cebe0 100644 (file)
@@ -4843,7 +4843,8 @@ ipa_tm_create_version_alias (struct cgraph_node *node, void *data)
 
   /* Perform the same remapping to the comdat group.  */
   if (DECL_ONE_ONLY (new_decl))
-    varpool_get_node (new_decl)->set_comdat_group (tm_mangle (decl_comdat_group_id (old_decl)));
+    varpool_node::get (new_decl)->set_comdat_group
+      (tm_mangle (decl_comdat_group_id (old_decl)));
 
   new_node = cgraph_node::create_same_body_alias (new_decl, info->new_decl);
   new_node->tm_clone = true;
@@ -4883,7 +4884,8 @@ ipa_tm_create_version (struct cgraph_node *old_node)
 
   /* Perform the same remapping to the comdat group.  */
   if (DECL_ONE_ONLY (new_decl))
-    varpool_get_node (new_decl)->set_comdat_group (tm_mangle (DECL_COMDAT_GROUP (old_decl)));
+    varpool_node::get (new_decl)->set_comdat_group
+      (tm_mangle (DECL_COMDAT_GROUP (old_decl)));
 
   gcc_assert (!old_node->ipa_transforms_to_apply.exists ());
   new_node = old_node->create_version_clone (new_decl, vNULL, NULL);
index d2381384cf924b9db56540b1343d1deec90cc3a6..6fee8a48a90416acf4215957ec809e2a47e91fca 100644 (file)
@@ -8500,7 +8500,7 @@ execute_fixup_cfg (void)
 
              if (TREE_CODE (lhs) == VAR_DECL
                  && (TREE_STATIC (lhs) || DECL_EXTERNAL (lhs))
-                 && varpool_get_node (lhs)->writeonly)
+                 && varpool_node::get (lhs)->writeonly)
                {
                  unlink_stmt_vdef (stmt);
                  gsi_remove (&gsi, true);
@@ -8518,7 +8518,7 @@ execute_fixup_cfg (void)
 
              if (TREE_CODE (lhs) == VAR_DECL
                  && (TREE_STATIC (lhs) || DECL_EXTERNAL (lhs))
-                 && varpool_get_node (lhs)->writeonly)
+                 && varpool_node::get (lhs)->writeonly)
                {
                  gimple_call_set_lhs (stmt, NULL);
                  update_stmt (stmt);
index ee5c3b4c7b30b68618482795161b8aa61bee2a8d..df9a6fcaf7c8bac47cf7781240c2ab042be4a144 100644 (file)
@@ -2707,7 +2707,7 @@ tree_could_trap_p (tree expr)
          varpool_node *node;
          if (!DECL_EXTERNAL (expr))
            return false;
-         node = varpool_variable_node (varpool_get_node (expr), NULL);
+         node = varpool_node::get (expr)->ultimate_alias_target ();
          if (node && node->in_other_partition)
            return false;
          return true;
index 3e2296de9aeb73e92c3b130a94fbb4639d349879..89197c774aab5d469e1ef26847c42743b6ecf7ce 100644 (file)
@@ -270,7 +270,7 @@ get_emutls_init_templ_addr (tree decl)
   /* Create varpool node for the new variable and finalize it if it is
      not external one.  */
   if (DECL_EXTERNAL (to))
-    varpool_node_for_decl (to);
+    varpool_node::get_create (to);
   else
     varpool_add_new_variable (to);
   return build_fold_addr_expr (to);
@@ -340,13 +340,13 @@ new_emutls_decl (tree decl, tree alias_of)
   /* Create varpool node for the new variable and finalize it if it is
      not external one.  */
   if (DECL_EXTERNAL (to))
-    varpool_node_for_decl (to);
+    varpool_node::get_create (to);
   else if (!alias_of)
     varpool_add_new_variable (to);
   else 
-    varpool_create_variable_alias (to,
-                                  varpool_node_for_asm
-                                   (DECL_ASSEMBLER_NAME (DECL_VALUE_EXPR (alias_of)))->decl);
+    varpool_node::create_alias (to,
+                               varpool_node::get_for_asmname
+                                 (DECL_ASSEMBLER_NAME (DECL_VALUE_EXPR (alias_of)))->decl);
   return to;
 }
 
@@ -358,7 +358,7 @@ emutls_index (tree decl)
 {
   varpool_node_set_iterator i;
   
-  i = varpool_node_set_find (tls_vars, varpool_get_node (decl));
+  i = varpool_node_set_find (tls_vars, varpool_node::get (decl));
   gcc_assert (i.index != ~0u);
 
   return i.index;
@@ -709,9 +709,9 @@ create_emultls_var (varpool_node *var, void *data)
 
   cdecl = new_emutls_decl (var->decl,
                           var->alias && var->analyzed
-                          ? varpool_alias_target (var)->decl : NULL);
+                          ? var->get_alias_target ()->decl : NULL);
 
-  cvar = varpool_get_node (cdecl);
+  cvar = varpool_node::get (cdecl);
   control_vars.quick_push (cvar);
 
   if (!var->alias)
@@ -754,7 +754,7 @@ ipa_lower_emutls (void)
                             || DECL_EXTERNAL (var->decl));
        varpool_node_set_add (tls_vars, var);
        if (var->alias && var->definition)
-         varpool_node_set_add (tls_vars, varpool_variable_node (var, NULL));
+         varpool_node_set_add (tls_vars, var->ultimate_alias_target ());
       }
 
   /* If we found no TLS variables, then there is no further work to do.  */
@@ -780,7 +780,7 @@ ipa_lower_emutls (void)
       if (var->alias && !var->analyzed)
        any_aliases = true;
       else if (!var->alias)
-       varpool_for_node_and_aliases (var, create_emultls_var, &ctor_body, true);
+       var->call_for_node_and_aliases (create_emultls_var, &ctor_body, true);
     }
 
   /* If there were any aliases, then frob the alias_pairs vector.  */
index d384e3dd018ac59ef9784c6d1f059fd451bd5e0e..6ab06e69c3f02a895bb286046a323bafbec5ac78 100644 (file)
@@ -112,7 +112,7 @@ init_ic_make_global_vars (void)
   if (targetm.have_tls)
     set_decl_tls_model (ic_void_ptr_var, decl_default_tls_model (ic_void_ptr_var));
 
-  varpool_finalize_decl (ic_void_ptr_var);
+  varpool_node::finalize_decl (ic_void_ptr_var);
 
   gcov_type_ptr = build_pointer_type (get_gcov_type ());
   /* Workaround for binutils bug 14342.  Once it is fixed, remove lto path.  */
@@ -142,7 +142,7 @@ init_ic_make_global_vars (void)
   if (targetm.have_tls)
     set_decl_tls_model (ic_gcov_type_ptr_var, decl_default_tls_model (ic_gcov_type_ptr_var));
 
-  varpool_finalize_decl (ic_gcov_type_ptr_var);
+  varpool_node::finalize_decl (ic_gcov_type_ptr_var);
 }
 
 /* Create the type and function decls for the interface with gcov.  */
index 470a324a9f3e4edc70d56dbd043b2b49c8aea8a2..1879fc0b8ff23346bd546e7b854cf2ad2d1767f9 100644 (file)
@@ -2931,10 +2931,10 @@ get_constraint_for_ssa_var (tree t, vec<ce_s> *results, bool address_p)
   if (TREE_CODE (t) == VAR_DECL
       && (TREE_STATIC (t) || DECL_EXTERNAL (t)))
     {
-      varpool_node *node = varpool_get_node (t);
+      varpool_node *node = varpool_node::get (t);
       if (node && node->alias && node->analyzed)
        {
-         node = varpool_variable_node (node, NULL);
+         node = node->ultimate_alias_target ();
          t = node->decl;
        }
     }
@@ -5671,7 +5671,7 @@ create_variable_info_for_1 (tree decl, const char *name)
         in IPA mode.  Else we'd have to parse arbitrary initializers.  */
       && !(in_ipa_mode
           && is_global_var (decl)
-          && varpool_get_constructor (varpool_get_node (decl))))
+          && varpool_node::get (decl)->get_constructor ()))
     {
       fieldoff_s *fo = NULL;
       bool notokay = false;
@@ -5789,21 +5789,21 @@ create_variable_info_for (tree decl, const char *name)
         for it.  */
       else
        {
-         varpool_node *vnode = varpool_get_node (decl);
+         varpool_node *vnode = varpool_node::get (decl);
 
          /* For escaped variables initialize them from nonlocal.  */
-         if (!varpool_all_refs_explicit_p (vnode))
+         if (!vnode->all_refs_explicit_p ())
            make_copy_constraint (vi, nonlocal_id);
 
          /* If this is a global variable with an initializer and we are in
             IPA mode generate constraints for it.  */
-         if (varpool_get_constructor (vnode)
+         if (vnode->get_constructor ()
              && vnode->definition)
            {
              auto_vec<ce_s> rhsc;
              struct constraint_expr lhs, *rhsp;
              unsigned i;
-             get_constraint_for_rhs (varpool_get_constructor (vnode), &rhsc);
+             get_constraint_for_rhs (vnode->get_constructor (), &rhsc);
              lhs.var = vi->id;
              lhs.offset = 0;
              lhs.type = SCALAR;
@@ -5811,7 +5811,7 @@ create_variable_info_for (tree decl, const char *name)
                process_constraint (new_constraint (lhs, *rhsp));
              /* If this is a variable that escapes from the unit
                 the initializer escapes as well.  */
-             if (!varpool_all_refs_explicit_p (vnode))
+             if (!vnode->all_refs_explicit_p ())
                {
                  lhs.var = escaped_id;
                  lhs.offset = 0;
index 636e8ee7c3dc7d51e73a36a5e44248cd964785f6..09c668e3415cd3817a31ec0ff055895bed678d3d 100644 (file)
@@ -1074,7 +1074,7 @@ build_one_array (gimple swtch, int num, tree arr_index_type, gimple phi,
       DECL_ARTIFICIAL (decl) = 1;
       TREE_CONSTANT (decl) = 1;
       TREE_READONLY (decl) = 1;
-      varpool_finalize_decl (decl);
+      varpool_node::finalize_decl (decl);
 
       fetch = build4 (ARRAY_REF, value_type, decl, tidx, NULL_TREE,
                      NULL_TREE);
index 4ae31f4efdf2e26ba76bd505007fb99df0b5f9e2..51ef63b6bb2fdc307d9db545fbea450286d0f1b9 100644 (file)
@@ -644,7 +644,7 @@ set_decl_section_name (tree node, const char *value)
        return;
     }
   else if (TREE_CODE (node) == VAR_DECL)
-    snode = varpool_node_for_decl (node);
+    snode = varpool_node::get_create (node);
   else
     snode = cgraph_node::get_create (node);
   snode->set_section (value);
@@ -654,7 +654,7 @@ set_decl_section_name (tree node, const char *value)
 enum tls_model
 decl_tls_model (const_tree node)
 {
-  struct varpool_node *snode = varpool_get_node (node);
+  struct varpool_node *snode = varpool_node::get (node);
   if (!snode)
     return TLS_MODEL_NONE;
   return snode->tls_model;
@@ -668,12 +668,12 @@ set_decl_tls_model (tree node, enum tls_model model)
 
   if (model == TLS_MODEL_NONE)
     {
-      vnode = varpool_get_node (node);
+      vnode = varpool_node::get (node);
       if (!vnode)
        return;
     }
   else
-    vnode = varpool_node_for_decl (node);
+    vnode = varpool_node::get_create (node);
   vnode->tls_model = model;
 }
 
@@ -6523,7 +6523,7 @@ decl_init_priority_insert (tree decl, priority_type priority)
        return;
     }
   else if (TREE_CODE (decl) == VAR_DECL)
-    snode = varpool_node_for_decl (decl);
+    snode = varpool_node::get_create (decl);
   else
     snode = cgraph_node::get_create (decl);
   snode->set_init_priority (priority);
index fd9bf20a30d8f35863143d4697d07f037c646dc0..4e7e4878c6683969ece932fa3d65e37b576d78ac 100644 (file)
@@ -295,10 +295,10 @@ ubsan_type_descriptor (tree type, enum ubsan_print_style pstyle)
 
   tree decl = decl_for_type_lookup (type);
   /* It is possible that some of the earlier created DECLs were found
-     unused, in that case they weren't emitted and varpool_get_node
+     unused, in that case they weren't emitted and varpool_node::get
      returns NULL node on them.  But now we really need them.  Thus,
      renew them here.  */
-  if (decl != NULL_TREE && varpool_get_node (decl))
+  if (decl != NULL_TREE && varpool_node::get (decl))
     return build_fold_addr_expr (decl);
 
   tree dtype = ubsan_type_descriptor_type ();
@@ -441,7 +441,7 @@ ubsan_type_descriptor (tree type, enum ubsan_print_style pstyle)
   TREE_CONSTANT (ctor) = 1;
   TREE_STATIC (ctor) = 1;
   DECL_INITIAL (decl) = ctor;
-  varpool_finalize_decl (decl);
+  varpool_node::finalize_decl (decl);
 
   /* Save the VAR_DECL into the hash table.  */
   decl_for_type_insert (type, decl);
@@ -553,7 +553,7 @@ ubsan_create_data (const char *name, const location_t *ploc,
   TREE_CONSTANT (ctor) = 1;
   TREE_STATIC (ctor) = 1;
   DECL_INITIAL (var) = ctor;
-  varpool_finalize_decl (var);
+  varpool_node::finalize_decl (var);
 
   return var;
 }
index 7757995f41f95f4c9c60cec731005d41856df1a9..275b65feeda0b7b4b5393f44cd7cf0644258876a 100644 (file)
@@ -2394,7 +2394,7 @@ mark_decl_referenced (tree decl)
     }
   else if (TREE_CODE (decl) == VAR_DECL)
     {
-      varpool_node *node = varpool_node_for_decl (decl);
+      varpool_node *node = varpool_node::get_create (decl);
       /* C++ frontend use mark_decl_references to force COMDAT variables
          to be output that might appear dead otherwise.  */
       node->force_output = true;
@@ -3400,7 +3400,7 @@ tree_output_constant_def (tree exp)
     }
 
   decl = SYMBOL_REF_DECL (XEXP (desc->rtl, 0));
-  varpool_finalize_decl (decl);
+  varpool_node::finalize_decl (decl);
   return decl;
 }
 \f
@@ -5634,7 +5634,7 @@ assemble_alias (tree decl, tree target)
   if (TREE_CODE (decl) == FUNCTION_DECL)
     cgraph_node::get_create (decl)->alias = true;
   else
-    varpool_node_for_decl (decl)->alias = true;
+    varpool_node::get_create (decl)->alias = true;
 
   /* If the target has already been emitted, we don't have to queue the
      alias.  This saves a tad of memory.  */
@@ -5878,7 +5878,7 @@ make_decl_one_only (tree decl, tree comdat_group)
   TREE_PUBLIC (decl) = 1;
 
   if (TREE_CODE (decl) == VAR_DECL)
-    symbol = varpool_node_for_decl (decl);
+    symbol = varpool_node::get_create (decl);
   else
     symbol = cgraph_node::get_create (decl);
 
@@ -6692,7 +6692,7 @@ default_binds_local_p_1 (const_tree exp, int shlib)
   if (TREE_CODE (exp) == VAR_DECL && TREE_PUBLIC (exp)
       && (TREE_STATIC (exp) || DECL_EXTERNAL (exp)))
     {
-      varpool_node *vnode = varpool_get_node (exp);
+      varpool_node *vnode = varpool_node::get (exp);
       if (vnode && (resolution_local_p (vnode->resolution) || vnode->in_other_partition))
        resolved_locally = true;
       if (vnode
@@ -6785,7 +6785,7 @@ decl_binds_to_current_def_p (const_tree decl)
   if (TREE_CODE (decl) == VAR_DECL
       && (TREE_STATIC (decl) || DECL_EXTERNAL (decl)))
     {
-      varpool_node *vnode = varpool_get_node (decl);
+      varpool_node *vnode = varpool_node::get (decl);
       if (vnode
          && vnode->resolution != LDPR_UNKNOWN)
        return resolution_to_local_definition_p (vnode->resolution);
index 6b31e73b072f105607f65b1c3fdb751c76bd3e17..74117e2d60bd0c2853eacf163ff9f1eb816c51ca 100644 (file)
@@ -140,7 +140,7 @@ varpool_call_variable_insertion_hooks (varpool_node *node)
 /* Allocate new callgraph node and insert it into basic data structures.  */
 
 varpool_node *
-varpool_create_empty_node (void)
+varpool_node::create_empty (void)
 {   
   varpool_node *node = ggc_cleared_alloc<varpool_node> ();
   node->type = SYMTAB_VARIABLE;
@@ -149,14 +149,14 @@ varpool_create_empty_node (void)
 
 /* Return varpool node assigned to DECL.  Create new one when needed.  */
 varpool_node *
-varpool_node_for_decl (tree decl)
+varpool_node::get_create (tree decl)
 {
-  varpool_node *node = varpool_get_node (decl);
+  varpool_node *node = varpool_node::get (decl);
   gcc_checking_assert (TREE_CODE (decl) == VAR_DECL);
   if (node)
     return node;
 
-  node = varpool_create_empty_node ();
+  node = varpool_node::create_empty ();
   node->decl = decl;
   node->register_symbol ();
   return node;
@@ -176,19 +176,19 @@ varpool_node::remove (void)
   /* Keep constructor when it may be used for folding. We remove
      references to external variables before final compilation.  */
   else if (DECL_INITIAL (decl) && DECL_INITIAL (decl) != error_mark_node
-          && !varpool_ctor_useable_for_folding_p (this))
-    varpool_remove_initializer (this);
+          && !ctor_useable_for_folding_p ())
+    remove_initializer ();
   ggc_free (this);
 }
 
-/* Renove node initializer when it is no longer needed.  */
+/* Remove node initializer when it is no longer needed.  */
 void
-varpool_remove_initializer (varpool_node *node)
+varpool_node::remove_initializer (void)
 {
-  if (DECL_INITIAL (node->decl)
-      && !DECL_IN_CONSTANT_POOL (node->decl)
+  if (DECL_INITIAL (decl)
+      && !DECL_IN_CONSTANT_POOL (decl)
       /* Keep vtables for BINFO folding.  */
-      && !DECL_VIRTUAL_P (node->decl)
+      && !DECL_VIRTUAL_P (decl)
       /* FIXME: http://gcc.gnu.org/PR55395 */
       && debug_info_level == DINFO_LEVEL_NONE
       /* When doing declaration merging we have duplicate
@@ -196,17 +196,17 @@ varpool_remove_initializer (varpool_node *node)
         the boides, or we will end up remiving
         wrong one.  */
       && cgraph_state != CGRAPH_LTO_STREAMING)
-    DECL_INITIAL (node->decl) = error_mark_node;
+    DECL_INITIAL (decl) = error_mark_node;
 }
 
-/* Dump given cgraph node.  */
+/* Dump given varpool node to F.  */
 void
 varpool_node::dump (FILE *f)
 {
   dump_base (f);
   fprintf (f, "  Availability: %s\n",
           cgraph_function_flags_ready
-          ? cgraph_availability_names[cgraph_variable_initializer_availability (this)]
+          ? cgraph_availability_names[get_availability ()]
           : "not-ready");
   fprintf (f, "  Varpool flags:");
   if (DECL_INITIAL (decl))
@@ -217,7 +217,7 @@ varpool_node::dump (FILE *f)
     fprintf (f, " used-by-single-function");
   if (TREE_READONLY (decl))
     fprintf (f, " read-only");
-  if (varpool_ctor_useable_for_folding_p (this))
+  if (ctor_useable_for_folding_p ())
     fprintf (f, " const-value-known");
   if (writeonly)
     fprintf (f, " write-only");
@@ -226,9 +226,16 @@ varpool_node::dump (FILE *f)
   fprintf (f, "\n");
 }
 
+
+/* Dump given varpool node to stderr.  */
+void varpool_node::debug (void)
+{
+  varpool_node::dump (stderr);
+}
+
 /* Dump the variable pool to F.  */
 void
-dump_varpool (FILE *f)
+varpool_node::dump_varpool (FILE *f)
 {
   varpool_node *node;
 
@@ -240,14 +247,14 @@ dump_varpool (FILE *f)
 /* Dump the variable pool to stderr.  */
 
 DEBUG_FUNCTION void
-debug_varpool (void)
+varpool_node::debug_varpool (void)
 {
   dump_varpool (stderr);
 }
 
 /* Given an assembler name, lookup node.  */
 varpool_node *
-varpool_node_for_asm (tree asmname)
+varpool_node::get_for_asmname (tree asmname)
 {
   if (symtab_node *node = symtab_node_for_asm (asmname))
     return dyn_cast <varpool_node *> (node);
@@ -255,23 +262,23 @@ varpool_node_for_asm (tree asmname)
     return NULL;
 }
 
-/* When doing LTO, read NODE's constructor from disk if it is not already present.  */
+/* When doing LTO, read variable's constructor from disk if
+   it is not already present.  */
 
 tree
-varpool_get_constructor (struct varpool_node *node)
+varpool_node::get_constructor (void)
 {
   struct lto_file_decl_data *file_data;
   const char *data, *name;
   size_t len;
-  tree decl = node->decl;
 
-  if (DECL_INITIAL (node->decl) != error_mark_node
+  if (DECL_INITIAL (decl) != error_mark_node
       || !in_lto_p)
-    return DECL_INITIAL (node->decl);
+    return DECL_INITIAL (decl);
 
   timevar_push (TV_IPA_LTO_CTORS_IN);
 
-  file_data = node->lto_file_data;
+  file_data = lto_file_data;
   name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
 
   /* We may have renamed the declaration, e.g., a static function.  */
@@ -284,29 +291,29 @@ varpool_get_constructor (struct varpool_node *node)
                 file_data->file_name,
                 name);
 
-  lto_input_variable_constructor (file_data, node, data);
+  lto_input_variable_constructor (file_data, this, data);
   lto_stats.num_function_bodies++;
   lto_free_section_data (file_data, LTO_section_function_body, name,
                         data, len);
-  lto_free_function_in_decl_state_for_node (node);
+  lto_free_function_in_decl_state_for_node (this);
   timevar_pop (TV_IPA_LTO_CTORS_IN);
-  return DECL_INITIAL (node->decl);
+  return DECL_INITIAL (decl);
 }
 
-/* Return ture if NODE has constructor that can be used for folding.  */
+/* Return true if variable has constructor that can be used for folding.  */
 
 bool
-varpool_ctor_useable_for_folding_p (varpool_node *node)
+varpool_node::ctor_useable_for_folding_p (void)
 {
-  varpool_node *real_node = node;
+  varpool_node *real_node = this;
 
   if (real_node->alias && real_node->definition)
-    real_node = varpool_variable_node (node);
+    real_node = ultimate_alias_target ();
 
-  if (TREE_CODE (node->decl) == CONST_DECL
-      || DECL_IN_CONSTANT_POOL (node->decl))
+  if (TREE_CODE (decl) == CONST_DECL
+      || DECL_IN_CONSTANT_POOL (decl))
     return true;
-  if (TREE_THIS_VOLATILE (node->decl))
+  if (TREE_THIS_VOLATILE (decl))
     return false;
 
   /* If we do not have a constructor, we can't use it.  */
@@ -316,7 +323,7 @@ varpool_ctor_useable_for_folding_p (varpool_node *node)
 
   /* Vtables are defined by their types and must match no matter of interposition
      rules.  */
-  if (DECL_VIRTUAL_P (node->decl))
+  if (DECL_VIRTUAL_P (decl))
     {
       /* The C++ front end creates VAR_DECLs for vtables of typeinfo
         classes not defined in the current TU so that it can refer
@@ -327,14 +334,14 @@ varpool_ctor_useable_for_folding_p (varpool_node *node)
   /* Alias of readonly variable is also readonly, since the variable is stored
      in readonly memory.  We also accept readonly aliases of non-readonly
      locations assuming that user knows what he is asking for.  */
-  if (!TREE_READONLY (node->decl) && !TREE_READONLY (real_node->decl))
+  if (!TREE_READONLY (decl) && !TREE_READONLY (real_node->decl))
     return false;
 
   /* Variables declared 'const' without an initializer
      have zero as the initializer if they may not be
      overridden at link or run time.  */
   if (!DECL_INITIAL (real_node->decl)
-      && (DECL_EXTERNAL (node->decl) || decl_replaceable_p (node->decl)))
+      && (DECL_EXTERNAL (decl) || decl_replaceable_p (decl)))
     return false;
 
   /* Variables declared `const' with an initializer are considered
@@ -345,9 +352,9 @@ varpool_ctor_useable_for_folding_p (varpool_node *node)
   return true;
 }
 
-/* If DECL is constant variable and its initial value is known (so we can
-   do constant folding), return its constructor (DECL_INITIAL). This may
-   be an expression or NULL when DECL is initialized to 0.
+/* If DECLARATION is constant variable and its initial value is known
+   (so we can do constant folding), return its constructor (DECL_INITIAL).
+   This may be an expression or NULL when DECL is initialized to 0.
    Return ERROR_MARK_NODE otherwise.
 
    In LTO this may actually trigger reading the constructor from disk.
@@ -381,10 +388,10 @@ ctor_for_folding (tree decl)
 
   gcc_assert (TREE_CODE (decl) == VAR_DECL);
 
-  real_node = node = varpool_get_node (decl);
+  real_node = node = varpool_node::get (decl);
   if (node)
     {
-      real_node = varpool_variable_node (node);
+      real_node = node->ultimate_alias_target ();
       real_decl = real_node->decl;
     }
   else
@@ -401,7 +408,7 @@ ctor_for_folding (tree decl)
                  || DECL_INITIAL (decl) == error_mark_node);
       if (node->weakref)
        {
-         node = varpool_alias_target (node);
+         node = node->get_alias_target ();
          decl = node->decl;
        }
     }
@@ -409,7 +416,7 @@ ctor_for_folding (tree decl)
   if ((!DECL_VIRTUAL_P (real_decl)
        || DECL_INITIAL (real_decl) == error_mark_node
        || !DECL_INITIAL (real_decl))
-      && (!node || !varpool_ctor_useable_for_folding_p (node)))
+      && (!node || !node->ctor_useable_for_folding_p ()))
     return error_mark_node;
 
   /* OK, we can return constructor.  See if we need to fetch it from disk
@@ -417,7 +424,7 @@ ctor_for_folding (tree decl)
   if (DECL_INITIAL (real_decl) != error_mark_node
       || !in_lto_p)
     return DECL_INITIAL (real_decl);
-  return varpool_get_constructor (real_node);
+  return real_node->get_constructor ();
 }
 
 /* Add the variable DECL to the varpool.
@@ -428,90 +435,85 @@ void
 varpool_add_new_variable (tree decl)
 {
   varpool_node *node;
-  varpool_finalize_decl (decl);
-  node = varpool_node_for_decl (decl);
+  varpool_node::finalize_decl (decl);
+  node = varpool_node::get_create (decl);
   varpool_call_variable_insertion_hooks (node);
-  if (varpool_externally_visible_p (node))
+  if (node->externally_visible_p ())
     node->externally_visible = true;
 }
 
 /* Return variable availability.  See cgraph.h for description of individual
    return values.  */
 enum availability
-cgraph_variable_initializer_availability (varpool_node *node)
+varpool_node::get_availability (void)
 {
-  if (!node->definition)
+  if (!definition)
     return AVAIL_NOT_AVAILABLE;
-  if (!TREE_PUBLIC (node->decl))
+  if (!TREE_PUBLIC (decl))
     return AVAIL_AVAILABLE;
-  if (DECL_IN_CONSTANT_POOL (node->decl)
-      || DECL_VIRTUAL_P (node->decl))
+  if (DECL_IN_CONSTANT_POOL (decl)
+      || DECL_VIRTUAL_P (decl))
     return AVAIL_AVAILABLE;
-  if (node->alias && node->weakref)
+  if (alias && weakref)
     {
       enum availability avail;
 
-      cgraph_variable_initializer_availability
-             (varpool_variable_node (node, &avail));
+      ultimate_alias_target (&avail)->get_availability ();
       return avail;
     }
   /* If the variable can be overwritten, return OVERWRITABLE.  Takes
      care of at least one notable extension - the COMDAT variables
      used to share template instantiations in C++.  */
-  if (decl_replaceable_p (node->decl)
-      || DECL_EXTERNAL (node->decl))
+  if (decl_replaceable_p (decl)
+      || DECL_EXTERNAL (decl))
     return AVAIL_INTERPOSABLE;
   return AVAIL_AVAILABLE;
 }
 
 void
-varpool_analyze_node (varpool_node *node)
+varpool_node::analyze (void)
 {
-  tree decl = node->decl;
-
   /* When reading back varpool at LTO time, we re-construct the queue in order
      to have "needed" list right by inserting all needed nodes into varpool.
      We however don't want to re-analyze already analyzed nodes.  */
-  if (!node->analyzed)
+  if (!analyzed)
     {
       gcc_assert (!in_lto_p || cgraph_function_flags_ready);
       /* Compute the alignment early so function body expanders are
         already informed about increased alignment.  */
       align_variable (decl, 0);
     }
-  if (node->alias)
-    node->resolve_alias (varpool_get_node (node->alias_target));
+  if (alias)
+    resolve_alias (varpool_node::get (alias_target));
   else if (DECL_INITIAL (decl))
-    record_references_in_initializer (decl, node->analyzed);
-  node->analyzed = true;
+    record_references_in_initializer (decl, analyzed);
+  analyzed = true;
 }
 
-/* Assemble thunks and aliases associated to NODE.  */
+/* Assemble thunks and aliases associated to varpool node.  */
 
-static void
-assemble_aliases (varpool_node *node)
+void
+varpool_node::assemble_aliases (void)
 {
   struct ipa_ref *ref;
 
-  FOR_EACH_ALIAS (node, ref)
+  FOR_EACH_ALIAS (this, ref)
     {
       varpool_node *alias = dyn_cast <varpool_node *> (ref->referring);
       do_assemble_alias (alias->decl,
-                        DECL_ASSEMBLER_NAME (node->decl));
-      assemble_aliases (alias);
+                        DECL_ASSEMBLER_NAME (decl));
+      alias->assemble_aliases ();
     }
 }
 
 /* Output one variable, if necessary.  Return whether we output it.  */
 
 bool
-varpool_assemble_decl (varpool_node *node)
+varpool_node::assemble_decl (void)
 {
-  tree decl = node->decl;
-
   /* Aliases are outout when their target is produced or by
      output_weakrefs.  */
-  if (node->alias)
+  if (alias)
     return false;
 
   /* Constant pool is output from RTL land when the reference
@@ -535,14 +537,14 @@ varpool_assemble_decl (varpool_node *node)
                       && TREE_CODE (decl) == VAR_DECL
                       && !DECL_HAS_VALUE_EXPR_P (decl));
 
-  if (!node->in_other_partition
+  if (!in_other_partition
       && !DECL_EXTERNAL (decl))
     {
-      varpool_get_constructor (node);
+      get_constructor ();
       assemble_variable (decl, 0, 1, 0);
       gcc_assert (TREE_ASM_WRITTEN (decl));
-      gcc_assert (node->definition);
-      assemble_aliases (node);
+      gcc_assert (definition);
+      assemble_aliases ();
       return true;
     }
 
@@ -584,7 +586,7 @@ varpool_remove_unreferenced_decls (void)
   FOR_EACH_DEFINED_VARIABLE (node)
     {
       if (node->analyzed
-         && (!varpool_can_remove_if_no_refs (node)
+         && (!node->can_remove_if_no_refs_p ()
              /* We just expanded all function bodies.  See if any of
                 them needed the variable.  */
              || DECL_RTL_SET_P (node->decl)))
@@ -634,7 +636,7 @@ varpool_remove_unreferenced_decls (void)
           if (cgraph_dump_file)
            fprintf (cgraph_dump_file, " %s", node->asm_name ());
          if (pointer_set_contains (referenced, node))
-           varpool_remove_initializer (node);
+           node->remove_initializer ();
          else
            node->remove ();
        }
@@ -649,21 +651,21 @@ varpool_remove_unreferenced_decls (void)
    conflicts between read-only and read-only requiring relocations
    sections can be resolved.  */
 void
-varpool_finalize_named_section_flags (varpool_node *node)
+varpool_node::finalize_named_section_flags (void)
 {
-  if (!TREE_ASM_WRITTEN (node->decl)
-      && !node->alias
-      && !node->in_other_partition
-      && !DECL_EXTERNAL (node->decl)
-      && TREE_CODE (node->decl) == VAR_DECL
-      && !DECL_HAS_VALUE_EXPR_P (node->decl)
-      && node->get_section ())
-    get_variable_section (node->decl, false);
+  if (!TREE_ASM_WRITTEN (decl)
+      && !alias
+      && !in_other_partition
+      && !DECL_EXTERNAL (decl)
+      && TREE_CODE (decl) == VAR_DECL
+      && !DECL_HAS_VALUE_EXPR_P (decl)
+      && get_section ())
+    get_variable_section (decl, false);
 }
 
 /* Output all variables enqueued to be assembled.  */
 bool
-varpool_output_variables (void)
+varpool_node::output_variables (void)
 {
   bool changed = false;
   varpool_node *node;
@@ -676,10 +678,10 @@ varpool_output_variables (void)
   timevar_push (TV_VAROUT);
 
   FOR_EACH_DEFINED_VARIABLE (node)
-    varpool_finalize_named_section_flags (node);
+    node->finalize_named_section_flags ();
 
   FOR_EACH_DEFINED_VARIABLE (node)
-    if (varpool_assemble_decl (node))
+    if (node->assemble_decl ())
       changed = true;
   timevar_pop (TV_VAROUT);
   return changed;
@@ -700,8 +702,8 @@ add_new_static_var (tree type)
   DECL_CONTEXT (new_decl) = NULL_TREE;
   DECL_ABSTRACT (new_decl) = 0;
   lang_hooks.dup_lang_specific_decl (new_decl);
-  new_node = varpool_node_for_decl (new_decl);
-  varpool_finalize_decl (new_decl);
+  new_node = varpool_node::get_create (new_decl);
+  varpool_node::finalize_decl (new_decl);
 
   return new_node->decl;
 }
@@ -710,13 +712,13 @@ add_new_static_var (tree type)
    Extra name aliases are output whenever DECL is output.  */
 
 varpool_node *
-varpool_create_variable_alias (tree alias, tree decl)
+varpool_node::create_alias (tree alias, tree decl)
 {
   varpool_node *alias_node;
 
   gcc_assert (TREE_CODE (decl) == VAR_DECL);
   gcc_assert (TREE_CODE (alias) == VAR_DECL);
-  alias_node = varpool_node_for_decl (alias);
+  alias_node = varpool_node::get_create (alias);
   alias_node->alias = true;
   alias_node->definition = true;
   alias_node->alias_target = decl;
@@ -729,7 +731,7 @@ varpool_create_variable_alias (tree alias, tree decl)
    Extra name aliases are output whenever DECL is output.  */
 
 varpool_node *
-varpool_extra_name_alias (tree alias, tree decl)
+varpool_node::create_extra_name_alias (tree alias, tree decl)
 {
   varpool_node *alias_node;
 
@@ -737,7 +739,7 @@ varpool_extra_name_alias (tree alias, tree decl)
   /* If aliases aren't supported by the assembler, fail.  */
   return NULL;
 #endif
-  alias_node = varpool_create_variable_alias (alias, decl);
+  alias_node = varpool_node::create_alias (alias, decl);
   alias_node->cpp_implicit_alias = true;
 
   /* Extra name alias mechanizm creates aliases really late
@@ -745,32 +747,32 @@ varpool_extra_name_alias (tree alias, tree decl)
      This is unfortunate because they are not going through the
      standard channels.  Ensure they get output.  */
   if (cpp_implicit_aliases_done)
-    alias_node->resolve_alias (varpool_node_for_decl (decl));
+    alias_node->resolve_alias (varpool_node::get_create (decl));
   return alias_node;
 }
 
-/* Call calback on NODE and aliases associated to NODE. 
+/* Call calback on varpool symbol and aliases associated to varpool symbol.
    When INCLUDE_OVERWRITABLE is false, overwritable aliases and thunks are
    skipped. */
 
 bool
-varpool_for_node_and_aliases (varpool_node *node,
-                             bool (*callback) (varpool_node *, void *),
-                             void *data,
-                             bool include_overwritable)
+varpool_node::call_for_node_and_aliases (bool (*callback) (varpool_node *,
+                                                          void *),
+                                        void *data,
+                                        bool include_overwritable)
 {
   struct ipa_ref *ref;
 
-  if (callback (node, data))
+  if (callback (this, data))
     return true;
 
-  FOR_EACH_ALIAS (node, ref)
+  FOR_EACH_ALIAS (this, ref)
     {
       varpool_node *alias = dyn_cast <varpool_node *> (ref->referring);
       if (include_overwritable
-         || cgraph_variable_initializer_availability (alias) > AVAIL_INTERPOSABLE)
-       if (varpool_for_node_and_aliases (alias, callback, data,
-                                        include_overwritable))
+         || alias->get_availability () > AVAIL_INTERPOSABLE)
+       if (alias->call_for_node_and_aliases (callback, data,
+                                             include_overwritable))
          return true;
     }
   return false;