GCC Middle and Back End API Reference
|
Go to the source code of this file.
Data Structures | |
struct | histogram_value_t |
Typedefs | |
typedef struct histogram_value_t * | histogram_value |
typedef struct histogram_value_t * | const_histogram_value |
typedef vec< histogram_value > | histogram_values |
Enumerations | |
enum | hist_type { HIST_TYPE_INTERVAL, HIST_TYPE_POW2, HIST_TYPE_SINGLE_VALUE, HIST_TYPE_CONST_DELTA, HIST_TYPE_INDIR_CALL, HIST_TYPE_AVERAGE, HIST_TYPE_IOR, HIST_TYPE_MAX } |
typedef struct histogram_value_t* const_histogram_value |
typedef struct histogram_value_t* histogram_value |
typedef vec<histogram_value> histogram_values |
enum hist_type |
void branch_prob | ( | void | ) |
Instrument and/or analyze program behavior based on program the CFG. This function creates a representation of the control flow graph (of the function being compiled) that is suitable for the instrumentation of edges and/or converting measured edge counts to counts on the complete CFG. When FLAG_PROFILE_ARCS is nonzero, this function instruments the edges in the flow graph that are needed to reconstruct the dynamic behavior of the flow graph. This data is written to the gcno file for gcov. When FLAG_BRANCH_PROBABILITIES is nonzero, this function reads auxiliary information from the gcda file containing edge count information from previous executions of the function being compiled. In this case, the control flow graph is annotated with actual execution counts by compute_branch_probabilities(). Main entry point of this file.
We can't handle cyclic regions constructed using abnormal edges. To avoid these we replace every source of abnormal edge by a fake edge from entry node and every destination by fake edge to exit. This keeps graph acyclic and our calculation exact for all normal edges except for exit and entrance ones. We also add fake exit edges for each call and asm statement in the basic, since it may not return.
Functions returning multiple times are not handled by extra edges. Instead we simply allow negative counts on edges from exit to the block past call and corresponding probabilities. We can't go with the extra edges because that would result in flowgraph that needs to have fake edges outside the spanning tree.
It may happen that there are compiler generated statements without a locus at all. Go through the basic block from the last to the first statement looking for a locus.
Edge with goto locus might get wrong coverage info unless it is the only edge out of BB. Don't do that when the locuses match, so if (blah) goto something; is not computed twice.
Avoid bbs that have both fake entry edge and also some exit edge. One of those edges wouldn't be added to the spanning tree, but we can't instrument any of them.
Don't split the bbs containing __builtin_setjmp_receiver or __builtin_setjmp_dispatcher calls. These are very special and don't expect anything to be inserted before them.
The basic blocks are expected to be numbered sequentially.
Mark edges we've replaced by fake edges above as ignored.
Create spanning tree from basic block graph, mark each edge that is on the spanning tree. We insert as many abnormal and critical edges as possible to minimize number of edge splits necessary.
Fake edges that are not on the tree will not be instrumented, so mark them ignored.
Compute two different checksums. Note that we want to compute the checksum in only once place, since it depends on the shape of the control flow which can change during various transformations.
Write the data from which gcov can reconstruct the basic block graph and function line numbers (the gcno file).
Basic block flags
Arcs
On trees we don't have fallthru flags, but we can recompute them from CFG shape.
Line numbers.
Initialize the output.
Notice GOTO expressions eliminated while constructing the CFG.
A file of NULL indicates the end of run.
For each edge not on the spanning tree, add counting code.
Commit changes done by instrumentation.
References gimple_has_location(), and gsi_stmt().
void end_branch_prob | ( | void | ) |
Performs file-level cleanup after branch-prob processing is completed.
Referenced by rest_of_type_compilation().
|
read |
void free_histograms | ( | void | ) |
References current_function_decl, dump_enabled_p(), dump_printf_loc(), and gimple_location().
void gimple_add_histogram_value | ( | struct function * | fun, |
gimple | stmt, | ||
histogram_value | hist | ||
) |
Add histogram for STMT.
References gimple_histogram_value(), histogram_value_t::hvalue, histogram_value_t::next, and set_histogram_value().
Referenced by gimple_remove_stmt_histograms().
void gimple_duplicate_stmt_histograms | ( | struct function * | fun, |
gimple | stmt, | ||
struct function * | ofun, | ||
gimple | ostmt | ||
) |
Duplicate all histograms associates with OSTMT to STMT.
References gimple_histogram_value(), histogram_value_t::hvalue, histogram_value_t::next, set_histogram_value(), and histogram_value_t::stmt.
Referenced by gimple_redirect_edge_and_branch(), and gsi_split_seq_before().
void gimple_find_values_to_profile | ( | histogram_values * | ) |
void gimple_gen_average_profiler | ( | histogram_value | , |
unsigned | , | ||
unsigned | |||
) |
void gimple_gen_const_delta_profiler | ( | histogram_value | value, |
unsigned | tag, | ||
unsigned | base | ||
) |
Output instructions as GIMPLE trees for code to find the most common value of a difference between two evaluations of an expression. VALUE is the expression whose value is profiled. TAG is the tag of the section for counters, BASE is offset of the counter position.
FIXME implement this.
Referenced by instrument_values().
void gimple_gen_edge_profiler | ( | int | , |
edge | |||
) |
void gimple_gen_ic_func_profiler | ( | void | ) |
Output instructions as GIMPLE trees for code to find the most common called function in indirect call. Insert instructions at the beginning of every possible called function.
Insert code: stmt1: __gcov_indirect_call_profiler_v2 (profile_id, ¤t_function_decl)
Workaround for binutils bug 14342. Once it is fixed, remove lto path.
Set __gcov_indirect_call_callee to 0, so that calls from other modules won't get misattributed to the last caller of the current callee.
void gimple_gen_ic_profiler | ( | histogram_value | , |
unsigned | , | ||
unsigned | |||
) |
void gimple_gen_interval_profiler | ( | histogram_value | , |
unsigned | , | ||
unsigned | |||
) |
void gimple_gen_ior_profiler | ( | histogram_value | , |
unsigned | , | ||
unsigned | |||
) |
void gimple_gen_one_value_profiler | ( | histogram_value | , |
unsigned | , | ||
unsigned | |||
) |
void gimple_gen_pow2_profiler | ( | histogram_value | , |
unsigned | , | ||
unsigned | |||
) |
histogram_value gimple_histogram_value | ( | struct function * | , |
gimple | |||
) |
histogram_value gimple_histogram_value_of_type | ( | struct function * | fun, |
gimple | stmt, | ||
enum hist_type | type | ||
) |
Lookup histogram of type TYPE in the STMT.
References histogram_value_t::counters, histogram_value_t::hdata, HIST_TYPE_INTERVAL, histogram_value_t::hvalue, histogram_value_t::intvl, and histogram_value_t::type.
gimple gimple_ic | ( | gimple | icall_stmt, |
struct cgraph_node * | direct_call, | ||
int | prob, | ||
gcov_type | count, | ||
gcov_type | all | ||
) |
Do transformation if (actual_callee_address == address_of_most_common_function/method) do direct call else old call
Fix CFG.
Edge e_cd connects cond_bb to dcall_bb, etc; note the first letters.
Do not disturb existing EH edges from the indirect call.
The indirect call might be noreturn.
Insert PHI node for the call result if necessary.
Build an EH edge for the direct call if necessary.
void gimple_init_edge_profiler | ( | void | ) |
In tree-profile.c.
Create the type and function decls for the interface with gcov.
void (*) (gcov_type *, gcov_type, int, unsigned)
void (*) (gcov_type *, gcov_type)
void (*) (gcov_type *, gcov_type)
Workaround for binutils bug 14342. Once it is fixed, remove lto path.
void (*) (gcov_type, void *)
void (*) (gcov_type, void *)
void (*) (gcov_type *, gcov_type)
LTO streamer needs assembler names. Because we create these decls late, we need to initialize them by hand.
References build_fn_decl(), build_function_type_list(), build_pointer_type(), get_gcov_type(), get_identifier(), and init_ic_make_global_vars().
void gimple_remove_histogram_value | ( | struct function * | fun, |
gimple | stmt, | ||
histogram_value | hist | ||
) |
Remove histogram HIST from STMT's histogram list.
References histogram_value_t::hvalue, and histogram_value_t::next.
bool gimple_value_profile_transformations | ( | void | ) |
GIMPLE based transformations.
Transformations:
The order of things in this conditional controls which transformation is used when more than one is applicable.
It is expected that any code added by the transformations will be added before the current statement, and that the current statement remain valid (although possibly modified) upon return.
Original statement may no longer be in the same block.
References gimple_bb(), gsi_for_stmt(), and gsi_stmt().
void init_branch_prob | ( | void | ) |
In profile.c.
Perform file-level initialization for branch-prob processing.
void stream_in_histogram_value | ( | struct lto_input_block * | , |
gimple | |||
) |
void stream_out_histogram_value | ( | struct output_block * | , |
histogram_value | |||
) |
void stringop_block_profile | ( | gimple | , |
unsigned int * | , | ||
HOST_WIDE_INT * | |||
) |
Even if we can hold bigger value in SIZE, INT_MAX is safe "infinity" for code generation strategies.
References cfun, gimple_alloc_histogram_value(), histogram_value_t::hdata, HIST_TYPE_INTERVAL, HIST_TYPE_POW2, and histogram_value_t::intvl.
void verify_histograms | ( | void | ) |
Verify sanity of the histograms.