GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "tree.h"
#include "tree-inline.h"
#include "langhooks.h"
#include "hashtab.h"
#include "toplev.h"
#include "flags.h"
#include "ggc.h"
#include "debug.h"
#include "target.h"
#include "basic-block.h"
#include "cgraph.h"
#include "intl.h"
#include "gimple.h"
#include "timevar.h"
#include "dumpfile.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-ssa.h"
#include "value-prof.h"
#include "except.h"
#include "diagnostic-core.h"
#include "rtl.h"
#include "ipa-utils.h"
#include "lto-streamer.h"
#include "ipa-inline.h"
#include "cfgloop.h"
#include "gimple-pretty-print.h"
#include "tree-pass.h"
#include "cif-code.def"
#include "gt-cgraph.h"
Data Structures | |
struct | cgraph_edge_hook_list |
struct | cgraph_node_hook_list |
struct | cgraph_2edge_hook_list |
struct | cgraph_2node_hook_list |
Macros | |
#define | cgraph_nodes_queue ((struct cgraph_node *)x_cgraph_nodes_queue) |
#define | NEXT_FREE_NODE(NODE) cgraph ((NODE)->next) |
#define | SET_NEXT_FREE_NODE(NODE, NODE2) ((NODE))->next = NODE2 |
#define | NEXT_FREE_EDGE(EDGE) (EDGE)->prev_caller |
#define | DEFCIFCODE(code, string) string, |
Variables | |
symtab_node | x_cgraph_nodes_queue |
int | cgraph_n_nodes |
int | cgraph_max_uid |
int | cgraph_edge_max_uid |
bool | cgraph_global_info_ready = false |
enum cgraph_state | cgraph_state = CGRAPH_STATE_PARSING |
bool | cgraph_function_flags_ready = false |
struct cgraph_edge_hook_list * | first_cgraph_edge_removal_hook |
struct cgraph_node_hook_list * | first_cgraph_node_removal_hook |
struct cgraph_2edge_hook_list * | first_cgraph_edge_duplicated_hook |
struct cgraph_2node_hook_list * | first_cgraph_node_duplicated_hook |
struct cgraph_node_hook_list * | first_cgraph_function_insertion_hook |
static struct cgraph_node * | free_nodes |
static struct cgraph_edge * | free_edges |
bool | cpp_implicit_aliases_done |
static htab_t | cgraph_fnver_htab = NULL |
static struct cgraph_function_version_info * | version_info_node = NULL |
const char *const | cgraph_availability_names [] |
#define cgraph_nodes_queue ((struct cgraph_node *)x_cgraph_nodes_queue) |
#define DEFCIFCODE | ( | code, | |
string | |||
) | string, |
#define NEXT_FREE_EDGE | ( | EDGE | ) | (EDGE)->prev_caller |
Referenced by cgraph_create_indirect_edge().
#define NEXT_FREE_NODE | ( | NODE | ) | cgraph ((NODE)->next) |
Macros to access the next item in the list of free cgraph nodes and edges.
Referenced by cgraph_add_node_duplication_hook().
#define SET_NEXT_FREE_NODE | ( | NODE, | |
NODE2 | |||
) | ((NODE))->next = NODE2 |
|
read |
Register HOOK to be called with DATA on each duplicated edge.
References cgraph_2node_hook_list::data, first_cgraph_node_duplicated_hook, cgraph_2node_hook_list::hook, cgraph_2node_hook_list::next, and NULL.
Referenced by ipa_edge_duplication_hook().
|
read |
Register HOOK to be called with DATA on each removed edge.
References cgraph_edge_hook_list::data, cgraph_edge_hook_list::hook, and cgraph_edge_hook_list::next.
Referenced by ipa_edge_duplication_hook().
|
inlinestatic |
Add call graph edge E to call site hash of its caller.
There are two speculative edges for every statement (one direct, one indirect); always hash the direct one.
|
read |
Register HOOK to be called with DATA on each inserted node.
References cgraph_2edge_hook_list::data, first_cgraph_edge_duplicated_hook, cgraph_2edge_hook_list::hook, cgraph_2edge_hook_list::next, and NULL.
Referenced by ipa_edge_duplication_hook().
|
read |
Register HOOK to be called with DATA on each duplicated node.
References free_nodes, and NEXT_FREE_NODE.
Referenced by ipa_edge_duplication_hook().
|
read |
Register HOOK to be called with DATA on each removed node.
Referenced by devirt_variable_node_removal_hook(), and ipa_edge_duplication_hook().
|
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.
|
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.
|
staticread |
Allocate new callgraph node.
Referenced by cgraph_remove_node_duplication_hook().
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().
|
static |
Call all edge removal hooks.
void cgraph_call_function_insertion_hooks | ( | ) |
Call all node insertion hooks.
References cgraph_2edge_hook_list::data, first_cgraph_edge_duplicated_hook, cgraph_2edge_hook_list::hook, and cgraph_2edge_hook_list::next.
Referenced by cgraph_process_new_functions().
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.
|
static |
Call all node removal hooks.
References cgraph_node_hook_list::data, first_cgraph_function_insertion_hook, cgraph_node_hook_list::hook, and cgraph_node_hook_list::next.
Referenced by cgraph_node_remove_callees().
bool cgraph_can_remove_if_no_direct_calls_and_refs_p | ( | ) |
Return true when function NODE can be removed from callgraph if all direct calls are eliminated.
Extern inlines can always go, we will use the external definition.
When function is needed, we can not remove it.
Only COMDAT functions can be removed if externally visible.
References cgraph_edge::call_stmt, cgraph_edge::caller, compute_call_stmt_bb_frequency(), symtab_node_base::decl, error(), and cgraph_edge::frequency.
Referenced by cgraph_make_node_local(), and symtab_remove_unreachable_nodes().
bool cgraph_can_remove_if_no_direct_calls_p | ( | ) |
Return true when function NODE and its aliases can be removed from callgraph if all direct calls are eliminated.
Extern inlines can always go, we will use the external definition.
References cgraph_edge::callee, cgraph_get_node(), CGRAPH_LTO_STREAMING, cgraph_node::global, and cgraph_global_info::inlined_to.
Referenced by cgraph_set_const_flag_1().
|
read |
Create edge from CALLER to CALLEE in the cgraph.
Referenced by build_cgraph_edges(), cgraph_clone_edge(), and ipa_tm_diagnose_tm_safe().
|
staticread |
Allocate a cgraph_edge structure and fill it with data according to the parameters of which only CALLEE can be NULL (when creating an indirect call edge).
LTO does not actually have access to the call_stmt since these have not been loaded yet.
This is a rather expensive check possibly triggering construction of call stmt hashtable.
References cgraph_node::callees, cgraph_node::callers, initialize_inline_failed(), cgraph_edge::next_callee, cgraph_edge::next_caller, cgraph_edge::prev_callee, and cgraph_edge::prev_caller.
|
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 |
Mark ALIAS as an alias to DECL. DECL_NODE is cgraph node representing the function body is associated with (not necessarily cgraph_node (DECL).
References symtab_node_base::alias, cgraph_thunk_info::alias, cgraph_create_node(), cgraph_get_node(), cgraph_remove_node(), symtab_node_base::definition, cgraph_thunk_info::fixed_offset, double_int::from_shwi(), gcc_assert, gcc_checking_assert, NULL, cgraph_thunk_info::this_adjusting, cgraph_node::thunk, cgraph_thunk_info::thunk_p, tree_to_double_int(), cgraph_thunk_info::virtual_offset_p, and cgraph_thunk_info::virtual_value.
|
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 |
Return cgraph node assigned to DECL. Create new one when needed.
Referenced by cgraph_create_function_alias(), expand_assign_tm(), and update_call_expr().
|
static |
Switch to THIS_CFUN if needed and print STMT to stderr.
debug_gimple_stmt needs correct cfun
...and an actual current_function_decl
References error().
|
read |
Return the callgraph edge representing the GIMPLE_CALL statement CALL_STMT.
This loop may turn out to be performance problem. In such case adding hashtables into call nodes with very many edges is probably best solution. It is not good idea to add pointer into CALL_EXPR itself because we want to make possible having multiple cgraph nodes representing different clones of the same body before the body is actually cloned.
Referenced by cgraph_set_edge_callee(), and update_call_edge_frequencies().
bool cgraph_edge_cannot_lead_to_return | ( | ) |
Return true when call of E can not lead to return from caller and thus it is safe to ignore its side effects for IPA analysis when computing side effects of the caller. FIXME: We could actually mark all edges that have no reaching patch to EXIT_BLOCK_PTR or throw to get better results.
References cgraph_edge::caller, CGRAPH_FREQ_MAX, cgraph_edge::count, symtab_node_base::decl, error(), error_found, cgraph_edge::frequency, gimple_has_body_p(), cgraph_node::global, and cgraph_global_info::inlined_to.
|
inlinestatic |
|
inlinestatic |
Remove the edge E from the list of the callers of the callee.
|
inlinestatic |
|
inlinestatic |
Remove the edge E from the list of the callees of the caller.
References cgraph_edge::caller, cgraph_node_name(), dump_file, and symtab_node_base::order.
|
static |
eq function for cgraph_fnver_htab.
|
static |
Hash function for cgraph_fnver_htab.
References cgraph_fnver_htab, NULL, and cgraph_function_version_info::this_node.
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().
|
static |
Put the edge onto the free list.
Clear out the edge so we do not dangle pointers.
enum availability cgraph_function_body_availability | ( | ) |
Return function availability. See cgraph.h for description of individual return values.
Inline functions are safe to be analyzed even if their symbol can be overwritten at runtime. It is not meaningful to enforce any sane behaviour on replacing inline function by different body.
If the function can be overwritten, return OVERWRITABLE. Take care at least of two notable extensions - the COMDAT functions used to share template instantiations in C++ (this is symmetric to code cp_cannot_inline_tree_fn and probably shall be shared and the inlinability hooks completely eliminated). ??? Does the C++ one definition rule allow us to always return AVAIL_AVAILABLE here? That would be good reason to preserve this bit.
References cgraph_for_node_thunks_and_aliases(), and cgraph_make_node_local_1().
Referenced by cgraph_unnest_node(), debug_cgraph(), and print_all_lattices().
|
read |
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 availability in the chain.
Referenced by ipa_reverse_postorder(), known_aggs_to_agg_replacement_list(), propagate_aggs_accross_jump_function(), read_write_all_from_decl(), and set_reference_optimization_summary().
bool cgraph_function_possibly_inlined_p | ( | ) |
Return true when the DECL can possibly be inlined.
bool cgraph_get_body | ( | ) |
When doing LTO, read NODE's body from disk if it is not already present.
We may have renamed the declaration, e.g., a static function.
Referenced by cgraph_materialize_clone().
|
read |
Try to find a call graph node for declaration DECL and if it does not exist, create it.
Referenced by build_cgraph_edges(), cgraph_call_node_duplication_hooks(), cgraph_create_empty_node(), delete_function_version(), ipa_tm_diagnose_tm_safe(), ipa_tm_mark_force_output_node(), and lower_emutls_phi_arg().
|
read |
Create external decl node for DECL. The difference i nbetween cgraph_get_create_node and cgraph_get_create_real_symbol_node is that cgraph_get_create_node may return inline clone, while cgraph_get_create_real_symbol_node will create a new node in this case. FIXME: This function should be removed once clones are put out of decl hash.
create symbol table node. even if inline clone exists, we can not take it as a target of non-inlined call.
ok, we previously inlined the function, then removed the offline copy and now we want it back for external call. this can happen when devirtualizing while inlining function called once that happens after extern inlined and virtuals are already removed. in this case introduce the external node and make it available for call.
|
read |
Return local info for the compiled function.
const char* cgraph_inline_failed_string | ( | ) |
Return a string describing the failure REASON.
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.
Inlining failed for an unspecified reason.
Function has not be considered for inlining. This is the code for functions that have not been rejected for inlining yet.
Caller is compiled with optimizations disabled.
Inlining failed owing to unavailable function body.
Extern inline function that has been redefined.
Function is not inlinable.
Function is overwritable.
Function is not an inlining candidate.
Inlining failed because of various limit parameters.
Recursive inlining.
Call is unlikely.
Function is not declared as inline.
Inlining suppressed due to size optimization.
Caller and callee disagree on the arguments.
Call was originally indirect.
Ths edge represents an indirect edge with a yet-undetermined callee .
We can't inline different EH personalities together.
We can't inline if the callee can throw non-call exceptions but the caller cannot.
We can't inline because of mismatched target specific options.
We can't inline because of mismatched optimization levels.
Signedness of an enum type is implementation defined, so cast it to unsigned before testing.
|
read |
Return local info for the compiled function.
|
read |
Make an indirect EDGE with an unknown callee an ordinary edge leading to CALLEE. DELTA is an integer constant that is to be added to the this pointer (first parameter) to compensate for skipping a thunk adjustment.
If we are redirecting speculative call, make it non-speculative.
On successful speculation just return the pre existing direct edge.
Get the edge out of the indirect edge list.
Put it into the normal callee list
Insert to callers list of the new callee.
We need to re-determine the inlining status of the edge.
void cgraph_make_node_local | ( | ) |
Bring NODE local.
References cgraph_can_remove_if_no_direct_calls_and_refs_p().
|
static |
Worker to bring NODE local.
Referenced by cgraph_function_body_availability().
void cgraph_mark_address_taken_node | ( | ) |
Likewise indicate that a node is having address taken.
Indirect inlining can figure out that all uses of the address are inlined.
FIXME: address_taken flag is used both as a shortcut for testing whether IPA_REF_ADDR reference exists (and thus it should be set on node representing alias we take address of) and as a test whether address of the object was taken (and thus it should be set on node alias is referring to). We should remove the first use and the remove the following set.
bool cgraph_node_can_be_local_p | ( | ) |
Return true if NODE can be made local for API change. Extern inline functions and C++ COMDAT functions can be made local at the expense of possible code size growth if function is used in multiple compilation units.
|
static |
Worker for cgraph_node_can_be_local_p.
References symtab_node_base::decl, DECL_STATIC_CONSTRUCTOR, and DECL_STATIC_DESTRUCTOR.
bool cgraph_node_cannot_return | ( | ) |
Return true when NODE can not return or throw and thus it is safe to ignore its side effects for IPA analysis.
Referenced by cgraph_for_node_and_aliases().
|
read |
Return the cgraph node that has ASMNAME for its DECL_ASSEMBLER_NAME. Return NULL if there's no such node.
We do not want to look at inline clones.
References cgraph_edge::callee, and gcc_assert.
void cgraph_node_remove_callees | ( | ) |
Remove all callees from the node.
It is sufficient to remove the edges from the lists of callers of the callees. The callee list of the node can be zapped with one assignment.
References cgraph_call_node_removal_hooks(), cgraph_node_remove_callers(), cgraph_node::clone_of, cgraph_node::clones, symtab_node_base::force_output, symtab_node_base::forced_by_abi, cgraph_node::ipa_transforms_to_apply, cgraph_node::nested, symtab_node_base::next, cgraph_node::next_nested, cgraph_node::next_sibling_clone, NULL, cgraph_node::origin, cgraph_node::prev_sibling_clone, symtab_unregister_node(), and cgraph_node::uid.
|
static |
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/. This file contains basic routines manipulating call graph
The call-graph is a data structure designed for intra-procedural optimization. It represents a multi-graph where nodes are functions and edges are call sites. FIXME: Only for PROP_loops, but cgraph shouldn't have to know about this.
Referenced by cgraph_node_remove_callees().
|
static |
Remove all callers from the node.
It is sufficient to remove the edges from the lists of callees of the callers. The caller list of the node can be zapped with one assignment.
References cgraph_node::clone_of, cgraph_node::clones, cgraph_node::next_sibling_clone, and cgraph_node::prev_sibling_clone.
|
static |
Worker for cgraph_only_called_directly_p.
Referenced by cgraph_set_pure_flag_1().
bool cgraph_only_called_directly_p | ( | ) |
Return true when function NODE and all its aliases are only called directly. 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_1().
gimple cgraph_redirect_edge_call_stmt_to_callee | ( | ) |
If necessary, change the function declaration in the call statement associated with E so that it corresponds to the edge callee.
If there already is an direct call (i.e. as a result of inliner's substitution), forget about speculating.
If types do not match, speculation was likely wrong. The direct edge was posisbly redirected to the clone with a different signature. We did not update the call statement yet, so compare it with the reference that still points to the proper type.
We are producing the final function body and will throw away the callgraph edges really soon. Reset the counts/frequencies to keep verifier happy in the case of roundoff errors.
Expand speculation into GIMPLE code.
Indirect edges are not both in the call site hash. get it updated.
Continue redirecting E to proper target.
We need to defer cleaning EH info on the new statement to fixup-cfg. We may not have dominator information at this point and thus would end up with unreachable blocks and have no way to communicate that we need to run CFG cleanup then.
References cgraph_edge::callee, cgraph_dump_file, cgraph_node::clone, cgraph_clone_info::combined_args_to_skip, and dump_bitmap().
void cgraph_redirect_edge_callee | ( | ) |
Redirect callee of E to N. The function does not update underlying call expression.
Remove from callers list of the current callee.
Insert to callers list of the new callee.
Referenced by clone_inlined_nodes(), known_aggs_to_agg_replacement_list(), lookup_recursive_calls(), and recursive_inlining().
void cgraph_release_function_body | ( | ) |
Release memory used to represent body of function NODE. Use this only for functions that are released before being translated to target code (i.e. RTL). Functions that are compiled to RTL and beyond are free'd in final.c via free_after_compilation().
If the node is abstract and needed, then do not clear DECL_INITIAL of its associated function function declaration because it's needed to emit debug info later.
References cgraph_node::callers, cfun, gcc_assert, and cgraph_edge::indirect_inlining_edge.
Referenced by comp_type_attributes().
void cgraph_remove_edge | ( | ) |
Remove the edge E in the cgraph.
Call all edge removal hooks.
Remove from callers list of the callee.
Remove from callees list of the callers.
Put the edge onto the free list.
Referenced by replace_locals_op().
void cgraph_remove_edge_duplication_hook | ( | ) |
Remove ENTRY from the list of hooks called on duplicating edges.
References first_cgraph_node_duplicated_hook, and cgraph_2node_hook_list::next.
void cgraph_remove_edge_removal_hook | ( | ) |
Remove ENTRY from the list of hooks called on removing edges.
void cgraph_remove_function_insertion_hook | ( | ) |
Remove ENTRY from the list of hooks called on inserted nodes.
References first_cgraph_edge_duplicated_hook, and cgraph_2edge_hook_list::next.
void cgraph_remove_node | ( | ) |
Remove the node from cgraph.
Incremental inlining access removed nodes stored in the postorder list.
We are removing node with clones. This makes clones inconsistent, but assume they will be removed subsequently and just keep clone tree intact. This can happen in unreachable function removal since we remove unreachable functions in random order, not by bottom-up walk of clone trees.
While all the clones are removed after being proceeded, the function itself is kept in the cgraph even after it is compiled. Check whether we are done with this body and reclaim it proactively if this is the case.
Clear out the node to NULL all pointers and add the node to the free list.
Referenced by cgraph_create_function_alias().
void cgraph_remove_node_duplication_hook | ( | ) |
Remove ENTRY from the list of hooks called on duplicating nodes.
References cgraph_allocate_node(), cgraph_n_nodes, cgraph_node::count_materialization_scale, NODE_FREQUENCY_NORMAL, REG_BR_PROB_BASE, and SYMTAB_FUNCTION.
void cgraph_remove_node_removal_hook | ( | ) |
Remove ENTRY from the list of hooks called on removing nodes.
|
read |
Speculative call EDGE turned out to be direct call to CALLE_DECL. Remove the speculative call sequence and return edge representing the call. It is up to caller to redirect the call as appropriate.
FIXME: If EDGE is inlined, we should scale up the frequencies and counts in the functions inlined through it.
Referenced by add_new_edges_to_heap().
|
read |
Return local info for the compiled function.
|
read |
Attempt to mark ALIAS as an alias to DECL. Return alias node if successful and NULL otherwise. Same body aliases are output whenever the body of DECL is output, and cgraph_get_node (ALIAS) transparently returns cgraph_get_node (DECL).
If aliases aren't supported by the assembler, fail.
Langhooks can create same body aliases of symbols not defined. Those are useless. Drop them on the floor.
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_const_flag | ( | ) |
Set TREE_READONLY on NODE's decl and on aliases of NODE if any to READONLY.
References cgraph_only_called_directly_or_aliased_p().
|
static |
Worker to set const flag.
Static constructors and destructors without a side effect can be optimized out.
References cgraph_can_remove_if_no_direct_calls_p(), cgraph_for_node_and_aliases(), cgraph_only_called_directly_p(), symtab_node_base::decl, DECL_EXTERNAL, gcc_assert, cgraph_node::global, cgraph_global_info::inlined_to, and used_from_object_file_p().
|
static |
Set callee of call graph edge E and add it to the corresponding set of callers.
References cgraph_edge::call_stmt, cgraph_node::callees, cgraph_edge::caller, cgraph_edge(), gcc_assert, cgraph_edge::indirect_unknown_callee, cgraph_edge::lto_stmt_uid, cgraph_edge::next_callee, and cgraph_edge::speculative.
void cgraph_set_nothrow_flag | ( | ) |
Set TREE_NOTHROW on NODE's decl and on aliases of NODE if any to NOTHROW.
|
static |
Worker to set nothrow flag.
References symtab_node_base::address_taken, cgraph_for_node_and_aliases(), symtab_node_base::decl, DECL_EXTERNAL, and nonremovable_p().
void cgraph_set_pure_flag | ( | ) |
Set DECL_PURE_P on NODE's decl and on aliases of NODE if any to PURE.
Referenced by skip_function_for_local_pure_const().
|
static |
Worker to set pure flag.
Static constructors and destructors without a side effect can be optimized out.
References cgraph_for_node_and_aliases(), cgraph_function_or_thunk_node(), cgraph_not_only_called_directly_p_1(), and gcc_assert.
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 | ( | ) |
NODE is no longer nested function; update cgraph accordingly.
References AVAIL_LOCAL, cgraph_function_body_availability(), symtab_node_base::decl, symtab_node_base::externally_visible, symtab_node_base::forced_by_abi, gcc_assert, cgraph_local_info::local, cgraph_node::local, symtab_make_decl_local(), and symtab_node_base::unique_name.
|
inlinestatic |
Add call graph edge E to call site hash of its caller.
References cgraph_edge::call_stmt.
void cgraph_update_edges_for_call_stmt | ( | ) |
Update or remove the corresponding cgraph edge if a GIMPLE_CALL OLD_STMT changed into NEW_STMT. OLD_DECL is gimple_call_fndecl of OLD_STMT before it was updated (updating can happen inplace).
|
static |
Update or remove the corresponding cgraph edge if a GIMPLE_CALL OLD_STMT changed into NEW_STMT. OLD_CALL is gimple_call_fndecl of OLD_STMT if it was previously call statement. If NEW_STMT is NULL, the call has been dropped without any replacement.
We are seeing indirect calls, then there is nothing to update.
See if we turned indirect call into direct call or folded call to one builtin into different builtin.
See if the edge is already there and has the correct callee. It might be so because of indirect inlining has already updated it. We also might've cloned and redirected the edge.
Otherwise remove edge and create new one; we can't simply redirect since function has changed, so inline plan and other information attached to edge is invalid.
We are seeing new direct call; compute profile info based on BB.
We only updated the call stmt; update pointer in cgraph edge..
bool cgraph_will_be_removed_from_program_if_no_direct_calls | ( | ) |
Return true when function NODE can be expected to be removed from program when direct calls in this compilation unit are removed.
As a special case COMDAT functions are cgraph_can_remove_if_no_direct_calls_p while the are not cgraph_only_called_directly_p (it is possible they are called from other unit)
This function behaves as cgraph_only_called_directly_p because eliminating all uses of COMDAT function does not make it necessarily disappear from the program unless we are compiling whole program or we do LTO. In this case we know we win since dynamic linking will not really discard the linkonce section.
|
static |
Return TRUE if NODE2 is equivalent to NODE or its clone.
References error().
vec<cgraph_edge_p> collect_callers_of_node | ( | ) |
Collect all callers of NODE and its aliases that are known to lead to NODE (i.e. are not overwritable).
|
static |
Collect all callers of NODE. Worker for collect_callers_of_node.
References error().
DEBUG_FUNCTION 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().
DEBUG_FUNCTION void debug_cgraph_node | ( | ) |
Dump call graph node NODE to stderr.
void delete_function_version | ( | ) |
Remove the cgraph_function_version_info and cgraph_node for DECL. This DECL is a duplicate declaration.
References cgraph_get_create_node(), gcc_assert, get_cgraph_node_version(), insert_new_cgraph_node_version(), cgraph_function_version_info::next, and NULL.
void dump_cgraph | ( | ) |
Dump the callgraph to file F.
References ipa_ref_list_referring_iterate, and symtab_node_base::ref_list.
void dump_cgraph_node | ( | ) |
Dump call graph node NODE to file F.
Referenced by compile(), and ipa_print_order().
|
static |
Return nonzero if the call_stmt of of cgraph_edge X is stmt *Y.
References cgraph_edge::call_stmt.
|
static |
Returns a hash value for X (which really is a cgraph_edge).
|
read |
Get the cgraph_function_version_info node corresponding to node.
Referenced by delete_function_version().
|
static |
Verify if the type of the argument matches that of the function declaration. If we cannot verify this or there is a mismatch, return false.
Calls to internal functions always match their signature.
Get argument types for verification.
Verify if the type of the argument matches that of the function declaration. If we cannot verify this or there is a mismatch, return false.
We cannot distinguish a varargs function from the case of excess parameters, still deferring the inlining decision to the callee is possible.
If this is a varargs function defer inlining decision to callee.
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.
|
read |
Insert a new cgraph_function_version_info node into cgraph_fnver_htab corresponding to cgraph_node NODE.
Referenced by delete_function_version().
|
static |
Worker for cgraph_can_remove_if_no_direct_calls_p.
Referenced by cgraph_set_nothrow_flag_1().
void record_function_versions | ( | ) |
Record that DECL1 and DECL2 are semantically identical function versions.
Chain decl2_v and decl1_v. All semantically identical versions will be chained together.
void release_function_body | ( | ) |
Helper function for cgraph_release_function_body and free_lang_data. It releases body from function DECL without having to inspect its possibly non-existent symtab node.
Struct function hangs a lot of data that would leak if we didn't removed all pointers to it.
Referenced by comp_type_attributes().
|
static |
Worker for cgraph_can_remove_if_no_direct_calls_p.
Referenced by cgraph_set_const_flag_1().
DEBUG_FUNCTION void verify_cgraph | ( | void | ) |
Verify whole cgraph structure.
Referenced by cgraph_materialize_clone().
DEBUG_FUNCTION void verify_cgraph_node | ( | ) |
Verify cgraph nodes of given cgraph node.
Reach the trees by walking over the CFG, and note the enclosing basic-blocks in the call edges.
No CFG available?!
|
static |
Verify that call graph edge E corresponds to DECL from the associated statement. Return true if the verification should fail.
We do not know if a node from a different partition is an alias or what it aliases and therefore cannot do the former_clone_of check reliably.
IPA-CP sometimes redirect edge to clone and then back to the former function. This ping-pong has to go, eventually.
|
static |
Verify edge E count and frequency.
FIXME: Inline-analysis sets frequency to 0 when edge is optimized out. Remove this once edges are actually removed from the function at that time.
References error().
const char* const cgraph_availability_names[] |
Names used to print out the availability enum.
Referenced by varpool_remove_initializer().
int cgraph_edge_max_uid |
Maximal uid used in cgraph edges.
Referenced by ipcp_propagate_stage().
|
static |
Map a cgraph_node to cgraph_function_version_info using this htab. The cgraph_function_version_info has a THIS_NODE field that is the corresponding cgraph_node..
Referenced by cgraph_fnver_htab_hash().
Set when the cgraph is fully build and the basic flags are computed.
Referenced by cgraph_variable_initializer_availability(), and varpool_remove_initializer().
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().
What state callgraph is in right now.
bool cpp_implicit_aliases_done |
Did procss_same_body_aliases run?
struct cgraph_2edge_hook_list* first_cgraph_edge_duplicated_hook |
List of hooks triggered when an edge is duplicated.
Referenced by cgraph_add_function_insertion_hook(), cgraph_call_function_insertion_hooks(), and cgraph_remove_function_insertion_hook().
struct cgraph_edge_hook_list* first_cgraph_edge_removal_hook |
List of hooks triggered when an edge is removed.
struct cgraph_node_hook_list* first_cgraph_function_insertion_hook |
List of hooks triggered when an function is inserted.
Referenced by cgraph_call_node_removal_hooks().
struct cgraph_2node_hook_list* first_cgraph_node_duplicated_hook |
List of hooks triggered when a node is duplicated.
Referenced by cgraph_add_edge_duplication_hook(), cgraph_call_edge_duplication_hooks(), and cgraph_remove_edge_duplication_hook().
struct cgraph_node_hook_list* first_cgraph_node_removal_hook |
List of hooks triggered when a node is removed.
|
static |
Head of a linked list of unused (freed) call graph edges. Do not this list so UIDs gets reliably recycled.
Referenced by cgraph_create_indirect_edge().
|
static |
Head of a linked list of unused (freed) call graph nodes. Do not this list so UIDs gets reliably recycled.
Referenced by cgraph_add_node_duplication_hook().
|
static |
Mark as GC root all allocated nodes.
symtab_node x_cgraph_nodes_queue |
Queue of cgraph nodes scheduled to be lowered.