From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21154 invoked by alias); 17 Jul 2014 16:14:46 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 21087 invoked by uid 89); 17 Jul 2014 16:14:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.4 required=5.0 tests=AWL,BAYES_50,KAM_STOCKGEN autolearn=no version=3.3.2 X-HELO: mx2.suse.de Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Thu, 17 Jul 2014 16:14:35 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id D5171AAC3; Thu, 17 Jul 2014 16:14:31 +0000 (UTC) Message-ID: <53C7F667.7070005@suse.cz> Date: Thu, 17 Jul 2014 16:56:00 -0000 From: =?windows-1252?Q?Martin_Li=9Aka?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: Jan Hubicka CC: gcc-patches@gcc.gnu.org Subject: Re: [RFC, PATCH 2/n] IPA C++ refactoring References: <53C69058.70306@suse.cz> <53C7E024.50309@suse.cz> <20140717154305.GC19997@atrey.karlin.mff.cuni.cz> In-Reply-To: <20140717154305.GC19997@atrey.karlin.mff.cuni.cz> Content-Type: multipart/mixed; boundary="------------000603050501040300020502" X-IsSubscribed: yes X-SW-Source: 2014-07/txt/msg01233.txt.bz2 This is a multi-part message in MIME format. --------------000603050501040300020502 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Content-length: 7278 On 07/17/2014 05:43 PM, Jan Hubicka wrote: >> Bootstrapped/regtested x86_64-linux >> >> Ready for trunk? >> >> gcc/ChangeLog: >> 2014-07-17 Martin Liska >> >> * 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 * 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 *symbol_for_decl (tree decl)): created from varpool_node_for_decl >> (static varpool_node *symbol_for_asmname (tree asmname)): created from varpool_node_for_asm >> (void assemble_aliases (void)): created from assemble_aliases >> >> + /* 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); >> + >> + /* Return variable availability. */ >> + availability get_availability (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); >> + >> + /* 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); > Quite special, so it should go bellow the other declarations. >> + >> + /* Output one variable, if necessary. Return whether we output it. */ >> + bool assemble_decl (void); >> + >> + void analyze (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); >> + >> + /* Remove node initializer when it is no longer needed. */ >> + void remove_initializer (void); >> + >> + /* When doing LTO, read variable's constructor from disk if >> + it is not already present. */ >> + tree get_constructor (void); >> + >> + /* Return true when variable should be considered externally visible. */ >> + bool externally_visible_p (void); > We have flag and this helper function to set it. Probably the comment should > mention that this is not to be used except for varpool maintenance code. What function do you mean please? >> + >> + /* Return true if variable has constructor that can be used for folding. */ >> + bool ctor_useable_for_folding_p (void); > Group it with get_constructor and move earlier in the list (probably basic manipulation > first, constructor next, aliases and random predicates last) >> + >> + /* 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 * extra_name_alias (tree alias, tree decl); > create_extra_name_alias Renamed. >> + >> + /* 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 *symbol_for_decl (tree decl); > This is equivalent of get_create in cgraph, so lets call it the same way. You are right, I found one more member that I renamed: get_for_asmname. I hope reorganization of varpool_node looks fine? Martin >> + >> + /* Given an assembler name, lookup node. */ >> + static varpool_node *symbol_for_asmname (tree asmname); > Also please double heck it match the cgraph equivalent. > > OK with those changes. > Honza --------------000603050501040300020502 Content-Type: text/x-patch; name="ipa-ref-varpool-node4.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ipa-ref-varpool-node4.patch" Content-length: 71616 diff --git a/gcc/asan.c b/gcc/asan.c index 920f72e..59ec904 100644 --- a/gcc/asan.c +++ b/gcc/asan.c @@ -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 *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); diff --git a/gcc/cgraph.h b/gcc/cgraph.h index eb80f99..f8f76c4 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -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 (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 (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 (n->get_alias_target ()); + return dyn_cast (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 (node->ultimate_alias_target (availability)); - else - n = NULL; + varpool_node *n = dyn_cast + (symtab_node::ultimate_alias_target (availability)); if (!n && availability) *availability = AVAIL_NOT_AVAILABLE; diff --git a/gcc/cgraphbuild.c b/gcc/cgraphbuild.c index 9f1f244..91811d7 100644 --- a/gcc/cgraphbuild.c +++ b/gcc/cgraphbuild.c @@ -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; diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index 47828d7..34f4c81 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -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 (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 (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 (); diff --git a/gcc/coverage.c b/gcc/coverage.c index 1e47dd8..8ac1d5f 100644 --- a/gcc/coverage.c +++ b/gcc/coverage.c @@ -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 *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 *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 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 150c74e..aafb917 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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 ()); } diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 90244ef..8fa3145 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -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; } diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 8983e0d..40508ab 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -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 } } diff --git a/gcc/cp/vtable-class-hierarchy.c b/gcc/cp/vtable-class-hierarchy.c index 09e6730..2c10fd3 100644 --- a/gcc/cp/vtable-class-hierarchy.c +++ b/gcc/cp/vtable-class-hierarchy.c @@ -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)); diff --git a/gcc/dbxout.c b/gcc/dbxout.c index 6cb4341..fc6b13b 100644 --- a/gcc/dbxout.c +++ b/gcc/dbxout.c @@ -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; } diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 6fa2a70..8fd1945 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -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; diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index 5e2cbda..4e8de82 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -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 diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c index 1bfcfa1..7c4151a 100644 --- a/gcc/ipa-devirt.c +++ b/gcc/ipa-devirt.c @@ -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 &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; } diff --git a/gcc/ipa-visibility.c b/gcc/ipa-visibility.c index ddce77d..4720ee9 100644 --- a/gcc/ipa-visibility.c +++ b/gcc/ipa-visibility.c @@ -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); diff --git a/gcc/ipa.c b/gcc/ipa.c index 42dce67..8198b17 100644 --- 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 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 { diff --git a/gcc/java/resource.c b/gcc/java/resource.c index 8e5702f..8ae7e42 100644 --- a/gcc/java/resource.c +++ b/gcc/java/resource.c @@ -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); } diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c index 2233349..b1fcf67 100644 --- a/gcc/lto-cgraph.c +++ b/gcc/lto-cgraph.c @@ -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 (); diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c index 001df9b..75332f9 100644 --- a/gcc/lto-streamer-out.c +++ b/gcc/lto-streamer-out.c @@ -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)); diff --git a/gcc/lto/lto-partition.c b/gcc/lto/lto-partition.c index 8f2e236..cb08a88 100644 --- a/gcc/lto/lto-partition.c +++ b/gcc/lto/lto-partition.c @@ -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 (ref->referred) - && varpool_ctor_useable_for_folding_p - (dyn_cast (ref->referred)) + && dyn_cast (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 (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, diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 9a848eb..82b6fb8 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -4834,7 +4834,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); @@ -7959,7 +7959,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); @@ -8897,7 +8897,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); diff --git a/gcc/passes.c b/gcc/passes.c index 96d95ac..38485a7 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -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. */ diff --git a/gcc/symtab.c b/gcc/symtab.c index e3519fc..0f5b472 100644 --- a/gcc/symtab.c +++ b/gcc/symtab.c @@ -1507,8 +1507,7 @@ enum availability symtab_node::get_availability (void) if (is_a (this)) return dyn_cast (this)->get_availability (); else - return cgraph_variable_initializer_availability - (dyn_cast (this)); + return dyn_cast (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) diff --git a/gcc/toplev.c b/gcc/toplev.c index 9e747e5..5ebb250 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -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; diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c index f33b52f..5633398 100644 --- a/gcc/trans-mem.c +++ b/gcc/trans-mem.c @@ -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); diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index d238138..6fee8a4 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -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); diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c index ee5c3b4..df9a6fc 100644 --- a/gcc/tree-eh.c +++ b/gcc/tree-eh.c @@ -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; diff --git a/gcc/tree-emutls.c b/gcc/tree-emutls.c index 3e2296d..89197c7 100644 --- a/gcc/tree-emutls.c +++ b/gcc/tree-emutls.c @@ -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. */ diff --git a/gcc/tree-profile.c b/gcc/tree-profile.c index d384e3d..6ab06e6 100644 --- a/gcc/tree-profile.c +++ b/gcc/tree-profile.c @@ -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. */ diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index d40e445..cc455a7 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -2931,10 +2931,10 @@ get_constraint_for_ssa_var (tree t, vec *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; } } @@ -5789,10 +5789,10 @@ 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 @@ -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; diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c index 636e8ee..09c668e 100644 --- a/gcc/tree-switch-conversion.c +++ b/gcc/tree-switch-conversion.c @@ -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); diff --git a/gcc/tree.c b/gcc/tree.c index 4ae31f4..51ef63b 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -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); diff --git a/gcc/ubsan.c b/gcc/ubsan.c index fd9bf20..4e7e487 100644 --- a/gcc/ubsan.c +++ b/gcc/ubsan.c @@ -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; } diff --git a/gcc/varasm.c b/gcc/varasm.c index 7757995..275b65f 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -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; } @@ -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); diff --git a/gcc/varpool.c b/gcc/varpool.c index 6b31e73..74117e2 100644 --- a/gcc/varpool.c +++ b/gcc/varpool.c @@ -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 (); 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 (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 (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 (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; --------------000603050501040300020502--