GCC Middle and Back End API Reference
|
#include "is-a.h"
#include "plugin-api.h"
#include "vec.h"
#include "basic-block.h"
#include "function.h"
#include "ipa-ref.h"
#include "cif-code.def"
#include "ipa-ref-inline.h"
Go to the source code of this file.
Data Structures | |
class | symtab_node_base |
struct | cgraph_thunk_info |
struct | cgraph_local_info |
struct | cgraph_global_info |
struct | cgraph_rtl_info |
struct | ipa_replace_map |
struct | cgraph_clone_info |
struct | cgraph_node |
struct | cgraph_function_version_info |
struct | cgraph_node_set_def |
struct | varpool_node_set_def |
struct | cgraph_node_set_iterator |
struct | varpool_node_set_iterator |
struct | cgraph_indirect_call_info |
struct | cgraph_edge |
class | varpool_node |
struct | asm_node |
struct | constant_descriptor_tree |
Macros | |
#define | DEFCIFCODE(code, string) CIF_ ## code, |
#define | CGRAPH_FREQ_BASE 1000 |
#define | CGRAPH_FREQ_MAX 100000 |
#define | FOR_EACH_SYMBOL(node) for ((node) = symtab_nodes; (node); (node) = (node)->next) |
#define | FOR_EACH_VARIABLE(node) |
#define | FOR_EACH_STATIC_INITIALIZER(node) |
#define | FOR_EACH_DEFINED_VARIABLE(node) |
#define | FOR_EACH_DEFINED_FUNCTION(node) |
#define | FOR_EACH_FUNCTION(node) |
#define | FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) |
Typedefs | |
typedef struct ipa_replace_map * | ipa_replace_map_p |
typedef struct cgraph_node * | cgraph_node_ptr |
typedef struct varpool_node * | varpool_node_ptr |
typedef struct cgraph_node_set_def * | cgraph_node_set |
typedef struct varpool_node_set_def * | varpool_node_set |
typedef enum cgraph_inline_failed_enum | cgraph_inline_failed_t |
typedef struct cgraph_edge * | cgraph_edge_p |
typedef void(* | cgraph_edge_hook )(struct cgraph_edge *, void *) |
typedef void(* | cgraph_node_hook )(struct cgraph_node *, void *) |
typedef void(* | varpool_node_hook )(struct varpool_node *, void *) |
typedef void(* | cgraph_2edge_hook )(struct cgraph_edge *, struct cgraph_edge *, void *) |
typedef void(* | cgraph_2node_hook )(struct cgraph_node *, struct cgraph_node *, void *) |
Variables | |
const char *const | cgraph_availability_names [] |
const char *const | ld_plugin_symbol_resolution_names [] |
symtab_node | symtab_nodes |
int | cgraph_n_nodes |
int | cgraph_max_uid |
int | cgraph_edge_max_uid |
bool | cgraph_global_info_ready |
enum cgraph_state | cgraph_state |
bool | cgraph_function_flags_ready |
cgraph_node_set | cgraph_new_nodes |
struct asm_node * | asm_nodes |
int | symtab_order |
bool | cpp_implicit_aliases_done |
FILE * | cgraph_dump_file |
#define CGRAPH_FREQ_BASE 1000 |
#define CGRAPH_FREQ_MAX 100000 |
Referenced by cgraph_clone_edge(), cgraph_edge_cannot_lead_to_return(), and update_noncloned_frequencies().
#define DEFCIFCODE | ( | code, | |
string | |||
) | CIF_ ## code, |
#define FOR_EACH_DEFINED_FUNCTION | ( | node | ) |
Walk all functions with body defined.
Referenced by duplicate_node_data(), gcc::pass_manager::pass_manager(), and possible_polymorphic_call_target_p().
#define FOR_EACH_DEFINED_VARIABLE | ( | node | ) |
Walk all variables with definitions in current unit.
#define FOR_EACH_FUNCTION | ( | node | ) |
Walk all functions.
Referenced by cgraph_materialize_clone().
#define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY | ( | node | ) |
Walk all functions with body defined.
Referenced by spread_undeadness().
#define FOR_EACH_STATIC_INITIALIZER | ( | node | ) |
Walk all static variables with initializer set.
#define FOR_EACH_SYMBOL | ( | node | ) | for ((node) = symtab_nodes; (node); (node) = (node)->next) |
Walk all symbols.
#define FOR_EACH_VARIABLE | ( | node | ) |
Walk all variables.
Referenced by dump_varpool_node().
typedef void(* cgraph_2edge_hook)(struct cgraph_edge *, struct cgraph_edge *, void *) |
typedef void(* cgraph_2node_hook)(struct cgraph_node *, struct cgraph_node *, void *) |
typedef void(* cgraph_edge_hook)(struct cgraph_edge *, void *) |
typedef struct cgraph_edge* cgraph_edge_p |
typedef enum cgraph_inline_failed_enum cgraph_inline_failed_t |
Reasons for inlining failures.
typedef void(* cgraph_node_hook)(struct cgraph_node *, void *) |
typedef struct cgraph_node* cgraph_node_ptr |
typedef struct cgraph_node_set_def* cgraph_node_set |
typedef struct ipa_replace_map* ipa_replace_map_p |
typedef void(* varpool_node_hook)(struct varpool_node *, void *) |
typedef struct varpool_node* varpool_node_ptr |
typedef struct varpool_node_set_def* varpool_node_set |
enum availability |
Reasons for inlining failures.
DEFCIFCODE |
This file contains the definitions of the cgraph_inline_failed_t enums used in GCC. Copyright (C) 2008-2013 Free Software Foundation, Inc. Contributed by Doug Kwan dougk wan@ googl e.co m This file is part of GCC. GCC is free software you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GCC see the file COPYING3. If not see http://www.gnu.org/licenses/. The format of this file is DEFCIFCODE(code, string). Where symbol is the enumeration name without the ``''. The argument STRING is a explain the failure. Except for OK, which is a NULL pointer. Inlining successful. This must be the first code. |
enum cgraph_state |
enum symtab_type |
Callgraph handling code. Copyright (C) 2003-2013 Free Software Foundation, Inc. Contributed by Jan Hubicka
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/. Symbol table consists of functions and variables. TODO: add labels and CONST_DECLs.
In cgraphunit.c
|
staticread |
Return callgraph node for given symbol and check it is a function.
Referenced by input_overwrite_node().
|
read |
|
read |
|
read |
|
read |
|
read |
|
read |
Add thunk alias into callgraph. The alias declaration is ALIAS and it aliases DECL with an adjustments made into the first parameter. See comments in thunk_adjust for detail on the parameters.
|
staticread |
Referenced by propagate_aggs_accross_jump_function().
|
read |
Allocate cgraph_indirect_call_info and set its fields to default values.
References cgraph_node::callees, cgraph_edge::caller, cgraph_node::indirect_calls, cgraph_edge::indirect_unknown_callee, and cgraph_edge::next_callee.
void cgraph_build_static_cdtor | ( | char | which, |
tree | body, | ||
int | priority | ||
) |
Referenced by tsan_pass().
void cgraph_call_edge_duplication_hooks | ( | struct cgraph_edge * | cs1, |
struct cgraph_edge * | cs2 | ||
) |
Call all edge duplication hooks.
References cgraph_2node_hook_list::data, first_cgraph_node_duplicated_hook, cgraph_2node_hook_list::hook, and cgraph_2node_hook_list::next.
Referenced by cgraph_clone_edge().
void cgraph_call_function_insertion_hooks | ( | struct cgraph_node * | node | ) |
void cgraph_call_node_duplication_hooks | ( | struct cgraph_node * | node1, |
struct cgraph_node * | node2 | ||
) |
Call all node duplication hooks.
References cgraph_create_empty_node(), cgraph_get_create_node(), symtab_node_base::decl, DECL_CONTEXT, gcc_assert, cgraph_node::nested, cgraph_node::next_nested, cgraph_node::origin, symtab_register_node(), and TREE_CODE.
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 | ) |
|
read |
Callgraph clones Copyright (C) 2003-2013 Free Software Foundation, Inc. Contributed by Jan Hubicka
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/. This module provide facilities for clonning functions. I.e. creating new functions based on existing functions with simple modifications, such as replacement of parameters.
To allow whole program optimization without actual presence of function bodies, an additional infrastructure is provided for so-called virtual clones
A virtual clone in the callgraph is a function that has no associated body, just a description of how to create its body based on a different function (which itself may be a virtual clone).
The description of function modifications includes adjustments to the function's signature (which allows, for example, removing or adding function arguments), substitutions to perform on the function body, and, for inlined functions, a pointer to the function that it will be inlined into.
It is also possible to redirect any edge of the callgraph from a function to its virtual clone. This implies updating of the call site to adjust for the new function signature.
Most of the transformations performed by inter-procedural optimizations can be represented via virtual clones. For instance, a constant propagation pass can produce a virtual clone of the function which replaces one of its arguments by a constant. The inliner can represent its decisions by producing a clone of a function whose body will be later integrated into a given function.
Using virtual clones, the program can be easily updated during the Execute stage, solving most of pass interactions problems that would otherwise occur during Transform.
Virtual clones are later materialized in the LTRANS stage and turned into real functions. Passes executed after the virtual clone were introduced also perform their Transform stage on new functions, so for a pass there is no significant difference between operating on a real function or a virtual clone introduced before its Execute stage.
Optimization passes then work on virtual clones introduced before their Execute stage as if they were real functions. The only difference is that clones are not visible during the Generate Summary stage. Create clone of E in the node N represented by CALL_EXPR the callgraph.
We do not want to ignore loop nest after frequency drops to 0.
Clone flags that depend on call_stmt availability manually.
References apply_probability(), cgraph_edge::call_stmt_cannot_inline_p, cgraph_edge::callee, cgraph_edge::can_throw_external, cgraph_call_edge_duplication_hooks(), cgraph_create_edge(), cgraph_create_indirect_edge(), CGRAPH_FREQ_BASE, CGRAPH_FREQ_MAX, cgraph_get_node(), count, cgraph_edge::count, cgraph_indirect_call_info::ecf_flags, cgraph_edge::frequency, gcc_checking_assert, gimple_call_fndecl(), cgraph_edge::indirect_info, cgraph_edge::indirect_inlining_edge, cgraph_edge::indirect_unknown_callee, cgraph_edge::inline_failed, cgraph_edge::lto_stmt_uid, and cgraph_edge::speculative.
Referenced by update_call_expr().
|
read |
Create node representing clone of N executed COUNT times. Decrease the execution counts from original node too. The new clone will have decl set to DECL that may or may not be the same as decl of N.
When UPDATE_ORIGINAL is true, the counts are subtracted from the original function's profile to reflect the fact that part of execution is handled by node. When CALL_DUPLICATOIN_HOOK is true, the ipa passes are acknowledged about the new clone. Otherwise the caller is responsible for doing so later.
If the new node is being inlined into another one, NEW_INLINED_TO should be the outline function the new one is (even indirectly) inlined to. All hooks will see this in node's global.inlined_to, when invoked. Can be NULL if the node is not inlined.
Redirect calls to the old version node to point to its new version.
Referenced by clone_inlined_nodes(), and input_overwrite_node().
|
read |
Create a new cgraph node which is the new version of OLD_VERSION node. REDIRECT_CALLERS holds the callers edges which should be redirected to point to NEW_VERSION. ALL the callees edges of OLD_VERSION are cloned to the new version node. Return the new version node.
If non-NULL BLOCK_TO_COPY determine what basic blocks was copied to prevent duplications of calls that are dead in the clone.
Redirect calls to the old version node to point to its new version.
|
read |
Create edge from CALLER to CALLEE in the cgraph.
Referenced by build_cgraph_edges(), cgraph_clone_edge(), and ipa_tm_diagnose_tm_safe().
void cgraph_create_edge_including_clones | ( | struct cgraph_node * | orig, |
struct cgraph_node * | callee, | ||
gimple | old_stmt, | ||
gimple | stmt, | ||
gcov_type | count, | ||
int | freq, | ||
cgraph_inline_failed_t | reason | ||
) |
Like cgraph_create_edge walk the clone tree and update all clones sharing same function body. If clones already have edge for OLD_STMT; only update the edge same way as cgraph_set_call_stmt_including_clones does.
TODO: COUNT and LOOP_DEPTH should be properly distributed based on relative frequencies of the clones.
It is possible that clones already contain the edge while master didn't. Either we promoted indirect call into direct call in the clone or we are processing clones of unreachable master where edges has been removed.
|
read |
Allocate new callgraph node and insert it into basic data structures.
References symtab_node_base::alias, symtab_node_base::alias_target, cgraph_get_create_node(), DECL_ATTRIBUTES, symtab_node_base::definition, gcc_assert, gdbhooks::IDENTIFIER_NODE, lookup_attribute(), TREE_CODE, and symtab_node_base::weakref.
Referenced by cgraph_call_node_duplication_hooks(), and input_overwrite_node().
|
read |
|
read |
Create an indirect edge with a yet-undetermined callee where the call statement destination is a formal parameter of the caller with index PARAM_INDEX.
Record polymorphic call info.
Only record types can have virtual calls.
References free_edges, ggc_free(), cgraph_edge::indirect_info, NEXT_FREE_EDGE, and cgraph_edge::uid.
Referenced by build_cgraph_edges(), and cgraph_clone_edge().
|
read |
|
read |
Create callgraph node clone with new declaration. The actual body will be copied later at compilation stage.
TODO: after merging in ipa-sra use function call notes instead of args_to_skip bitmap interface.
Make a new FUNCTION_DECL tree node
These pointers represent function body and will be populated only when clone is materialized.
We can not do DECL_RESULT (new_decl) = NULL; here because of LTO partitioning sometimes storing only clone decl instead of original.
Generate a new name for the new version.
Update the properties. Make clone visible only within this translation unit. Make sure that is not weak also. ??? We cannot use COMDAT linkage because there is no ABI support for this.
Clones of global symbols or symbols with unique names are unique.
|
read |
bool cgraph_edge_cannot_lead_to_return | ( | struct cgraph_edge * | ) |
|
inlinestatic |
Return true when the edge E represents a direct recursion.
Referenced by remap_hint_predicate().
Referenced by cgraph_process_new_functions().
|
read |
|
staticread |
Return first function with body defined.
|
staticread |
Return first function.
|
staticread |
Return first function with body defined.
bool cgraph_for_node_and_aliases | ( | struct cgraph_node * | node, |
bool(*)(struct cgraph_node *, void *) | callback, | ||
void * | data, | ||
bool | include_overwritable | ||
) |
Call calback on NODE and aliases associated to NODE. When INCLUDE_OVERWRITABLE is false, overwritable aliases and thunks are skipped.
References cgraph_edge::callee, cgraph_edge::caller, cgraph_node_cannot_return(), cgraph_indirect_call_info::ecf_flags, ECF_NOTHROW, cgraph_edge::indirect_info, and cgraph_edge::indirect_unknown_callee.
Referenced by cgraph_set_const_flag_1(), cgraph_set_nothrow_flag_1(), cgraph_set_pure_flag_1(), contains_hot_call_p(), and debug_cgraph().
bool cgraph_for_node_thunks_and_aliases | ( | struct cgraph_node * | node, |
bool(*)(struct cgraph_node *, void *) | callback, | ||
void * | data, | ||
bool | include_overwritable | ||
) |
Call calback on NODE, thunks and aliases associated to NODE. When INCLUDE_OVERWRITABLE is false, overwritable aliases and thunks are skipped.
Referenced by cgraph_function_body_availability().
enum availability cgraph_function_body_availability | ( | struct cgraph_node * | ) |
|
read |
|
staticread |
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 availability in the chain.
Referenced by cgraph_set_pure_flag_1(), report_inline_failed_reason(), and searchc().
|
read |
Perform function versioning. Function versioning includes copying of the tree and a callgraph update (creating a new cgraph node and updating its callees and callers).
REDIRECT_CALLERS varray includes the edges to be redirected to the new version.
TREE_MAP is a mapping of tree nodes we want to replace with new ones (according to results of prior analysis). OLD_VERSION_NODE is the node that is versioned.
If non-NULL ARGS_TO_SKIP determine function parameters to remove from new version. If SKIP_RETURN is true, the new version will return void. If non-NULL BLOCK_TO_COPY determine what basic blocks to copy. If non_NULL NEW_ENTRY determine new entry BB of the clone.
Return the new version's cgraph node.
Make a new FUNCTION_DECL tree node for the new version.
Generate a new name for the new version.
When the old decl was a con-/destructor make sure the clone isn't.
Create the new version's call-graph node. and update the edges of the new node.
Copy the OLD_VERSION_NODE function tree to the new version.
Update the new version's properties. Make The new version visible only within this translation unit. Make sure that is not weak also. ??? We cannot use COMDAT linkage because there is no ABI support for this.
Clones of global symbols or symbols with unique names are unique.
Update the call_expr on the edges to call the new version node.
|
inlinestatic |
Return true when NODE is a function with Gimple body defined in current unit. Functions can also be define externally or they can be thunks with no Gimple representation.
Note that at WPA stage, the function body may not be present in memory.
Referenced by init_alias_vars(), ipcp_versionable_function_p(), and propagate_aggs_accross_jump_function().
bool cgraph_get_body | ( | struct cgraph_node * | node | ) |
|
read |
|
read |
|
staticread |
Return callgraph node for given symbol and check it is a function.
Referenced by attribute_value_equal(), cgraph_can_remove_if_no_direct_calls_p(), cgraph_clone_edge(), cgraph_create_function_alias(), comp_type_attributes(), declare_weak(), default_function_section(), get_cdtor_priority_section(), maybe_init_pretty_print(), probably_never_executed_edge_p(), update_call_edge_frequencies(), and walk_all_functions().
|
read |
const char* cgraph_inline_failed_string | ( | cgraph_inline_failed_t | ) |
|
read |
|
read |
void cgraph_make_node_local | ( | struct cgraph_node * | ) |
void cgraph_mark_address_taken_node | ( | struct cgraph_node * | ) |
|
inlinestatic |
Likewise indicate that a node is needed, i.e. reachable via some external means.
Referenced by process_common_attributes().
void cgraph_materialize_all_clones | ( | void | ) |
Once all functions from compilation unit are in memory, produce all clones and update all calls. We might also do this on demand if we don't want to bring all functions to memory prior compilation, but current WHOPR implementation does that and it is is bit easier to keep everything right in this order.
We can also do topological order, but number of iterations should be bounded by number of IPA passes since single IPA pass is probably not going to create clones of clones it created itself.
bool cgraph_maybe_hot_edge_p | ( | struct cgraph_edge * | e | ) |
In predict.c
|
staticread |
Return next function with body defined after NODE.
|
staticread |
Return next function.
|
staticread |
Return next reachable static variable with initializer after NODE.
|
inlinestatic |
Return asm name of cgraph node.
Referenced by remove_node_data().
bool cgraph_node_can_be_local_p | ( | struct cgraph_node * | ) |
bool cgraph_node_cannot_return | ( | struct cgraph_node * | ) |
|
read |
|
inlinestatic |
Return true if SET contains NODE.
|
inlinestatic |
Return name of cgraph node.
Referenced by cgraph_edge_remove_caller(), cgraph_materialize_clone(), contains_hot_call_p(), flatten_function(), free_varpool_node_set(), gather_caller_stats(), init_alias_vars(), init_caller_stats(), ipa_propagate_frequency(), known_aggs_to_agg_replacement_list(), possible_polymorphic_call_target_p(), print_all_lattices(), and want_early_inline_function_p().
void cgraph_node_remove_callees | ( | struct cgraph_node * | node | ) |
void cgraph_node_set_add | ( | cgraph_node_set | , |
struct cgraph_node * | |||
) |
cgraph_node_set_iterator cgraph_node_set_find | ( | cgraph_node_set | , |
struct cgraph_node * | |||
) |
cgraph_node_set cgraph_node_set_new | ( | void | ) |
Create a new cgraph node set.
References gcc_checking_assert, and pointer_map_insert().
|
inlinestatic |
Return true if set is nonempty.
void cgraph_node_set_remove | ( | cgraph_node_set | , |
struct cgraph_node * | |||
) |
|
inlinestatic |
Return number of nodes in SET.
|
inlinestatic |
Return true when function NODE is only called directly or it has alias. i.e. it is not externally visible, address was not taken and it is not used in any other non-standard way.
Referenced by cgraph_set_const_flag().
bool cgraph_only_called_directly_p | ( | struct cgraph_node * | ) |
bool cgraph_optimize_for_size_p | ( | struct cgraph_node * | ) |
Referenced by probably_never_executed_edge_p().
bool cgraph_process_new_functions | ( | void | ) |
Process CGRAPH_NEW_FUNCTIONS and perform actions necessary to add these functions into callgraph in a way so they look like ordinary reachable functions inserted into callgraph already at construction time.
Note that this queue may grow as its being processed, as the new functions may generate new ones.
At construction time we just need to finalize function and move it into reachable functions list.
When IPA optimization already started, do all essential transformations that has been already performed on the whole cgraph but not on this function.
Functions created during expansion shall be compiled directly.
References analyze_function(), symtab_node_base::analyzed, CDI_DOMINATORS, CDI_POST_DOMINATORS, cgraph_call_function_insertion_hooks(), cgraph_finalize_function(), CGRAPH_STATE_CONSTRUCTION, CGRAPH_STATE_EXPANSION, CGRAPH_STATE_IPA, CGRAPH_STATE_IPA_SSA, compute_inline_parameters(), DECL_STRUCT_FUNCTION, enqueue_node(), gcc::pass_manager::execute_early_local_passes(), expand_function(), free_dominance_info(), g, gcc_unreachable, gcc::context::get_passes(), gimple_in_ssa_p(), gimple_register_cfg_hooks(), inline_summary_vec, NULL, pop_cfun(), cgraph_node::process, and push_cfun().
void cgraph_process_same_body_aliases | ( | void | ) |
C++ frontend produce same body aliases all over the place, even before PCH gets streamed out. It relies on us linking the aliases with their function in order to do the fixups, but ipa-ref is not PCH safe. Consequentely we first produce aliases without links, but once C++ FE is sure he won't sream PCH we build the links via this function.
void cgraph_rebuild_references | ( | void | ) |
Rebuild cgraph edges for current function node. This needs to be run after passes that don't update the cgraph.
Keep speculative references for further cgraph edge expansion.
gimple cgraph_redirect_edge_call_stmt_to_callee | ( | struct cgraph_edge * | ) |
void cgraph_redirect_edge_callee | ( | struct cgraph_edge * | , |
struct cgraph_node * | |||
) |
void cgraph_release_function_body | ( | struct cgraph_node * | ) |
void cgraph_remove_edge | ( | struct cgraph_edge * | ) |
void cgraph_remove_edge_duplication_hook | ( | struct cgraph_2edge_hook_list * | ) |
void cgraph_remove_edge_removal_hook | ( | struct cgraph_edge_hook_list * | ) |
void cgraph_remove_function_insertion_hook | ( | struct cgraph_node_hook_list * | ) |
void cgraph_remove_node | ( | struct cgraph_node * | ) |
bool cgraph_remove_node_and_inline_clones | ( | struct cgraph_node * | , |
struct cgraph_node * | |||
) |
Referenced by replace_locals_op().
void cgraph_remove_node_duplication_hook | ( | struct cgraph_2node_hook_list * | ) |
void cgraph_remove_node_removal_hook | ( | struct cgraph_node_hook_list * | ) |
void cgraph_reset_node | ( | struct cgraph_node * | ) |
Referenced by referred_to_p().
|
read |
|
read |
|
read |
void cgraph_set_call_stmt | ( | struct cgraph_edge * | e, |
gimple | new_stmt, | ||
bool | update_speculative | ||
) |
Change field call_stmt of edge E to NEW_STMT. If UPDATE_SPECULATIVE and E is any component of speculative edge, then update all components.
Speculative edges has three component, update all of them when asked to.
Only direct speculative edges go to call_site_hash.
Constant propagation (and possibly also inlining?) can turn an indirect call into a direct one.
void cgraph_set_call_stmt_including_clones | ( | struct cgraph_node * | orig, |
gimple | old_stmt, | ||
gimple | new_stmt, | ||
bool | update_speculative | ||
) |
Like cgraph_set_call_stmt but walk the clone tree and update all clones sharing the same function body. When WHOLE_SPECULATIVE_EDGES is true, all three components of speculative edge gets updated. Otherwise we update only direct call.
If UPDATE_SPECULATIVE is false, it means that we are turning speculative call into a real code sequence. Update the callgraph edges.
void cgraph_set_const_flag | ( | struct cgraph_node * | , |
bool | , | ||
bool | |||
) |
void cgraph_set_nothrow_flag | ( | struct cgraph_node * | , |
bool | |||
) |
void cgraph_set_pure_flag | ( | struct cgraph_node * | , |
bool | , | ||
bool | |||
) |
void cgraph_speculative_call_info | ( | struct cgraph_edge * | e, |
struct cgraph_edge *& | direct, | ||
struct cgraph_edge *& | indirect, | ||
struct ipa_ref *& | reference | ||
) |
Speculative call consist of three components: 1) an indirect edge representing the original call 2) an direct edge representing the new call 3) ADDR_EXPR reference representing the speculative check. All three components are attached to single statement (the indirect call) and if one of them exists, all of them must exist.
Given speculative call edge E, return all three components.
We can take advantage of the call stmt hash.
Speculative edge always consist of all three components - direct edge, indirect and reference.
|
read |
Turn edge E into speculative call calling N2. Update the profile so the direct call is taken COUNT times with FREQUENCY.
At clone materialization time, the indirect call E will be expanded as:
if (call_dest == N2) n2 (); else call call_dest
At this time the function just creates the direct call, the referencd representing the if conditional and attaches them all to the orginal indirect call statement.
Return direct edge created.
void cgraph_unnest_node | ( | struct cgraph_node * | ) |
enum availability cgraph_variable_initializer_availability | ( | struct varpool_node * | ) |
Referenced by varpool_create_variable_alias(), and varpool_remove_initializer().
bool cgraph_will_be_removed_from_program_if_no_direct_calls | ( | struct cgraph_node * | node | ) |
vec<cgraph_edge_p> collect_callers_of_node | ( | struct cgraph_node * | node | ) |
void compile | ( | void | ) |
Perform simple optimizations based on callgraph.
If LTO is enabled, initialize the streamer hooks needed by GIMPLE.
Don't run the IPA passes if there was any error or sorry messages.
Do nothing else if any IPA pass found errors or if we are just streaming LTO.
This pass remove bodies of extern inline functions we never inlined. Do this later so other IPA passes see what is really going on.
Output everything.
When weakref support is missing, we autmatically translate all references to NODE to references to its ultimate alias target. The renaming mechanizm uses flag IDENTIFIER_TRANSPARENT_ALIAS and TREE_CHAIN. Set up this mapping before we output any assembler but once we are sure that all symbol renaming is done. FIXME: All this uglyness can go away if we just do renaming at gimple level by physically rewritting the IL. At the moment we can only redirect calls, so we need infrastructure for renaming references as well.
References dump_cgraph_node().
int compute_call_stmt_bb_frequency | ( | tree | , |
basic_block | bb | ||
) |
htab_t constant_pool_htab | ( | void | ) |
Constant pool accessor function.
|
inlinestatic |
Return true if iterator CSI points to nothing.
Referenced by enqueue_node().
|
inlinestatic |
Advance iterator CSI.
Referenced by enqueue_node().
|
staticread |
Return the node pointed to by CSI.
Referenced by enqueue_node().
|
inlinestatic |
Return an iterator to the first node in SET.
Referenced by enqueue_node().
Referenced by varpool_node_for_decl(), and varpool_remove_initializer().
void debug_cgraph | ( | void | ) |
Dump the call graph to stderr.
References AVAIL_OVERWRITABLE, cgraph_for_node_and_aliases(), cgraph_function_body_availability(), and ipa_ref_referring_node().
void debug_cgraph_node | ( | struct cgraph_node * | ) |
void debug_cgraph_node_set | ( | cgraph_node_set | ) |
void debug_symtab | ( | void | ) |
Dump symbol table to stderr.
References symtab_node_base::decl, error(), and symtab_get_node().
void debug_symtab_node | ( | symtab_node | ) |
void debug_varpool | ( | void | ) |
Dump the variable pool to stderr.
References error_mark_node, and TREE_CODE.
void debug_varpool_node_set | ( | varpool_node_set | ) |
|
inlinestatic |
Return true if the TM_CLONE bit is set for a given FNDECL.
void delete_function_version | ( | tree | decl | ) |
Remove the cgraph_function_version_info and cgraph_node for DECL. This DECL is a duplicate declaration.
void dump_cgraph | ( | FILE * | ) |
In cgraph.c
void dump_cgraph_node | ( | FILE * | , |
struct cgraph_node * | |||
) |
void dump_cgraph_node_set | ( | FILE * | , |
cgraph_node_set | |||
) |
void dump_symtab | ( | FILE * | ) |
Referenced by init_cgraph().
void dump_symtab_base | ( | FILE * | , |
symtab_node | |||
) |
Referenced by varpool_remove_initializer().
void dump_symtab_node | ( | FILE * | , |
symtab_node | |||
) |
void dump_varpool | ( | FILE * | ) |
void dump_varpool_node | ( | FILE * | , |
struct varpool_node * | |||
) |
Referenced by dump_varpool_node().
void dump_varpool_node_set | ( | FILE * | , |
varpool_node_set | |||
) |
bool expand_thunk | ( | struct cgraph_node * | , |
bool | |||
) |
void finalize_compilation_unit | ( | void | ) |
Analyze the whole compilation unit once it is parsed completely.
If we're here there's no current function anymore. Some frontends are lazy in clearing these.
Do not skip analyzing the functions if there were errors, we miss diagnostics for following functions otherwise.
Emit size functions we didn't inline.
Mark alias targets necessary and emit diagnostics.
Gimplify and lower all functions, compute reachability and remove unreachable nodes.
Mark alias targets necessary and emit diagnostics.
Gimplify and lower thunks.
Finally drive the pass manager.
void fixup_same_cpp_alias_visibility | ( | symtab_node | node, |
symtab_node | target | ||
) |
void fixup_same_cpp_alias_visibility | ( | symtab_node | , |
symtab_node | target, | ||
tree | |||
) |
void free_cgraph_node_set | ( | cgraph_node_set | ) |
void free_varpool_node_set | ( | varpool_node_set | ) |
|
read |
Get the cgraph_function_version_info node corresponding to node.
Verify if the type of the argument and lhs of CALL_STMT matches that of the function declaration CALLEE. If ARGS_COUNT_MATCH is true, the arg count needs to be the same. If we cannot verify this or there is a mismatch, return false.
void init_cgraph | ( | void | ) |
Initialize callgraph dump file.
References cgraph_dump_file, and dump_symtab().
basic_block init_lowered_empty_function | ( | tree | , |
bool | |||
) |
Initialize datastructures so DECL is a function in lowered gimple form. IN_SSA is true if the gimple is in SSA.
|
read |
Insert a new cgraph_function_version_info node into cgraph_fnver_htab corresponding to cgraph_node NODE.
void ipa_discover_readonly_nonaddressable_vars | ( | void | ) |
Discover variables that have no longer address taken or that are read only and update their flags.
FIXME: This can not be done in between gimplify and omp_expand since readonly flag plays role on what is shared and what is not. Currently we do this transformation as part of whole program visibility and re-do at ipa-reference pass (to take into account clonning), but it would make sense to do it before early optimizations.
Making variable in explicit section readonly can cause section type conflict. See e.g. gcc.c-torture/compile/pr23237.c
References symtab_node_base::decl, dump_file, TREE_READONLY, and varpool_node_name().
void ipa_record_stmt_references | ( | struct cgraph_node * | , |
gimple | |||
) |
unsigned int rebuild_cgraph_edges | ( | void | ) |
Rebuild cgraph edges for current function node. This needs to be run after passes that don't update the cgraph.
Referenced by gate_tm_memopt().
Record that DECL1 and DECL2 are semantically identical function versions.
void release_function_body | ( | tree | ) |
bool resolution_used_from_other_file_p | ( | enum | ld_plugin_symbol_resolution | ) |
void symtab_add_to_same_comdat_group | ( | symtab_node | new_node, |
symtab_node | old_node | ||
) |
Add NEW_ to the same comdat group that OLD is in.
References symtab_node_base::next, NULL, and symtab_node_base::same_comdat_group.
|
inlinestatic |
FIXME: inappropriate dependency of cgraph on IPA. Return node that alias N is aliasing.
Referenced by output_weakrefs().
symtab_node symtab_alias_ultimate_target | ( | symtab_node | , |
enum availability * | avail = NULL |
||
) |
Referenced by symtab_nonoverwritable_alias().
|
inlinestatic |
Return true if NODE can be discarded by linker from the binary.
void symtab_dissolve_same_comdat_group_list | ( | symtab_node | node | ) |
Referenced by clone_inlined_nodes().
bool symtab_for_node_and_aliases | ( | symtab_node | node, |
bool(*)(symtab_node, void *) | callback, | ||
void * | data, | ||
bool | include_overwritable | ||
) |
Call calback on NODE and aliases associated to NODE. When INCLUDE_OVERWRITABLE is false, overwritable aliases and thunks are skipped.
Referenced by symtab_resolve_alias().
symtab_node symtab_get_node | ( | const_tree | ) |
Referenced by can_refer_decl_in_current_unit_p(), and debug_symtab().
void symtab_initialize_asm_name_hash | ( | void | ) |
Initalize asm name hash unless.
Referenced by symtab_remove_node().
void symtab_insert_node_to_hashtable | ( | symtab_node | ) |
void symtab_make_decl_local | ( | tree | ) |
Referenced by cgraph_unnest_node().
const char* symtab_node_asm_name | ( | symtab_node | ) |
Referenced by ipa_remove_all_referring().
enum availability symtab_node_availability | ( | symtab_node | ) |
Referenced by symtab_alias_ultimate_target(), and symtab_resolve_alias().
symtab_node symtab_node_for_asm | ( | const_tree | asmname | ) |
Referenced by dump_varpool().
const char* symtab_node_name | ( | symtab_node | ) |
symtab_node symtab_nonoverwritable_alias | ( | symtab_node | ) |
void symtab_prevail_in_asm_name_hash | ( | symtab_node | node | ) |
|
inlinestatic |
Return true when the symbol is real symbol, i.e. it is not inline clone or abstract function kept for debug info purposes only.
void symtab_register_node | ( | symtab_node | ) |
In symtab.c
Referenced by cgraph_call_node_duplication_hooks(), and input_overwrite_node().
void symtab_remove_node | ( | symtab_node | ) |
In ipa.c
Referenced by execute_function_todo().
bool symtab_resolve_alias | ( | symtab_node | node, |
symtab_node | target | ||
) |
bool symtab_semantically_equivalent_p | ( | symtab_node | a, |
symtab_node | b | ||
) |
Return true if A and B represents semantically equivalent symbols.
Equivalent functions are equivalent.
If symbol is not overwritable by different implementation, walk to the base object it defines.
void symtab_unregister_node | ( | symtab_node | ) |
Referenced by cgraph_node_remove_callees(), and varpool_node_for_decl().
bool symtab_used_from_object_file_p | ( | symtab_node | ) |
void tree_function_versioning | ( | tree | old_decl, |
tree | new_decl, | ||
vec< ipa_replace_map_p, va_gc > * | tree_map, | ||
bool | update_clones, | ||
bitmap | args_to_skip, | ||
bool | skip_return, | ||
bitmap | blocks_to_copy, | ||
basic_block | new_entry | ||
) |
Create a copy of a function's tree. OLD_DECL and NEW_DECL are FUNCTION_DECL tree nodes of the original function and the new copied function respectively. In case we want to replace a DECL tree with another tree while duplicating the function's body, TREE_MAP represents the mapping between these trees. If UPDATE_CLONES is set, the call_stmt fields of edges of clones of the function will be updated.
If non-NULL ARGS_TO_SKIP determine function parameters to remove from new version. If SKIP_RETURN is true, the new version will return void. If non-NULL BLOCK_TO_COPY determine what basic blocks to copy. If non_NULL NEW_ENTRY determine new entry BB of the clone.
Copy over debug args.
Output the inlining info for this abstract function, since it has been inlined. If we don't do this now, we can lose the information about the variables in the function when the blocks get blown away as soon as we remove the cgraph node.
Prepare the data structures for the tree copy.
Generate a new name for the new version.
Copy the function's static chain.
If there's a tree_map, prepare for substitution.
Copy the function's arguments.
Add local vars.
Set up the destination functions loop tree.
Copy the Function's body.
Renumber the lexical scoping (non-code) blocks consecutively.
We want to create the BB unconditionally, so that the addition of debug stmts doesn't affect BB count, which may in the end cause codegen differences.
Remap the nonlocal_goto_save_area, if any.
Clean up.
After partial cloning we need to rescale frequencies, so they are within proper range in the cloned function.
|
staticread |
Return varpool node for given symbol and check it is a variable.
Referenced by ipa_ref_referring_node().
void varpool_add_new_variable | ( | tree | ) |
|
read |
Referenced by devirt_variable_node_removal_hook().
|
read |
|
staticread |
|
inlinestatic |
Return true when all references to VNODE 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.
void varpool_analyze_node | ( | struct varpool_node * | ) |
bool varpool_assemble_decl | ( | struct varpool_node * | node | ) |
Referenced by expand_all_functions().
|
inlinestatic |
Return true when function NODE can be removed from callgraph if all direct calls are eliminated.
|
read |
In varpool.c
Allocate new callgraph node and insert it into basic data structures.
|
read |
bool varpool_externally_visible_p | ( | struct varpool_node * | ) |
|
read |
void varpool_finalize_decl | ( | tree | ) |
Referenced by coverage_end_function(), and coverage_obj_init().
void varpool_finalize_named_section_flags | ( | struct varpool_node * | node | ) |
|
staticread |
Return first reachable static variable with initializer.
|
staticread |
Return first reachable static variable with initializer.
|
staticread |
Return first variable.
bool varpool_for_node_and_aliases | ( | struct varpool_node * | node, |
bool(*)(struct varpool_node *, void *) | callback, | ||
void * | data, | ||
bool | include_overwritable | ||
) |
Call calback on NODE and aliases associated to NODE. When INCLUDE_OVERWRITABLE is false, overwritable aliases and thunks are skipped.
Referenced by varpool_create_variable_alias().
|
staticread |
Return varpool node for given symbol and check it is a function.
Referenced by default_select_section(), maybe_record_node(), and type_tag().
void varpool_mark_needed_node | ( | struct varpool_node * | ) |
|
staticread |
Return next reachable static variable with initializer after NODE.
|
staticread |
Return next reachable static variable with initializer after NODE.
|
staticread |
Return next variable after NODE.
|
inlinestatic |
Return asm name of varpool node.
|
read |
|
read |
Referenced by mark_address(), mark_load(), and varpool_output_variables().
|
inlinestatic |
Return true if SET contains NODE.
|
inlinestatic |
Return name of varpool node.
Referenced by ipa_discover_readonly_nonaddressable_vars().
void varpool_node_set_add | ( | varpool_node_set | , |
struct varpool_node * | |||
) |
varpool_node_set_iterator varpool_node_set_find | ( | varpool_node_set | , |
struct varpool_node * | |||
) |
varpool_node_set varpool_node_set_new | ( | void | ) |
Create a new varpool node set.
|
inlinestatic |
Return true if set is nonempty.
void varpool_node_set_remove | ( | varpool_node_set | , |
struct varpool_node * | |||
) |
|
inlinestatic |
Return number of nodes in SET.
bool varpool_output_variables | ( | void | ) |
Output all variables enqueued to be assembled.
References symtab_node_base::alias, symtab_node_base::alias_target, symtab_node_base::decl, DECL_ATTRIBUTES, symtab_node_base::definition, gcc_assert, lookup_attribute(), NULL, TREE_CODE, varpool_node_for_decl(), and symtab_node_base::weakref.
void varpool_remove_initializer | ( | struct varpool_node * | ) |
Referenced by varpool_node_for_decl().
void varpool_remove_node | ( | struct varpool_node * | node | ) |
void varpool_remove_node_removal_hook | ( | struct varpool_node_hook_list * | ) |
void varpool_remove_variable_insertion_hook | ( | struct varpool_node_hook_list * | ) |
void varpool_reset_queue | ( | void | ) |
|
staticread |
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 availability in the chain.
void verify_cgraph | ( | void | ) |
Verify whole cgraph structure.
Referenced by cgraph_materialize_clone().
void verify_cgraph_node | ( | struct cgraph_node * | ) |
void verify_symtab | ( | void | ) |
Verify symbol table for internal consistency.
bool verify_symtab_base | ( | symtab_node | ) |
void verify_symtab_node | ( | symtab_node | ) |
|
inlinestatic |
Return true if iterator VSI points to nothing.
|
inlinestatic |
Advance iterator VSI.
|
staticread |
Return the node pointed to by VSI.
|
inlinestatic |
Return an iterator to the first node in SET.
struct asm_node* asm_nodes |
Linked list of cgraph asm nodes.
const char* const cgraph_availability_names[] |
Names used to print out the availability enum.
Referenced by varpool_remove_initializer().
FILE* cgraph_dump_file |
int cgraph_edge_max_uid |
Maximal uid used in cgraph edges.
Referenced by ipcp_propagate_stage().
bool cgraph_function_flags_ready |
Set when the cgraph is fully build and the basic flags are computed.
Referenced by cgraph_variable_initializer_availability(), and varpool_remove_initializer().
bool cgraph_global_info_ready |
Set when whole unit has been analyzed so we can access global info.
int cgraph_max_uid |
Maximal uid used in cgraph nodes.
int cgraph_n_nodes |
Number of nodes in existence.
Referenced by cgraph_remove_node_duplication_hook().
cgraph_node_set cgraph_new_nodes |
Driver of optimization process Copyright (C) 2003-2013 Free Software Foundation, Inc. Contributed by Jan Hubicka
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/. This module implements main driver of compilation process.
The main scope of this file is to act as an interface in between tree based frontends and the backend.
The front-end is supposed to use following functionality:
cgraph_finalize_function
This function is called once front-end has parsed whole body of function and it is certain that the function body nor the declaration will change.
(There is one exception needed for implementing GCC extern inline function.)
varpool_finalize_decl
This function has same behavior as the above but is used for static variables.
add_asm_node
Insert new toplevel ASM statement
finalize_compilation_unit
This function is called once (source level) compilation unit is finalized and it will no longer change.
The symbol table is constructed starting from the trivially needed symbols finalized by the frontend. Functions are lowered into GIMPLE representation and callgraph/reference lists are constructed. Those are used to discover other necessary functions and variables.
At the end the bodies of unreachable functions are removed.
The function can be called multiple times when multiple source level compilation units are combined.
compile
This passes control to the back-end. Optimizations are performed and final assembler is generated. This is done in the following way. Note that with link time optimization the process is split into three stages (compile time, linktime analysis and parallel linktime as indicated bellow).
Compile time:
1) Inter-procedural optimization. (ipa_passes)
This part is further split into:
a) early optimizations. These are local passes executed in the topological order on the callgraph.
The purpose of early optimiations is to optimize away simple things that may otherwise confuse IP analysis. Very simple propagation across the callgraph is done i.e. to discover functions without side effects and simple inlining is performed.
b) early small interprocedural passes.
Those are interprocedural passes executed only at compilation time. These include, for example, transational memory lowering, unreachable code removal and other simple transformations.
c) IP analysis stage. All interprocedural passes do their analysis.
Interprocedural passes differ from small interprocedural passes by their ability to operate across whole program at linktime. Their analysis stage is performed early to both reduce linking times and linktime memory usage by not having to represent whole program in memory.
d) LTO sreaming. When doing LTO, everything important gets streamed into the object file.
Compile time and or linktime analysis stage (WPA):
At linktime units gets streamed back and symbol table is merged. Function bodies are not streamed in and not available. e) IP propagation stage. All IP passes execute their IP propagation. This is done based on the earlier analysis without having function bodies at hand. f) Ltrans streaming. When doing WHOPR LTO, the program is partitioned and streamed into multple object files.
Compile time and/or parallel linktime stage (ltrans)
Each of the object files is streamed back and compiled separately. Now the function bodies becomes available again.
2) Virtual clone materialization (cgraph_materialize_clone) IP passes can produce copies of existing functoins (such as versioned clones or inline clones) without actually manipulating their bodies by creating virtual clones in the callgraph. At this time the virtual clones are turned into real functions 3) IP transformation All IP passes transform function bodies based on earlier decision of the IP propagation. 4) late small IP passes Simple IP passes working within single program partition. 5) Expansion (expand_all_functions) At this stage functions that needs to be output into assembler are identified and compiled in topological order 6) Output of variables and aliases Now it is known what variable references was not optimized out and thus all variables are output to the file. Note that with -fno-toplevel-reorder passes 5 and 6 are combined together in cgraph_output_in_order.
Finally there are functions to manipulate the callgraph from backend.
cgraph_function_versioning
produces a copy of function into new one (a version) and apply simple transformations Queue of cgraph nodes scheduled to be added into cgraph. This is a secondary queue used during optimization to accommodate passes that may generate new functions that need to be optimized and expanded.
enum cgraph_state cgraph_state |
What state callgraph is in right now.
bool cpp_implicit_aliases_done |
Did procss_same_body_aliases run?
const char* const ld_plugin_symbol_resolution_names[] |
Symbol table. Copyright (C) 2012-2013 Free Software Foundation, Inc. Contributed by Jan Hubicka
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/.
symtab_node symtab_nodes |
Linked list of symbol table nodes.
int symtab_order |
The order index of the next symtab node to be created. This is used so that we can sort the cgraph nodes in order by when we saw them, to support -fno-toplevel-reorder.
Referenced by input_overwrite_node().