GCC Middle and Back End API Reference
|
Data Structures | |
struct | funct_state_d |
Typedefs | |
typedef struct funct_state_d * | funct_state |
Enumerations | |
enum | pure_const_state_e { IPA_CONST, IPA_PURE, IPA_NEITHER } |
Functions | |
static bool | function_always_visible_to_compiler_p () |
static struct pointer_set_t * | suggest_attribute (int option, tree decl, bool known_finite, struct pointer_set_t *warned_about, const char *attrib_name) |
static void | warn_function_pure () |
static void | warn_function_const () |
void | warn_function_noreturn () |
static void | finish_state () |
static bool | has_function_state () |
static funct_state | get_function_state () |
static void | set_function_state () |
static void | check_decl (funct_state local, tree t, bool checking_write, bool ipa) |
static void | check_op () |
static void | state_from_flags (enum pure_const_state_e *state, bool *looping, int flags, bool cannot_lead_to_return) |
static void | better_state (enum pure_const_state_e *state, bool *looping, enum pure_const_state_e state2, bool looping2) |
static void | worse_state (enum pure_const_state_e *state, bool *looping, enum pure_const_state_e state2, bool looping2) |
static bool | special_builtin_state (enum pure_const_state_e *state, bool *looping, tree callee) |
static void | check_call () |
static bool | check_load () |
static bool | check_store () |
static bool | check_ipa_load () |
static bool | check_ipa_store () |
static void | check_stmt () |
static funct_state | analyze_function () |
static void | add_new_function () |
static void | duplicate_node_data (struct cgraph_node *src, struct cgraph_node *dst, void *data) |
static void | remove_node_data () |
static void | register_hooks () |
static void | pure_const_generate_summary () |
static void | pure_const_write_summary () |
static void | pure_const_read_summary () |
static bool | ignore_edge () |
static bool | self_recursive_p () |
static void | propagate_pure_const () |
static void | propagate_nothrow () |
static unsigned int | propagate () |
static bool | gate_pure_const () |
ipa_opt_pass_d * | make_pass_ipa_pure_const () |
static bool | skip_function_for_local_pure_const () |
static unsigned int | local_pure_const () |
gimple_opt_pass * | make_pass_local_pure_const () |
Variables | |
static struct pointer_set_t * | visited_nodes |
const char * | pure_const_names [3] = {"const", "pure", "neither"} |
static struct funct_state_d | varying_state = { IPA_NEITHER, IPA_NEITHER, true, true, true } |
static vec< funct_state > | funct_state_vec |
static struct cgraph_node_hook_list * | function_insertion_hook_holder |
static struct cgraph_2node_hook_list * | node_duplication_hook_holder |
static struct cgraph_node_hook_list * | node_removal_hook_holder |
typedef struct funct_state_d* funct_state |
enum pure_const_state_e |
|
static |
Called when new function is inserted to callgraph late.
References analyze_function(), AVAIL_OVERWRITABLE, cgraph_function_body_availability(), pointer_set_create(), pointer_set_destroy(), and set_function_state().
Referenced by register_hooks().
|
static |
This is the main routine for finding the reference patterns for global variables within a function FN.
References symtab_node_base::alias, better_state(), funct_state_d::can_throw, cgraph_node_cannot_return(), cgraph_node_name(), check_stmt(), symtab_node_base::decl, dump_file, dump_flags, finite_loop_p(), flags_from_decl_or_type(), flow_loops_dump(), gsi_end_p(), gsi_next(), gsi_start_bb(), IPA_CONST, IPA_NEITHER, IPA_PURE, loop_optimizer_finalize(), loop_optimizer_init(), funct_state_d::looping, funct_state_d::looping_previously_known, LOOPS_HAVE_PREHEADERS, LOOPS_HAVE_RECORDED_EXITS, LOOPS_HAVE_SIMPLE_LATCHES, mark_dfs_back_edges(), mark_irreducible_loops(), memset(), loop::num, pop_cfun(), funct_state_d::pure_const_state, push_cfun(), scev_finalize(), scev_initialize(), state_from_flags(), funct_state_d::state_previously_known, cgraph_node::symbol, cgraph_node::thunk, and cgraph_thunk_info::thunk_p.
Referenced by add_new_function(), local_pure_const(), and pure_const_generate_summary().
|
inlinestatic |
Merge STATE and STATE2 and LOOPING and LOOPING2 and store into STATE and LOOPING better of the two variants. Be sure to merge looping correctly. IPA_NEITHER functions have looping 0 even if they don't have to return.
References IPA_NEITHER.
Referenced by analyze_function(), and propagate_pure_const().
|
static |
Check the parameters of a function call to CALL_EXPR to see if there are any references in the parameters that are not allowed for pure or const functions. Also check to see if this is either an indirect call, a call outside the compilation unit, or has special attributes that may also effect the purity. The CALL_EXPR node for the entire call expression.
References BUILT_IN_NORMAL, funct_state_d::can_throw, function::can_throw_non_call_exceptions, cfun, current_function_decl, dump_file, dump_flags, gimple_call_flags(), gimple_call_fndecl(), gimple_num_ops(), gimple_op(), IPA_NEITHER, lookup_stmt_eh_lp(), funct_state_d::looping, funct_state_d::pure_const_state, setjmp_call_p(), special_builtin_state(), state_from_flags(), stmt_can_throw_external(), stmt_could_throw_p(), tree_could_throw_p(), and worse_state().
Referenced by check_stmt().
|
inlinestatic |
Check to see if the use (or definition when CHECKING_WRITE is true) variable T is legal in a function that is either pure or const.
References dump_file, IPA_CONST, IPA_NEITHER, IPA_PURE, and funct_state_d::pure_const_state.
Referenced by check_ipa_load(), check_ipa_store(), check_load(), and check_store().
|
static |
Wrapper around check_decl for loads in ipa mode.
References check_decl(), and check_op().
Referenced by check_stmt().
|
static |
Wrapper around check_decl for stores in ipa mode.
References check_decl(), and check_op().
Referenced by check_stmt().
|
static |
Wrapper around check_decl for loads in local more.
References check_decl(), and check_op().
Referenced by check_stmt().
|
inlinestatic |
Check to see if the use (or definition when CHECKING_WRITE is true) variable T is legal in a function that is either pure or const.
References dump_file, get_base_address(), IPA_CONST, IPA_NEITHER, IPA_PURE, ptr_deref_may_alias_global_p(), and funct_state_d::pure_const_state.
Referenced by check_ipa_load(), check_ipa_store(), check_load(), and check_store().
|
static |
Look into pointer pointed to by GSIP and figure out what interesting side effects it has.
References funct_state_d::can_throw, function::can_throw_non_call_exceptions, cfun, check_call(), check_ipa_load(), check_ipa_store(), check_load(), check_store(), dump_file, gimple_asm_clobbers_memory_p(), gimple_asm_volatile_p(), gimple_clobber_p(), gimple_has_volatile_ops(), gimple_label_label(), gsi_stmt(), IPA_NEITHER, is_gimple_debug(), funct_state_d::looping, print_gimple_stmt(), funct_state_d::pure_const_state, stmt_can_throw_external(), stmt_could_throw_p(), and walk_stmt_load_store_ops().
Referenced by analyze_function().
|
static |
Wrapper around check_decl for stores in local more.
References check_decl(), and check_op().
Referenced by check_stmt().
|
static |
Called when new clone is inserted to callgraph late.
References get_function_state(), has_function_state(), memcpy(), and set_function_state().
Referenced by register_hooks().
|
static |
Init the function state.
Referenced by propagate().
|
static |
Try to guess if function body will always be visible to compiler when compiling the call and whether compiler will be able to propagate the information by itself.
Referenced by suggest_attribute().
|
static |
References seen_error().
|
inlinestatic |
Return the function state from NODE.
References cgraph_node::uid, and varying_state.
Referenced by duplicate_node_data(), propagate(), propagate_nothrow(), propagate_pure_const(), pure_const_write_summary(), and remove_node_data().
|
inlinestatic |
Return true if we have a function state for NODE.
References cgraph_node::uid.
Referenced by duplicate_node_data(), propagate(), pure_const_write_summary(), and remove_node_data().
|
static |
References cgraph_edge::can_throw_external.
Referenced by ipa_reduced_postorder(), propagate_nothrow(), and searchc().
|
static |
Simple local pass for pure const discovery reusing the analysis from ipa_pure_const. This pass is effective when executed together with other optimization passes in early optimization pass queue.
References analyze_function(), funct_state_d::can_throw, cfun, cgraph_get_node(), cgraph_set_const_flag(), cgraph_set_nothrow_flag(), cgraph_set_pure_flag(), changed, current_function_decl, current_function_name(), function::decl, dump_file, execute_fixup_cfg(), free(), IPA_CONST, IPA_PURE, funct_state_d::looping, NODE_FREQUENCY_EXECUTED_ONCE, funct_state_d::pure_const_state, skip_function_for_local_pure_const(), warn_function_const(), warn_function_noreturn(), and warn_function_pure().
ipa_opt_pass_d* make_pass_ipa_pure_const | ( | ) |
gimple_opt_pass* make_pass_local_pure_const | ( | ) |
|
static |
Produce the global information by preforming a transitive closure on the local information that was produced by generate_summary.
References cgraph_remove_function_insertion_hook(), cgraph_remove_node_duplication_hook(), cgraph_remove_node_removal_hook(), finish_state(), free(), get_function_state(), has_function_state(), propagate_nothrow(), and propagate_pure_const().
Referenced by propagate_pseudo_copies().
|
static |
Produce transitive closure over the callgraph and compute nothrow attributes.
References symtab_node_base::alias, symtab_node_base::aux, AVAIL_OVERWRITABLE, cgraph_edge::callee, cgraph_node::callees, funct_state_d::can_throw, cgraph_edge::can_throw_external, cgraph_function_body_availability(), cgraph_function_node(), cgraph_n_nodes, cgraph_node_name(), cgraph_set_nothrow_flag(), symtab_node_base::decl, dump_cgraph(), dump_file, free(), get_function_state(), ignore_edge(), cgraph_node::indirect_calls, ipa_free_postorder_info(), ipa_print_order(), ipa_reduced_postorder(), cgraph_edge::next_callee, ipa_dfs_info::next_cycle, order, and cgraph_node::symbol.
Referenced by propagate().
|
static |
Produce transitive closure over the callgraph and compute pure/const attributes.
References symtab_node_base::alias, symtab_node_base::aux, AVAIL_OVERWRITABLE, better_state(), cgraph_edge::callee, cgraph_node::callees, cgraph_edge_cannot_lead_to_return(), cgraph_function_body_availability(), cgraph_function_node(), cgraph_n_nodes, cgraph_node_name(), cgraph_set_const_flag(), cgraph_set_pure_flag(), count, symtab_node_base::decl, dump_cgraph(), dump_file, dump_flags, cgraph_indirect_call_info::ecf_flags, flags_from_decl_or_type(), free(), get_function_state(), cgraph_node::indirect_calls, cgraph_edge::indirect_info, IPA_CONST, ipa_free_postorder_info(), IPA_NEITHER, ipa_print_order(), IPA_PURE, ipa_reduced_postorder(), IPA_REF_ADDR, ipa_ref_cannot_lead_to_return(), IPA_REF_LOAD, IPA_REF_STORE, ipa_ref_varpool_node(), funct_state_d::looping, funct_state_d::looping_previously_known, cgraph_edge::next_callee, ipa_dfs_info::next_cycle, symtab_node_base::order, order, pure_const_names, funct_state_d::pure_const_state, symtab_node_base::ref_list, self_recursive_p(), special_builtin_state(), state_from_flags(), funct_state_d::state_previously_known, cgraph_node::symbol, warn_function_const(), warn_function_pure(), and worse_state().
Referenced by propagate().
|
static |
Analyze each function in the cgraph to see if it is locally PURE or CONST.
References analyze_function(), AVAIL_OVERWRITABLE, cgraph_function_body_availability(), pointer_set_create(), pointer_set_destroy(), register_hooks(), and set_function_state().
|
static |
Deserialize the ipa info for lto.
References bp_unpack_value(), cgraph(), cgraph_node_name(), count, symtab_node_base::decl, dump_file, flags_from_decl_or_type(), len, lto_create_simple_input_block(), lto_destroy_simple_input_block(), lto_get_file_decl_data(), LTO_section_ipa_pure_const, lto_symtab_encoder_deref(), symtab_node_base::order, pure_const_names, register_hooks(), set_function_state(), streamer_read_bitpack(), streamer_read_uhwi(), cgraph_node::symbol, and lto_file_decl_data::symtab_node_encoder.
|
static |
Serialize the ipa info for lto.
References bitpack_create(), bp_pack_value(), count, lto_simple_output_block::decl_state, symtab_node_base::definition, get_function_state(), has_function_state(), lsei_cgraph_node(), lsei_end_p(), lsei_next_function_in_partition(), lsei_start_function_in_partition(), lto_create_simple_output_block(), lto_destroy_simple_output_block(), lto_get_out_decl_state(), LTO_section_ipa_pure_const, lto_symtab_encoder_encode(), lto_simple_output_block::main_stream, streamer_write_bitpack(), streamer_write_uhwi_stream(), cgraph_node::symbol, and lto_out_decl_state::symtab_node_encoder.
|
static |
|
static |
Called when new clone is inserted to callgraph late.
References free(), get_function_state(), has_function_state(), set_function_state(), and varying_state.
Referenced by ipa_init(), ipa_reference_read_optimization_summary(), and register_hooks().
|
static |
Return true if NODE is self recursive function. ??? self recursive and indirectly recursive funcions should be the same, so this function seems unnecessary.
References cgraph_edge::callee, cgraph_node::callees, cgraph_function_node(), and cgraph_edge::next_callee.
Referenced by propagate_pure_const().
|
inlinestatic |
Set the function state S for NODE.
References cgraph_node::uid.
Referenced by add_new_function(), duplicate_node_data(), pure_const_generate_summary(), pure_const_read_summary(), and remove_node_data().
|
static |
Return true if function should be skipped for local pure const analysis.
References AVAIL_OVERWRITABLE, cgraph_function_body_availability(), dump_file, and function_called_by_processed_nodes_p().
Referenced by local_pure_const().
|
static |
Recognize special cases of builtins that are by themselves not pure or const but function using them is.
References BUILT_IN_NORMAL, and IPA_CONST.
Referenced by check_call(), and propagate_pure_const().
|
static |
compute state based on ECF FLAGS and store to STATE and LOOPING.
References dump_file, dump_flags, IPA_CONST, IPA_NEITHER, and IPA_PURE.
Referenced by analyze_function(), check_call(), and propagate_pure_const().
|
staticread |
Emit suggestion about attribute ATTRIB_NAME for DECL. KNOWN_FINITE is true if the function is known to be finite. The diagnostic is controlled by OPTION. WARNED_ABOUT is a pointer_set unique for OPTION, this function may initialize it and it is always returned by the function.
References function_always_visible_to_compiler_p(), option_enabled(), pointer_set_contains(), pointer_set_create(), pointer_set_insert(), and warning_at().
Referenced by warn_function_const(), warn_function_noreturn(), and warn_function_pure().
|
static |
Emit suggestion about __attribute_((const)) for DECL. KNOWN_FINITE is true if the function is known to be finite.
References suggest_attribute().
Referenced by local_pure_const(), and propagate_pure_const().
void warn_function_noreturn | ( | ) |
References lang_hooks::missing_noreturn_ok_p, suggest_attribute(), and targetm.
Referenced by execute_warn_function_noreturn(), and local_pure_const().
|
static |
Emit suggestion about __attribute_((pure)) for DECL. KNOWN_FINITE is true if the function is known to be finite.
References suggest_attribute().
Referenced by local_pure_const(), and propagate_pure_const().
|
inlinestatic |
Merge STATE and STATE2 and LOOPING and LOOPING2 and store into STATE and LOOPING worse of the two variants.
Referenced by check_call(), and propagate_pure_const().
|
static |
The storage of the funct_state is abstracted because there is the possibility that it may be desirable to move this to the cgraph local info.
Array, indexed by cgraph node uid, of function states.
|
static |
Holders of ipa cgraph hooks:
|
static |
|
static |
const char* pure_const_names[3] = {"const", "pure", "neither"} |
Referenced by propagate_pure_const(), and pure_const_read_summary().
|
static |
State used when we know nothing about function.
Referenced by get_function_state(), and remove_node_data().
|
static |
@verbatim Callgraph based analysis of static variables.
Copyright (C) 2004-2013 Free Software Foundation, Inc. Contributed by Kenneth Zadeck zadec k@na tural brid ge.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/.
This file marks functions as being either const (TREE_READONLY) or pure (DECL_PURE_P). It can also set a variant of these that are allowed to loop indefinitely (DECL_LOOPING_CONST_PURE_P). This must be run after inlining decisions have been made since otherwise, the local sets will not contain information that is consistent with post inlined state. The global sets are not prone to this problem since they are by definition transitive.
The code in this module is called by the ipa pass manager. It should be one of the later passes since it's information is used by the rest of the compilation.
Referenced by build_cgraph_edges(), inline_forbidden_p(), and record_references_in_initializer().