X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=gcc%2Fcgraph.h;h=7abfb8ae9f631b4032983ae31b57a777b717425a;hb=d4107d7c17c6f69e7ff93546e24d1490757cf49a;hp=055ab4884ef98e0d2d1fd99a058d2799f62154bf;hpb=74fa5f1cdaa093cd7d9b2405e9cbed0601a2c357;p=pf3gnuchains%2Fgcc-fork.git diff --git a/gcc/cgraph.h b/gcc/cgraph.h index 055ab4884ef..7abfb8ae9f6 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -84,10 +84,13 @@ struct GTY(()) cgraph_local_info { /* Set when function is visible by other units. */ unsigned externally_visible : 1; - + /* Set once it has been finalized so we consider it to be output. */ unsigned finalized : 1; + /* False when there is something makes versioning impossible. */ + unsigned versionable : 1; + /* False when function calling convention and signature can not be changed. This is the case when __builtin_apply_args is used. */ unsigned can_change_signature : 1; @@ -95,6 +98,9 @@ struct GTY(()) cgraph_local_info { /* True when the function has been originally extern inline, but it is redefined now. */ unsigned redefined_extern_inline : 1; + + /* True if the function may enter serial irrevocable mode. */ + unsigned tm_may_enter_irr : 1; }; /* Information about the function that needs to be computed globally @@ -165,9 +171,6 @@ struct GTY((chain_next ("%h.next"), chain_prev ("%h.previous"))) cgraph_node { struct cgraph_node *prev_sibling_clone; struct cgraph_node *clones; struct cgraph_node *clone_of; - /* For normal nodes pointer to the list of alias and thunk nodes, - in alias/thunk nodes pointer to the normal node. */ - struct cgraph_node *same_body; /* Circular list of nodes in the same comdat group if non-NULL. */ struct cgraph_node *same_comdat_group; /* For functions with many calls sites it holds map from call expression @@ -236,8 +239,7 @@ struct GTY((chain_next ("%h.next"), chain_prev ("%h.previous"))) cgraph_node { unsigned process : 1; /* Set for aliases once they got through assemble_alias. */ unsigned alias : 1; - /* Set for alias and thunk nodes, same_body points to the node they are alias - of and they are linked through the next/previous pointers. */ + /* Set for aliases created as C++ same body aliases. */ unsigned same_body_alias : 1; /* How commonly executed the node is. Initialized during branch probabilities pass. */ @@ -246,6 +248,11 @@ struct GTY((chain_next ("%h.next"), chain_prev ("%h.previous"))) cgraph_node { unsigned only_called_at_startup : 1; /* True when function can only be called at startup (from static dtor). */ unsigned only_called_at_exit : 1; + /* True when function is the transactional clone of a function which + is called only from inside transactions. */ + /* ?? We should be able to remove this. We have enough bits in + cgraph to calculate it. */ + unsigned tm_clone : 1; }; typedef struct cgraph_node *cgraph_node_ptr; @@ -318,9 +325,6 @@ struct GTY(()) cgraph_indirect_call_info HOST_WIDE_INT anc_offset; /* OBJ_TYPE_REF_TOKEN of a polymorphic call (if polymorphic is set). */ HOST_WIDE_INT otr_token; - /* Delta by which must be added to this parameter to compensate for a skipped - this adjusting thunk. */ - HOST_WIDE_INT thunk_delta; /* Type of the object from OBJ_TYPE_REF_OBJECT. */ tree otr_type; /* Index of the parameter that is called. */ @@ -384,13 +388,12 @@ DEF_VEC_ALLOC_P(cgraph_edge_p,heap); struct GTY((chain_next ("%h.next"), chain_prev ("%h.prev"))) varpool_node { tree decl; + /* For aliases points to declaration DECL is alias of. */ + tree alias_of; /* Pointer to the next function in varpool_nodes. */ struct varpool_node *next, *prev; /* Pointer to the next function in varpool_nodes_queue. */ struct varpool_node *next_needed, *prev_needed; - /* For normal nodes a pointer to the first extra name alias. For alias - nodes a pointer to the normal node. */ - struct varpool_node *extra_name; /* Circular list of nodes in the same comdat group if non-NULL. */ struct varpool_node *same_comdat_group; struct ipa_ref_list ref_list; @@ -419,6 +422,7 @@ struct GTY((chain_next ("%h.next"), chain_prev ("%h.prev"))) varpool_node { /* Set for aliases once they got through assemble_alias. Also set for extra name aliases in varpool_extra_name_alias. */ unsigned alias : 1; + unsigned extra_name_alias : 1; /* Set when variable is used from other LTRANS partition. */ unsigned used_from_other_partition : 1; /* Set when variable is available in the other LTRANS partition. @@ -463,6 +467,7 @@ extern GTY(()) struct cgraph_node *cgraph_new_nodes; extern GTY(()) struct cgraph_asm_node *cgraph_asm_nodes; extern GTY(()) int cgraph_order; +extern bool same_body_aliases_done; /* In cgraph.c */ void dump_cgraph (FILE *); @@ -472,6 +477,7 @@ void debug_cgraph_node (struct cgraph_node *); void cgraph_insert_node_to_hashtable (struct cgraph_node *node); void cgraph_remove_edge (struct cgraph_edge *); void cgraph_remove_node (struct cgraph_node *); +void cgraph_add_to_same_comdat_group (struct cgraph_node *, struct cgraph_node *); void cgraph_remove_node_and_inline_clones (struct cgraph_node *); void cgraph_release_function_body (struct cgraph_node *); void cgraph_node_remove_callees (struct cgraph_node *node); @@ -482,13 +488,11 @@ struct cgraph_edge *cgraph_create_indirect_edge (struct cgraph_node *, gimple, int, gcov_type, int); struct cgraph_indirect_call_info *cgraph_allocate_init_indirect_info (void); struct cgraph_node * cgraph_get_node (const_tree); -struct cgraph_node * cgraph_get_node_or_alias (const_tree); struct cgraph_node * cgraph_create_node (tree); struct cgraph_node * cgraph_get_create_node (tree); struct cgraph_node * cgraph_same_body_alias (struct cgraph_node *, tree, tree); struct cgraph_node * cgraph_add_thunk (struct cgraph_node *, tree, tree, bool, HOST_WIDE_INT, HOST_WIDE_INT, tree, tree); -void cgraph_remove_same_body_alias (struct cgraph_node *); struct cgraph_node *cgraph_node_for_asm (tree); struct cgraph_edge *cgraph_edge (struct cgraph_node *, gimple); void cgraph_set_call_stmt (struct cgraph_edge *, gimple); @@ -508,10 +512,12 @@ struct cgraph_edge * cgraph_clone_edge (struct cgraph_edge *, struct cgraph_node * cgraph_clone_node (struct cgraph_node *, tree, gcov_type, int, bool, VEC(cgraph_edge_p,heap) *, bool); +struct cgraph_node *cgraph_create_function_alias (tree, tree); +void cgraph_call_node_duplication_hooks (struct cgraph_node *node1, + struct cgraph_node *node2); void cgraph_redirect_edge_callee (struct cgraph_edge *, struct cgraph_node *); -void cgraph_make_edge_direct (struct cgraph_edge *, struct cgraph_node *, - HOST_WIDE_INT); +void cgraph_make_edge_direct (struct cgraph_edge *, struct cgraph_node *); bool cgraph_only_called_directly_p (struct cgraph_node *); struct cgraph_asm_node *cgraph_add_asm_node (tree); @@ -538,6 +544,7 @@ bool cgraph_will_be_removed_from_program_if_no_direct_calls (struct cgraph_node *node); bool cgraph_can_remove_if_no_direct_calls_and_refs_p (struct cgraph_node *node); +bool cgraph_can_remove_if_no_direct_calls_p (struct cgraph_node *node); bool resolution_used_from_other_file_p (enum ld_plugin_symbol_resolution); bool cgraph_used_from_object_file_p (struct cgraph_node *); bool varpool_used_from_object_file_p (struct varpool_node *); @@ -568,15 +575,18 @@ void verify_cgraph_node (struct cgraph_node *); void cgraph_build_static_cdtor (char which, tree body, int priority); void cgraph_reset_static_var_maps (void); void init_cgraph (void); +struct cgraph_node * cgraph_copy_node_for_versioning (struct cgraph_node *, + tree, VEC(cgraph_edge_p,heap)*, bitmap); struct cgraph_node *cgraph_function_versioning (struct cgraph_node *, VEC(cgraph_edge_p,heap)*, VEC(ipa_replace_map_p,gc)*, - bitmap, bitmap, basic_block, - const char *); -void tree_function_versioning (tree, tree, VEC (ipa_replace_map_p,gc)*, bool, bitmap, - bitmap, basic_block); + bitmap, bool, bitmap, + basic_block, const char *); +void tree_function_versioning (tree, tree, VEC (ipa_replace_map_p,gc)*, + bool, bitmap, bool, bitmap, basic_block); void record_references_in_initializer (tree, bool); bool cgraph_process_new_functions (void); +void cgraph_process_same_body_aliases (void); bool cgraph_decide_is_function_needed (struct cgraph_node *, tree); @@ -633,6 +643,7 @@ void debug_varpool_node_set (varpool_node_set); void free_varpool_node_set (varpool_node_set); void ipa_discover_readonly_nonaddressable_vars (void); bool cgraph_comdat_can_be_unshared_p (struct cgraph_node *); +bool varpool_externally_visible_p (struct varpool_node *, bool); /* In predict.c */ bool cgraph_maybe_hot_edge_p (struct cgraph_edge *e); @@ -666,9 +677,14 @@ bool varpool_analyze_pending_decls (void); void varpool_remove_unreferenced_decls (void); void varpool_empty_needed_queue (void); struct varpool_node * varpool_extra_name_alias (tree, tree); +struct varpool_node * varpool_create_variable_alias (tree, tree); const char * varpool_node_name (struct varpool_node *node); void varpool_reset_queue (void); bool const_value_known_p (tree); +bool varpool_for_node_and_aliases (struct varpool_node *, + bool (*) (struct varpool_node *, void *), + void *, bool); +void varpool_add_new_variable (tree); /* Walk all reachable static variables. */ #define FOR_EACH_STATIC_VARIABLE(node) \ @@ -719,7 +735,7 @@ cgraph_first_defined_function (void) return NULL; } -/* Return next reachable static variable with initializer after NODE. */ +/* Return next function with body defined after NODE. */ static inline struct cgraph_node * cgraph_next_defined_function (struct cgraph_node *node) { @@ -746,7 +762,7 @@ cgraph_next_defined_function (struct cgraph_node *node) static inline bool cgraph_function_with_gimple_body_p (struct cgraph_node *node) { - return node->analyzed && !node->thunk.thunk_p; + return node->analyzed && !node->thunk.thunk_p && !node->alias; } /* Return first function with body defined. */ @@ -919,6 +935,7 @@ cgraph_only_called_directly_or_aliased_p (struct cgraph_node *node) gcc_assert (!node->global.inlined_to); return (!node->needed && !node->address_taken && !node->reachable_from_other_partition + && !DECL_VIRTUAL_P (node->decl) && !DECL_STATIC_CONSTRUCTOR (node->decl) && !DECL_STATIC_DESTRUCTOR (node->decl) && !node->local.externally_visible); @@ -928,25 +945,15 @@ cgraph_only_called_directly_or_aliased_p (struct cgraph_node *node) if all direct calls are eliminated. */ static inline bool -cgraph_can_remove_if_no_direct_calls_p (struct cgraph_node *node) +varpool_can_remove_if_no_refs (struct varpool_node *node) { - /* Extern inlines can always go, we will use the external definition. */ if (DECL_EXTERNAL (node->decl)) return true; - return (!node->address_taken - && cgraph_can_remove_if_no_direct_calls_and_refs_p (node)); -} - -/* Return true when function NODE can be removed from callgraph - if all direct calls are eliminated. */ - -static inline bool -varpool_can_remove_if_no_refs (struct varpool_node *node) -{ return (!node->force_output && !node->used_from_other_partition - && (flag_toplevel_reorder || DECL_COMDAT (node->decl) - || DECL_ARTIFICIAL (node->decl)) - && (DECL_COMDAT (node->decl) || !node->externally_visible)); + && ((DECL_COMDAT (node->decl) + && !varpool_used_from_object_file_p (node)) + || (flag_toplevel_reorder && !node->externally_visible) + || DECL_HAS_VALUE_EXPR_P (node->decl))); } /* Return true when all references to VNODE must be visible in ipa_ref_list. @@ -957,7 +964,8 @@ varpool_can_remove_if_no_refs (struct varpool_node *node) static inline bool varpool_all_refs_explicit_p (struct varpool_node *vnode) { - return (!vnode->externally_visible + return (vnode->analyzed + && !vnode->externally_visible && !vnode->used_from_other_partition && !vnode->force_output); } @@ -968,6 +976,34 @@ htab_t constant_pool_htab (void); /* FIXME: inappropriate dependency of cgraph on IPA. */ #include "ipa-ref-inline.h" +/* Return node that alias N is aliasing. */ + +static inline struct cgraph_node * +cgraph_alias_aliased_node (struct cgraph_node *n) +{ + struct ipa_ref *ref; + + ipa_ref_list_reference_iterate (&n->ref_list, 0, ref); + gcc_checking_assert (ref->use == IPA_REF_ALIAS); + if (ref->refered_type == IPA_REF_CGRAPH) + return ipa_ref_node (ref); + return NULL; +} + +/* Return node that alias N is aliasing. */ + +static inline struct varpool_node * +varpool_alias_aliased_node (struct varpool_node *n) +{ + struct ipa_ref *ref; + + ipa_ref_list_reference_iterate (&n->ref_list, 0, ref); + gcc_checking_assert (ref->use == IPA_REF_ALIAS); + if (ref->refered_type == IPA_REF_VARPOOL) + return ipa_ref_varpool_node (ref); + return NULL; +} + /* Given NODE, walk the alias chain to return the function NODE is alias of. Walk through thunk, too. When AVAILABILITY is non-NULL, get minimal availablity in the chain. */ @@ -979,11 +1015,13 @@ cgraph_function_node (struct cgraph_node *node, enum availability *availability) *availability = cgraph_function_body_availability (node); while (node) { - if (node->thunk.thunk_p) + if (node->alias && node->analyzed) + node = cgraph_alias_aliased_node (node); + else if (node->thunk.thunk_p) node = node->callees->callee; else return node; - if (availability) + if (node && availability) { enum availability a; a = cgraph_function_body_availability (node); @@ -991,6 +1029,8 @@ cgraph_function_node (struct cgraph_node *node, enum availability *availability) *availability = a; } } + if (availability) + *availability = AVAIL_NOT_AVAILABLE; return NULL; } @@ -1003,7 +1043,50 @@ cgraph_function_or_thunk_node (struct cgraph_node *node, enum availability *avai { if (availability) *availability = cgraph_function_body_availability (node); - return node; + while (node) + { + if (node->alias && node->analyzed) + node = cgraph_alias_aliased_node (node); + else + return node; + if (node && availability) + { + enum availability a; + a = cgraph_function_body_availability (node); + if (a < *availability) + *availability = a; + } + } + if (availability) + *availability = AVAIL_NOT_AVAILABLE; + return NULL; +} + +/* Given NODE, walk the alias chain to return the function NODE is alias of. + Do not walk through thunks. + When AVAILABILITY is non-NULL, get minimal availablity in the chain. */ + +static inline struct varpool_node * +varpool_variable_node (struct varpool_node *node, enum availability *availability) +{ + if (availability) + *availability = cgraph_variable_initializer_availability (node); + while (node) + { + if (node->alias && node->analyzed) + node = varpool_alias_aliased_node (node); + else + return node; + if (node && availability) + { + enum availability a; + a = cgraph_variable_initializer_availability (node); + if (a < *availability) + *availability = a; + } + } + if (availability) + *availability = AVAIL_NOT_AVAILABLE; return NULL; } @@ -1017,4 +1100,14 @@ cgraph_edge_recursive_p (struct cgraph_edge *e) else return e->caller->decl == callee->decl; } + +/* Return true if the TM_CLONE bit is set for a given FNDECL. */ +static inline bool +decl_is_tm_clone (const_tree fndecl) +{ + struct cgraph_node *n = cgraph_get_node (fndecl); + if (n) + return n->tm_clone; + return false; +} #endif /* GCC_CGRAPH_H */