GCC Middle and Back End API Reference
passes.c File Reference

Data Structures

struct  pass_registry
struct  pass_registry_hasher
struct  uid_range
struct  pass_list_node

Typedefs

typedef const char * char_ptr
typedef struct uid_rangeuid_range_p

Functions

static void register_pass_name (struct opt_pass *, const char *)
void print_current_pass ()
DEBUG_FUNCTION void debug_pass ()
void rest_of_decl_compilation (tree decl, int top_level, int at_end)
void rest_of_type_compilation ()
static unsigned int execute_all_early_local_passes ()
static bool gate_all_early_local_passes ()
simple_ipa_opt_passmake_pass_early_local_passes ()
static bool gate_all_early_optimizations ()
static gimple_opt_passmake_pass_all_early_optimizations ()
static bool gate_all_optimizations ()
static gimple_opt_passmake_pass_all_optimizations ()
static bool gate_all_optimizations_g ()
static gimple_opt_passmake_pass_all_optimizations_g ()
static bool gate_rest_of_compilation ()
static rtl_opt_passmake_pass_rest_of_compilation ()
static bool gate_postreload ()
static rtl_opt_passmake_pass_postreload ()
void register_one_dump_file ()
static void register_pass_name ()
int passes_pass_traverse ()
static void create_pass_tab ()
static bool override_gate_status (struct opt_pass *, tree, bool)
static void dump_one_pass ()
static void dump_pass_list ()
void dump_passes ()
static struct opt_passget_pass_by_name ()
static void enable_disable_pass ()
void enable_pass ()
void disable_pass ()
static bool is_pass_explicitly_enabled_or_disabled (struct opt_pass *pass, tree func, vec< uid_range_p > tab)
static void add_pass_instance (struct opt_pass *new_pass, bool track_duplicates, opt_pass *initial_pass)
static struct opt_pass ** next_pass_1 (struct opt_pass **list, struct opt_pass *pass, struct opt_pass *initial_pass)
static bool position_pass (struct register_pass_info *new_pass_info, struct opt_pass **pass_list)
void register_pass ()
static void do_per_function (void(*callback)(void *data), void *data)
void do_per_function_toporder (void(*callback)(void *data), void *data)
static void execute_function_dump ()
static void check_profile_consistency ()
void dump_profile_report ()
static void execute_function_todo ()
static void execute_todo ()
static void verify_interpass_invariants ()
static void clear_last_verified ()
static void verify_curr_properties ()
bool pass_init_dump_file ()
void pass_fini_dump_file ()
static void update_properties_after_pass ()
void execute_ipa_summary_passes ()
static void execute_one_ipa_transform_pass (struct cgraph_node *node, struct ipa_opt_pass_d *ipa_pass)
void execute_all_ipa_transforms ()
static void apply_ipa_transforms ()
static bool override_gate_status ()
bool execute_one_pass ()
void execute_pass_list ()
static void ipa_write_summaries_2 ()
static void ipa_write_summaries_1 ()
void ipa_write_summaries ()
static void ipa_write_optimization_summaries_1 ()
void ipa_write_optimization_summaries ()
static void ipa_read_summaries_1 ()
void ipa_read_summaries ()
static void ipa_read_optimization_summaries_1 ()
void ipa_read_optimization_summaries ()
void execute_ipa_pass_list ()
static void execute_ipa_stmt_fixups (struct opt_pass *pass, struct cgraph_node *node, gimple *stmts)
void execute_all_ipa_stmt_fixups ()
void debug_properties (unsigned int)
void dump_properties (FILE *, unsigned int)
DEBUG_FUNCTION void dump_properties ()
DEBUG_FUNCTION void debug_properties ()
bool function_called_by_processed_nodes_p ()

Variables

struct opt_passcurrent_pass
bool in_gimple_form
bool first_pass_instance
static hash_table
< pass_registry_hasher
name_to_pass_map
static vec< char_ptrpass_tab = vNULL
static vec< uid_range_penabled_pass_uid_range_tab = vNULL
static vec< uid_range_pdisabled_pass_uid_range_tab = vNULL
static struct pass_list_nodeadded_pass_nodes = NULL
static struct pass_list_nodeprev_added_pass_node
static int nnodes
static cgraph_node_ptrorder
static struct profile_recordprofile_record

Typedef Documentation

typedef const char* char_ptr
Map from pass id to canonicalized pass name.   
typedef struct uid_range* uid_range_p

Function Documentation

static void add_pass_instance ( struct opt_pass new_pass,
bool  track_duplicates,
opt_pass initial_pass 
)
static
Update static_pass_number for passes (and the flag
   TODO_mark_first_instance).

   Passes are constructed with static_pass_number preinitialized to 0

   This field is used in two different ways: initially as instance numbers
   of their kind, and then as ids within the entire pass manager.

   Within pass_manager::pass_manager:

   * In add_pass_instance(), as called by next_pass_1 in
     NEXT_PASS in init_optimization_passes

   * When the initial instance of a pass within a pass manager is seen,
     it is flagged, and its static_pass_number is set to -1

   * On subsequent times that it is seen, the static pass number
     is decremented each time, so that if there are e.g. 4 dups,
     they have static_pass_number -4, 2, 3, 4 respectively (note
     how the initial one is negative and gives the count); these
     can be thought of as instance numbers of the specific pass

   * Within the register_dump_files () traversal, set_pass_for_id()
     is called on each pass, using these instance numbers to create
     dumpfile switches, and then overwriting them with a pass id,
     which are global to the whole pass manager (based on
     (TDI_end + current value of extra_dump_files_in_use) )   

References invoke_plugin_callbacks(), pass_data::name, opt_pass::static_pass_number, and pass_data::todo_flags_start.

Referenced by next_pass_1(), and position_pass().

static void apply_ipa_transforms ( )
static
static void check_profile_consistency ( )
static
Do profile consistency book-keeping for the pass with static number INDEX.
   If SUBPASS is zero, we run _before_ the pass, and if SUBPASS is one, then
   we run _after_ the pass.  RUN is true if the pass really runs, or FALSE
   if we are only book-keeping on passes that may have selectively disabled
   themselves on a given function.   

References account_profile_record(), g, gcc::context::get_passes(), gcc::pass_manager::passes_by_id_size, and profile_record::run.

Referenced by execute_one_ipa_transform_pass(), and execute_one_pass().

static void clear_last_verified ( )
static
Clear the last verified flag.   

References cfun, and function::last_verified.

Referenced by execute_one_pass().

static void create_pass_tab ( )
static
The function traverses NAME_TO_PASS_MAP and creates a pass info
   table for dumping purpose.   

References g, gcc::context::get_passes(), name_to_pass_map, pass_tab, gcc::pass_manager::passes_by_id_size, and passes_pass_traverse().

Referenced by gcc::pass_manager::dump_passes().

DEBUG_FUNCTION void debug_pass ( void  )
Call from the debugger to get the current pass name.   

References print_current_pass().

void debug_properties ( unsigned  int)
DEBUG_FUNCTION void debug_properties ( )

References dump_properties().

void disable_pass ( )
Disable pass specified by ARG.   

References enable_disable_pass().

Referenced by handle_common_deferred_options().

static void do_per_function ( void(*)(void *data callback,
void *  data 
)
static
If we are in IPA mode (i.e., current_function_decl is NULL), call
   function CALLBACK for every function in the call graph.  Otherwise,
   call CALLBACK on the current function.   

References symtab_node_base::analyzed, CDI_DOMINATORS, CDI_POST_DOMINATORS, cgraph_node::clone_of, current_function_decl, symtab_node_base::decl, free_dominance_info(), ggc_collect(), gimple_has_body_p(), pop_cfun(), push_cfun(), and cgraph_node::symbol.

Referenced by execute_one_ipa_transform_pass(), execute_one_pass(), and execute_todo().

void do_per_function_toporder ( void(*)(void *data callback,
void *  data 
)
If we are in IPA mode (i.e., current_function_decl is NULL), call
   function CALLBACK for every function in the call graph.  Otherwise,
   call CALLBACK on the current function.
   This function is global so that plugins can use it.   

References CDI_DOMINATORS, CDI_POST_DOMINATORS, cgraph_function_with_gimple_body_p(), cgraph_get_body(), cgraph_n_nodes, current_function_decl, symtab_node_base::decl, free_dominance_info(), ggc_collect(), ggc_free(), ipa_reverse_postorder(), nnodes, pop_cfun(), cgraph_node::process, push_cfun(), and cgraph_node::symbol.

Referenced by execute_ipa_pass_list().

static void dump_one_pass ( )
static
Dump the instantiated name for PASS. IS_ON indicates if PASS
   is turned on or not.   

References current_function_decl, opt_pass::gate(), pass_data::has_gate, indent, pass_data::name, override_gate_status(), pass_tab, and opt_pass::static_pass_number.

Referenced by dump_pass_list().

static void dump_pass_list ( )
static
Dump pass list PASS with indentation INDENT.   

References dump_one_pass(), opt_pass::next, and opt_pass::sub.

Referenced by gcc::pass_manager::dump_passes().

void dump_passes ( void  )
Dump all optimization passes.   

References gcc::pass_manager::dump_passes(), g, and gcc::context::get_passes().

Referenced by finalize_compilation_unit().

void dump_profile_report ( void  )
Output profile consistency.   

References gcc::pass_manager::dump_profile_report(), g, and gcc::context::get_passes().

Referenced by finalize().

void dump_properties ( FILE *  ,
unsigned  int 
)

Referenced by debug_properties().

DEBUG_FUNCTION void dump_properties ( )
static void enable_disable_pass ( )
static
Parse option string for -fdisable- and -fenable-
   The syntax of the options:

   -fenable-<pass_name>
   -fdisable-<pass_name>

   -fenable-<pass_name>=s1:e1,s2:e2,...
   -fdisable-<pass_name>=s1:e1,s2:e2,...

References uid_range::assem_name, disabled_pass_uid_range_tab, enabled_pass_uid_range_tab, error(), free(), get_pass_by_name(), inform(), last, uid_range::last, uid_range::next, uid_range::start, and opt_pass::static_pass_number.

Referenced by disable_pass(), and enable_pass().

void enable_pass ( )
Enable pass specified by ARG.   

References enable_disable_pass().

Referenced by handle_common_deferred_options().

static unsigned int execute_all_early_local_passes ( )
static

References CGRAPH_STATE_IPA_SSA.

void execute_all_ipa_stmt_fixups ( )
Execute stmt fixup hooks of all IPA passes for NODE and STMTS.   

References gcc::pass_manager::all_regular_ipa_passes, execute_ipa_stmt_fixups(), g, and gcc::context::get_passes().

Referenced by input_function().

void execute_all_ipa_transforms ( void  )
For the current function, execute all ipa transforms.  

References cfun, cgraph_get_node(), current_function_decl, execute_one_ipa_transform_pass(), and cgraph_node::ipa_transforms_to_apply.

Referenced by apply_ipa_transforms(), and expand_function().

static void execute_function_dump ( )
static
void execute_ipa_pass_list ( )
static void execute_ipa_stmt_fixups ( struct opt_pass pass,
struct cgraph_node node,
gimple stmts 
)
static
void execute_ipa_summary_passes ( )
bool function_called_by_processed_nodes_p ( void  )
Called by local passes to see if function is called by already processed nodes.
   Because we process nodes in topological order, this means that function is
   in recursive cycle or we introduced new direct calls.   

References cgraph_edge::caller, cgraph_function_with_gimple_body_p(), cgraph_get_node(), current_function_decl, symtab_node_base::decl, dump_cgraph_node(), dump_file, cgraph_node::global, cgraph_global_info::inlined_to, cgraph_edge::next_caller, cgraph_node::process, and cgraph_node::symbol.

Referenced by skip_function_for_local_pure_const().

static bool gate_all_early_local_passes ( )
static
Gate: execute, or not, all of the non-trivial optimizations.   

References seen_error().

static bool gate_all_early_optimizations ( )
static
Gate: execute, or not, all of the non-trivial optimizations.   

References seen_error().

static bool gate_all_optimizations ( )
static
Gate: execute, or not, all of the non-trivial optimizations.   
static bool gate_all_optimizations_g ( )
static
Gate: execute, or not, all of the non-trivial optimizations.   
static bool gate_postreload ( )
static

References reload_completed.

static bool gate_rest_of_compilation ( )
static

References seen_error().

static struct opt_pass* get_pass_by_name ( )
staticread
Returns the pass with NAME.   

References name_to_pass_map, and pass_registry::unique_name.

Referenced by enable_disable_pass().

void ipa_read_optimization_summaries ( void  )
Read all the summaries for all_regular_ipa_passes and all_lto_gen_passes.   

References gcc::pass_manager::all_lto_gen_passes, gcc::pass_manager::all_regular_ipa_passes, g, gcc::context::get_passes(), and ipa_read_optimization_summaries_1().

static void ipa_read_optimization_summaries_1 ( )
static
void ipa_read_summaries ( void  )
Read all the summaries for all_regular_ipa_passes and all_lto_gen_passes.   

References gcc::pass_manager::all_lto_gen_passes, gcc::pass_manager::all_regular_ipa_passes, g, gcc::context::get_passes(), and ipa_read_summaries_1().

static void ipa_read_summaries_1 ( )
static
static void ipa_write_optimization_summaries_1 ( )
static
Same as execute_pass_list but assume that subpasses of IPA passes
   are local passes. If SET is not NULL, write out optimization summaries of
   only those node in SET.  

References cfun, current_function_decl, opt_pass::gate(), GIMPLE_PASS, pass_data::has_gate, IPA_PASS, opt_pass::next, pass_fini_dump_file(), pass_init_dump_file(), SIMPLE_IPA_PASS, opt_pass::sub, timevar_pop(), timevar_push(), pass_data::tv_id, pass_data::type, and ipa_opt_pass_d::write_optimization_summary.

Referenced by ipa_write_optimization_summaries().

static void ipa_write_summaries_1 ( )
static
Helper function of ipa_write_summaries. Creates and destroys the
   decl state and calls ipa_write_summaries_2 for all passes that have
   summaries.  SET is the set of nodes to be written.   

References gcc::pass_manager::all_lto_gen_passes, gcc::pass_manager::all_regular_ipa_passes, g, gcc::context::get_passes(), ipa_write_summaries_2(), lto_delete_out_decl_state(), lto_get_out_decl_state(), lto_new_out_decl_state(), lto_pop_out_decl_state(), lto_push_out_decl_state(), and lto_out_decl_state::symtab_node_encoder.

Referenced by ipa_write_summaries().

static void ipa_write_summaries_2 ( )
static
Same as execute_pass_list but assume that subpasses of IPA passes
   are local passes. If SET is not NULL, write out summaries of only
   those node in SET.  

References cfun, current_function_decl, opt_pass::gate(), GIMPLE_PASS, pass_data::has_gate, IPA_PASS, opt_pass::next, pass_fini_dump_file(), pass_init_dump_file(), SIMPLE_IPA_PASS, opt_pass::sub, timevar_pop(), timevar_push(), pass_data::tv_id, pass_data::type, and ipa_opt_pass_d::write_summary.

Referenced by ipa_write_summaries_1().

static bool is_pass_explicitly_enabled_or_disabled ( struct opt_pass pass,
tree  func,
vec< uid_range_p tab 
)
static
Returns true if PASS is explicitly enabled/disabled for FUNC.   

References uid_range::assem_name, cgraph_get_node(), last, uid_range::next, uid_range::start, opt_pass::static_pass_number, and cgraph_node::uid.

Referenced by override_gate_status().

static gimple_opt_pass* make_pass_all_early_optimizations ( )
static
static gimple_opt_pass* make_pass_all_optimizations ( )
static
static gimple_opt_pass* make_pass_all_optimizations_g ( )
static
simple_ipa_opt_pass* make_pass_early_local_passes ( )
static rtl_opt_pass* make_pass_postreload ( )
static
static rtl_opt_pass* make_pass_rest_of_compilation ( )
static
static struct opt_pass** next_pass_1 ( struct opt_pass **  list,
struct opt_pass pass,
struct opt_pass initial_pass 
)
staticread
Add a pass to the pass list. Duplicate the pass if it's already
   in the list.   

References add_pass_instance(), pass_data::name, and opt_pass::next.

static bool override_gate_status ( struct opt_pass ,
tree  ,
bool   
)
static

Referenced by dump_one_pass(), and execute_one_pass().

static bool override_gate_status ( )
static
Check if PASS is explicitly disabled or enabled and return
   the gate status.  FUNC is the function to be processed, and
   GATE_STATUS is the gate status determined by pass manager by
   default.   

References disabled_pass_uid_range_tab, enabled_pass_uid_range_tab, and is_pass_explicitly_enabled_or_disabled().

int passes_pass_traverse ( )
Callback function for traversing NAME_TO_PASS_MAP.   

References pass_tab, and opt_pass::static_pass_number.

Referenced by create_pass_tab().

static bool position_pass ( struct register_pass_info new_pass_info,
struct opt_pass **  pass_list 
)
static
void print_current_pass ( )
Call from anywhere to find out what pass this is.  Useful for
   printing out debugging information deep inside an service
   routine.   

References current_pass, pass_data::name, and opt_pass::static_pass_number.

Referenced by debug_pass().

void register_one_dump_file ( )
Iterate over the pass tree allocating dump file numbers.  We want
   to do this depth first, and independent of whether the pass is
   enabled or not.   

References g, gcc::context::get_passes(), and gcc::pass_manager::register_one_dump_file().

void register_pass ( )
Hooks a new pass into the pass lists.

   PASS_INFO   - pass information that specifies the opt_pass object,
                 reference pass, instance number, and how to position
                 the pass   

References g, gcc::context::get_passes(), and gcc::pass_manager::register_pass().

Referenced by register_callback().

static void register_pass_name ( struct opt_pass ,
const char *   
)
static
static void register_pass_name ( )
static
Register PASS with NAME.   

References name_to_pass_map, pass_registry::pass, and pass_registry::unique_name.

void rest_of_decl_compilation ( tree  decl,
int  top_level,
int  at_end 
)
This is called from various places for FUNCTION_DECL, VAR_DECL,
   and TYPE_DECL nodes.

   This does nothing for local (non-static) variables, unless the
   variable is a register variable with DECL_ASSEMBLER_NAME set.  In
   that case, or if the variable is not an automatic, it sets up the
   RTL and outputs any assembler code (label definition, storage
   allocation and initialization).

   DECL is the declaration.  TOP_LEVEL is nonzero
   if this declaration is not within a function.   

References asm_out_file, assemble_alias(), debug_hooks, get_identifier(), last_assemble_variable_decl, lookup_attribute(), make_decl_rtl(), seen_error(), timevar_pop(), timevar_push(), gcc_debug_hooks::type_decl, varpool_finalize_decl(), and varpool_node_for_decl().

Referenced by expand_one_hard_reg_var(), and wrapup_global_declaration_2().

void rest_of_type_compilation ( )
Called after finishing a record, union or enumeral type.   

References debug_hooks, seen_error(), timevar_pop(), timevar_push(), and gcc_debug_hooks::type_decl.

static void update_properties_after_pass ( )
static
After executing the pass, apply expected changes to the function
   properties.  

References cfun, function::curr_properties, pass_data::properties_destroyed, and pass_data::properties_provided.

Referenced by execute_one_pass().

static void verify_curr_properties ( )
static
Helper function. Verify that the properties has been turn into the
   properties expected by the pass.   

References cfun, and function::curr_properties.

Referenced by execute_one_pass().

static void verify_interpass_invariants ( )
static
Verify invariants that should hold between passes.  This is a place
   to put simple sanity checks.   

References fold_deferring_overflow_warnings_p().

Referenced by execute_one_ipa_transform_pass(), and execute_one_pass().


Variable Documentation

struct pass_list_node* added_pass_nodes = NULL
static
struct opt_pass* current_pass
This is used for debugging.  It allows the current pass to printed
   from anywhere in compilation.
   The variable current_pass is also used for statistics and plugins.   

Referenced by connect_traces(), curr_statistics_hash(), execute_one_ipa_transform_pass(), execute_one_pass(), print_current_pass(), statistics_counter_event(), statistics_fini_pass(), statistics_fini_pass_2(), and statistics_histogram_event().

vec<uid_range_p> disabled_pass_uid_range_tab = vNULL
static
vec<uid_range_p> enabled_pass_uid_range_tab = vNULL
static
bool first_pass_instance
Set to true if the pass is called the first time during compilation of the
   current function.  Note that using this information in the optimization
   passes is considered not to be clean, and it should be avoided if possible.
   This flag is currently used to prevent loops from being peeled repeatedly
   in jump threading; it will be removed once we preserve loop structures
   throughout the compilation -- we will be able to mark the affected loops
   directly in jump threading, and avoid peeling them next time.   

Referenced by acceptable_pow_call(), execute_todo(), reassociate_bb(), and tree_ssa_dominator_optimize().

bool in_gimple_form
int nnodes
static
Because inlining might remove no-longer reachable nodes, we need to
   keep the array visible to garbage collector to avoid reading collected
   out nodes.   

Referenced by do_per_function_toporder(), and ipa_inline().

vec<char_ptr> pass_tab = vNULL
static
struct pass_list_node* prev_added_pass_node
static

Referenced by position_pass().