mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-29 14:01:18 +08:00
* asan.c (asan_emit_stack_protection): Update. (create_cond_insert_point): Update. * auto-profile.c (afdo_propagate_circuit): Update. * basic-block.h (struct edge_def): Turn probability to profile_probability. (EDGE_FREQUENCY): Update. * bb-reorder.c (find_traces_1_round): Update. (better_edge_p): Update. (sanitize_hot_paths): Update. * cfg.c (unchecked_make_edge): Initialize probability to uninitialized. (make_single_succ_edge): Update. (check_bb_profile): Update. (dump_edge_info): Update. (update_bb_profile_for_threading): Update. * cfganal.c (connect_infinite_loops_to_exit): Initialize new edge probabilitycount to 0. * cfgbuild.c (compute_outgoing_frequencies): Update. * cfgcleanup.c (try_forward_edges): Update. (outgoing_edges_match): Update. (try_crossjump_to_edge): Update. * cfgexpand.c (expand_gimple_cond): Update make_single_succ_edge. (expand_gimple_tailcall): Update. (construct_init_block): Use make_single_succ_edge. (construct_exit_block): Use make_single_succ_edge. * cfghooks.c (verify_flow_info): Update. (redirect_edge_succ_nodup): Update. (split_edge): Update. (account_profile_record): Update. * cfgloopanal.c (single_likely_exit): Update. * cfgloopmanip.c (scale_loop_profile): Update. (set_zero_probability): Remove. (duplicate_loop_to_header_edge): Update. * cfgloopmanip.h (loop_version): Update prototype. * cfgrtl.c (try_redirect_by_replacing_jump): Update. (force_nonfallthru_and_redirect): Update. (update_br_prob_note): Update. (rtl_verify_edges): Update. (purge_dead_edges): Update. (rtl_lv_add_condition_to_bb): Update. * cgraph.c: (cgraph_edge::redirect_call_stmt_to_calle): Update. * cgraphunit.c (init_lowered_empty_function): Update. (cgraph_node::expand_thunk): Update. * cilk-common.c: Include profile-count.h * dojump.c (inv): Remove. (jumpifnot): Update. (jumpifnot_1): Update. (do_jump_1): Update. (do_jump): Update. (do_jump_by_parts_greater_rtx): Update. (do_compare_rtx_and_jump): Update. * dojump.h (jumpifnot, jumpifnot_1, jumpif_1, jumpif, do_jump, do_jump_1. do_compare_rtx_and_jump): Update prototype. * dwarf2cfi.c: Include profile-count.h * except.c (dw2_build_landing_pads): Use make_single_succ_edge. (sjlj_emit_dispatch_table): Likewise. * explow.c: Include profile-count.h * expmed.c (emit_store_flag_force): Update. (do_cmp_and_jump): Update. * expr.c (compare_by_pieces_d::generate): Update. (compare_by_pieces_d::finish_mode): Update. (emit_block_move_via_loop): Update. (store_expr_with_bounds): Update. (store_constructor): Update. (expand_expr_real_2): Update. (expand_expr_real_1): Update. * expr.h (try_casesi, try_tablejump): Update prototypes. * gimple-pretty-print.c (dump_probability): Update. (dump_profile): New. (dump_gimple_label): Update. (dump_gimple_bb_header): Update. * graph.c (draw_cfg_node_succ_edges): Update. * hsa-gen.c (convert_switch_statements): Update. * ifcvt.c (cheap_bb_rtx_cost_p): Update. (find_if_case_1): Update. (find_if_case_2): Update. * internal-fn.c (expand_arith_overflow_result_store): Update. (expand_addsub_overflow): Update. (expand_neg_overflow): Update. (expand_mul_overflow): Update. (expand_vector_ubsan_overflow): Update. * ipa-cp.c (good_cloning_opportunity_p): Update. * ipa-split.c (split_function): Use make_single_succ_edge. * ipa-utils.c (ipa_merge_profiles): Update. * loop-doloop.c (add_test): Update. (doloop_modify): Update. * loop-unroll.c (compare_and_jump_seq): Update. (unroll_loop_runtime_iterations): Update. * lra-constraints.c (lra_inheritance): Update. * lto-streamer-in.c (input_cfg): Update. * lto-streamer-out.c (output_cfg): Update. * mcf.c (adjust_cfg_counts): Update. * modulo-sched.c (sms_schedule): Update. * omp-expand.c (expand_omp_for_init_counts): Update. (extract_omp_for_update_vars): Update. (expand_omp_ordered_sink): Update. (expand_omp_for_ordered_loops): Update. (expand_omp_for_generic): Update. (expand_omp_for_static_nochunk): Update. (expand_omp_for_static_chunk): Update. (expand_cilk_for): Update. (expand_omp_simd): Update. (expand_omp_taskloop_for_outer): Update. (expand_omp_taskloop_for_inner): Update. * omp-simd-clone.c (simd_clone_adjust): Update. * optabs.c (expand_doubleword_shift): Update. (expand_abs): Update. (emit_cmp_and_jump_insn_1): Update. (expand_compare_and_swap_loop): Update. * optabs.h (emit_cmp_and_jump_insns): Update prototype. * predict.c (predictable_edge_p): Update. (edge_probability_reliable_p): Update. (set_even_probabilities): Update. (combine_predictions_for_insn): Update. (combine_predictions_for_bb): Update. (propagate_freq): Update. (estimate_bb_frequencies): Update. (force_edge_cold): Update. * profile-count.c (profile_count::dump): Add missing space into dump. (profile_count::debug): Add newline. (profile_count::differs_from_p): Explicitly convert to unsigned. (profile_count::stream_in): Update. (profile_probability::dump): New member function. (profile_probability::debug): New member function. (profile_probability::differs_from_p): New member function. (profile_probability::differs_lot_from_p): New member function. (profile_probability::stream_in): New member function. (profile_probability::stream_out): New member function. * profile-count.h (profile_count_quality): Rename to ... (profile_quality): ... this one. (profile_probability): New. (profile_count): Update. * profile.c (compute_branch_probabilities): Update. * recog.c (peep2_attempt): Update. * sched-ebb.c (schedule_ebbs): Update. * sched-rgn.c (find_single_block_region): Update. (compute_dom_prob_ps): Update. (schedule_region): Update. * sel-sched-ir.c (compute_succs_info): Update. * stmt.c (struct case_node): Update. (do_jump_if_equal): Update. (get_outgoing_edge_probs): Update. (conditional_probability): Update. (emit_case_dispatch_table): Update. (expand_case): Update. (expand_sjlj_dispatch_table): Update. (emit_case_nodes): Update. * targhooks.c: Update. * tracer.c (better_p): Update. (find_best_successor): Update. * trans-mem.c (expand_transaction): Update. * tree-call-cdce.c: Update. * tree-cfg.c (gimple_split_edge): Upate. (move_sese_region_to_fn): Upate. * tree-cfgcleanup.c (cleanup_control_expr_graph): Upate. * tree-eh.c (lower_resx): Upate. (cleanup_empty_eh_move_lp): Upate. * tree-if-conv.c (version_loop_for_if_conversion): Update. * tree-inline.c (copy_edges_for_bb): Update. (copy_cfg_body): Update. * tree-parloops.c (gen_parallel_loop): Update. * tree-profile.c (gimple_gen_ic_func_profiler): Update. (gimple_gen_time_profiler): Update. * tree-ssa-dce.c (remove_dead_stmt): Update. * tree-ssa-ifcombine.c (update_profile_after_ifcombine): Update. * tree-ssa-loop-im.c (execute_sm_if_changed): Update. * tree-ssa-loop-ivcanon.c (remove_exits_and_undefined_stmts): Update. (unloop_loops): Update. (try_peel_loop): Update. * tree-ssa-loop-manip.c (tree_transform_and_unroll_loop): Update. * tree-ssa-loop-split.c (connect_loops): Update. (split_loop): Update. * tree-ssa-loop-unswitch.c (tree_unswitch_loop): Update. (hoist_guard): Update. * tree-ssa-phionlycprop.c (propagate_rhs_into_lhs): Update. * tree-ssa-phiopt.c (replace_phi_edge_with_variable): Update. (value_replacement): Update. * tree-ssa-reassoc.c (branch_fixup): Update. * tree-ssa-tail-merge.c (replace_block_by): Update. * tree-ssa-threadupdate.c (remove_ctrl_stmt_and_useless_edges): Update. (create_edge_and_update_destination_phis): Update. (compute_path_counts): Update. (recompute_probabilities): Update. (update_joiner_offpath_counts): Update. (freqs_to_counts_path): Update. (duplicate_thread_path): Update. * tree-switch-conversion.c (hoist_edge_and_branch_if_true): Update. (struct switch_conv_info): Update. (gen_inbound_check): Update. * tree-vect-loop-manip.c (slpeel_add_loop_guard): Update. (vect_do_peeling): Update. (vect_loop_versioning): Update. * tree-vect-loop.c (scale_profile_for_vect_loop): Update. (optimize_mask_stores): Update. * ubsan.c (ubsan_expand_null_ifn): Update. * value-prof.c (gimple_divmod_fixed_value): Update. (gimple_divmod_fixed_value_transform): Update. (gimple_mod_pow2): Update. (gimple_mod_pow2_value_transform): Update. (gimple_mod_subtract): Update. (gimple_mod_subtract_transform): Update. (gimple_ic): Update. (gimple_stringop_fixed_value): Update. (gimple_stringops_transform): Update. * value-prof.h: Update. From-SVN: r249800
444 lines
12 KiB
C
444 lines
12 KiB
C
/* The tracer pass for the GNU compiler.
|
||
Contributed by Jan Hubicka, SuSE Labs.
|
||
Adapted to work on GIMPLE instead of RTL by Robert Kidd, UIUC.
|
||
Copyright (C) 2001-2017 Free Software Foundation, Inc.
|
||
|
||
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 pass performs the tail duplication needed for superblock formation.
|
||
For more information see:
|
||
|
||
Design and Analysis of Profile-Based Optimization in Compaq's
|
||
Compilation Tools for Alpha; Journal of Instruction-Level
|
||
Parallelism 3 (2000) 1-25
|
||
|
||
Unlike Compaq's implementation we don't do the loop peeling as most
|
||
probably a better job can be done by a special pass and we don't
|
||
need to worry too much about the code size implications as the tail
|
||
duplicates are crossjumped again if optimizations are not
|
||
performed. */
|
||
|
||
|
||
#include "config.h"
|
||
#include "system.h"
|
||
#include "coretypes.h"
|
||
#include "backend.h"
|
||
#include "rtl.h"
|
||
#include "tree.h"
|
||
#include "gimple.h"
|
||
#include "cfghooks.h"
|
||
#include "tree-pass.h"
|
||
#include "profile.h"
|
||
#include "cfganal.h"
|
||
#include "params.h"
|
||
#include "gimple-iterator.h"
|
||
#include "tree-cfg.h"
|
||
#include "tree-ssa.h"
|
||
#include "tree-inline.h"
|
||
#include "cfgloop.h"
|
||
#include "fibonacci_heap.h"
|
||
#include "tracer.h"
|
||
|
||
static int count_insns (basic_block);
|
||
static bool better_p (const_edge, const_edge);
|
||
static edge find_best_successor (basic_block);
|
||
static edge find_best_predecessor (basic_block);
|
||
static int find_trace (basic_block, basic_block *);
|
||
|
||
/* Minimal outgoing edge probability considered for superblock formation. */
|
||
static int probability_cutoff;
|
||
static int branch_ratio_cutoff;
|
||
|
||
/* A bit BB->index is set if BB has already been seen, i.e. it is
|
||
connected to some trace already. */
|
||
static sbitmap bb_seen;
|
||
|
||
static inline void
|
||
mark_bb_seen (basic_block bb)
|
||
{
|
||
unsigned int size = SBITMAP_SIZE (bb_seen);
|
||
|
||
if ((unsigned int)bb->index >= size)
|
||
bb_seen = sbitmap_resize (bb_seen, size * 2, 0);
|
||
|
||
bitmap_set_bit (bb_seen, bb->index);
|
||
}
|
||
|
||
static inline bool
|
||
bb_seen_p (basic_block bb)
|
||
{
|
||
return bitmap_bit_p (bb_seen, bb->index);
|
||
}
|
||
|
||
/* Return true if we should ignore the basic block for purposes of tracing. */
|
||
bool
|
||
ignore_bb_p (const_basic_block bb)
|
||
{
|
||
if (bb->index < NUM_FIXED_BLOCKS)
|
||
return true;
|
||
if (optimize_bb_for_size_p (bb))
|
||
return true;
|
||
|
||
if (gimple *g = last_stmt (CONST_CAST_BB (bb)))
|
||
{
|
||
/* A transaction is a single entry multiple exit region. It
|
||
must be duplicated in its entirety or not at all. */
|
||
if (gimple_code (g) == GIMPLE_TRANSACTION)
|
||
return true;
|
||
|
||
/* An IFN_UNIQUE call must be duplicated as part of its group,
|
||
or not at all. */
|
||
if (is_gimple_call (g)
|
||
&& gimple_call_internal_p (g)
|
||
&& gimple_call_internal_unique_p (g))
|
||
return true;
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
/* Return number of instructions in the block. */
|
||
|
||
static int
|
||
count_insns (basic_block bb)
|
||
{
|
||
gimple_stmt_iterator gsi;
|
||
gimple *stmt;
|
||
int n = 0;
|
||
|
||
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
|
||
{
|
||
stmt = gsi_stmt (gsi);
|
||
n += estimate_num_insns (stmt, &eni_size_weights);
|
||
}
|
||
return n;
|
||
}
|
||
|
||
/* Return true if E1 is more frequent than E2. */
|
||
static bool
|
||
better_p (const_edge e1, const_edge e2)
|
||
{
|
||
if (e1->count.initialized_p () && e2->count.initialized_p ()
|
||
&& !(e1->count == e2->count))
|
||
return e1->count > e2->count;
|
||
if (EDGE_FREQUENCY (e1) != EDGE_FREQUENCY (e2))
|
||
return EDGE_FREQUENCY (e1) > EDGE_FREQUENCY (e2);
|
||
/* This is needed to avoid changes in the decision after
|
||
CFG is modified. */
|
||
if (e1->src != e2->src)
|
||
return e1->src->index > e2->src->index;
|
||
return e1->dest->index > e2->dest->index;
|
||
}
|
||
|
||
/* Return most frequent successor of basic block BB. */
|
||
|
||
static edge
|
||
find_best_successor (basic_block bb)
|
||
{
|
||
edge e;
|
||
edge best = NULL;
|
||
edge_iterator ei;
|
||
|
||
FOR_EACH_EDGE (e, ei, bb->succs)
|
||
if (!best || better_p (e, best))
|
||
best = e;
|
||
if (!best || ignore_bb_p (best->dest))
|
||
return NULL;
|
||
if (best->probability.initialized_p ()
|
||
&& best->probability.to_reg_br_prob_base () <= probability_cutoff)
|
||
return NULL;
|
||
return best;
|
||
}
|
||
|
||
/* Return most frequent predecessor of basic block BB. */
|
||
|
||
static edge
|
||
find_best_predecessor (basic_block bb)
|
||
{
|
||
edge e;
|
||
edge best = NULL;
|
||
edge_iterator ei;
|
||
|
||
FOR_EACH_EDGE (e, ei, bb->preds)
|
||
if (!best || better_p (e, best))
|
||
best = e;
|
||
if (!best || ignore_bb_p (best->src))
|
||
return NULL;
|
||
if (EDGE_FREQUENCY (best) * REG_BR_PROB_BASE
|
||
< bb->frequency * branch_ratio_cutoff)
|
||
return NULL;
|
||
return best;
|
||
}
|
||
|
||
/* Find the trace using bb and record it in the TRACE array.
|
||
Return number of basic blocks recorded. */
|
||
|
||
static int
|
||
find_trace (basic_block bb, basic_block *trace)
|
||
{
|
||
int i = 0;
|
||
edge e;
|
||
|
||
if (dump_file)
|
||
fprintf (dump_file, "Trace seed %i [%i]", bb->index, bb->frequency);
|
||
|
||
while ((e = find_best_predecessor (bb)) != NULL)
|
||
{
|
||
basic_block bb2 = e->src;
|
||
if (bb_seen_p (bb2) || (e->flags & (EDGE_DFS_BACK | EDGE_COMPLEX))
|
||
|| find_best_successor (bb2) != e)
|
||
break;
|
||
if (dump_file)
|
||
fprintf (dump_file, ",%i [%i]", bb->index, bb->frequency);
|
||
bb = bb2;
|
||
}
|
||
if (dump_file)
|
||
fprintf (dump_file, " forward %i [%i]", bb->index, bb->frequency);
|
||
trace[i++] = bb;
|
||
|
||
/* Follow the trace in forward direction. */
|
||
while ((e = find_best_successor (bb)) != NULL)
|
||
{
|
||
bb = e->dest;
|
||
if (bb_seen_p (bb) || (e->flags & (EDGE_DFS_BACK | EDGE_COMPLEX))
|
||
|| find_best_predecessor (bb) != e)
|
||
break;
|
||
if (dump_file)
|
||
fprintf (dump_file, ",%i [%i]", bb->index, bb->frequency);
|
||
trace[i++] = bb;
|
||
}
|
||
if (dump_file)
|
||
fprintf (dump_file, "\n");
|
||
return i;
|
||
}
|
||
|
||
/* Duplicate block BB2, placing it after BB in the CFG. Return the
|
||
newly created block. */
|
||
basic_block
|
||
transform_duplicate (basic_block bb, basic_block bb2)
|
||
{
|
||
edge e;
|
||
basic_block copy;
|
||
|
||
e = find_edge (bb, bb2);
|
||
|
||
copy = duplicate_block (bb2, e, bb);
|
||
flush_pending_stmts (e);
|
||
|
||
add_phi_args_after_copy (©, 1, NULL);
|
||
|
||
return (copy);
|
||
}
|
||
|
||
/* Look for basic blocks in frequency order, construct traces and tail duplicate
|
||
if profitable. */
|
||
|
||
static bool
|
||
tail_duplicate (void)
|
||
{
|
||
auto_vec<fibonacci_node<long, basic_block_def>*> blocks;
|
||
blocks.safe_grow_cleared (last_basic_block_for_fn (cfun));
|
||
|
||
basic_block *trace = XNEWVEC (basic_block, n_basic_blocks_for_fn (cfun));
|
||
int *counts = XNEWVEC (int, last_basic_block_for_fn (cfun));
|
||
int ninsns = 0, nduplicated = 0;
|
||
gcov_type weighted_insns = 0, traced_insns = 0;
|
||
fibonacci_heap<long, basic_block_def> heap (LONG_MIN);
|
||
gcov_type cover_insns;
|
||
int max_dup_insns;
|
||
basic_block bb;
|
||
bool changed = false;
|
||
|
||
/* Create an oversized sbitmap to reduce the chance that we need to
|
||
resize it. */
|
||
bb_seen = sbitmap_alloc (last_basic_block_for_fn (cfun) * 2);
|
||
bitmap_clear (bb_seen);
|
||
initialize_original_copy_tables ();
|
||
|
||
if (profile_info && profile_status_for_fn (cfun) == PROFILE_READ)
|
||
probability_cutoff = PARAM_VALUE (TRACER_MIN_BRANCH_PROBABILITY_FEEDBACK);
|
||
else
|
||
probability_cutoff = PARAM_VALUE (TRACER_MIN_BRANCH_PROBABILITY);
|
||
probability_cutoff = REG_BR_PROB_BASE / 100 * probability_cutoff;
|
||
|
||
branch_ratio_cutoff =
|
||
(REG_BR_PROB_BASE / 100 * PARAM_VALUE (TRACER_MIN_BRANCH_RATIO));
|
||
|
||
FOR_EACH_BB_FN (bb, cfun)
|
||
{
|
||
int n = count_insns (bb);
|
||
if (!ignore_bb_p (bb))
|
||
blocks[bb->index] = heap.insert (-bb->frequency, bb);
|
||
|
||
counts [bb->index] = n;
|
||
ninsns += n;
|
||
weighted_insns += n * bb->frequency;
|
||
}
|
||
|
||
if (profile_info && profile_status_for_fn (cfun) == PROFILE_READ)
|
||
cover_insns = PARAM_VALUE (TRACER_DYNAMIC_COVERAGE_FEEDBACK);
|
||
else
|
||
cover_insns = PARAM_VALUE (TRACER_DYNAMIC_COVERAGE);
|
||
cover_insns = (weighted_insns * cover_insns + 50) / 100;
|
||
max_dup_insns = (ninsns * PARAM_VALUE (TRACER_MAX_CODE_GROWTH) + 50) / 100;
|
||
|
||
while (traced_insns < cover_insns && nduplicated < max_dup_insns
|
||
&& !heap.empty ())
|
||
{
|
||
basic_block bb = heap.extract_min ();
|
||
int n, pos;
|
||
|
||
if (!bb)
|
||
break;
|
||
|
||
blocks[bb->index] = NULL;
|
||
|
||
if (ignore_bb_p (bb))
|
||
continue;
|
||
gcc_assert (!bb_seen_p (bb));
|
||
|
||
n = find_trace (bb, trace);
|
||
|
||
bb = trace[0];
|
||
traced_insns += bb->frequency * counts [bb->index];
|
||
if (blocks[bb->index])
|
||
{
|
||
heap.delete_node (blocks[bb->index]);
|
||
blocks[bb->index] = NULL;
|
||
}
|
||
|
||
for (pos = 1; pos < n; pos++)
|
||
{
|
||
basic_block bb2 = trace[pos];
|
||
|
||
if (blocks[bb2->index])
|
||
{
|
||
heap.delete_node (blocks[bb2->index]);
|
||
blocks[bb2->index] = NULL;
|
||
}
|
||
traced_insns += bb2->frequency * counts [bb2->index];
|
||
if (EDGE_COUNT (bb2->preds) > 1
|
||
&& can_duplicate_block_p (bb2)
|
||
/* We have the tendency to duplicate the loop header
|
||
of all do { } while loops. Do not do that - it is
|
||
not profitable and it might create a loop with multiple
|
||
entries or at least rotate the loop. */
|
||
&& bb2->loop_father->header != bb2)
|
||
{
|
||
nduplicated += counts [bb2->index];
|
||
basic_block copy = transform_duplicate (bb, bb2);
|
||
|
||
/* Reconsider the original copy of block we've duplicated.
|
||
Removing the most common predecessor may make it to be
|
||
head. */
|
||
blocks[bb2->index] = heap.insert (-bb2->frequency, bb2);
|
||
|
||
if (dump_file)
|
||
fprintf (dump_file, "Duplicated %i as %i [%i]\n",
|
||
bb2->index, copy->index, copy->frequency);
|
||
|
||
bb2 = copy;
|
||
changed = true;
|
||
}
|
||
mark_bb_seen (bb2);
|
||
bb = bb2;
|
||
/* In case the trace became infrequent, stop duplicating. */
|
||
if (ignore_bb_p (bb))
|
||
break;
|
||
}
|
||
if (dump_file)
|
||
fprintf (dump_file, " covered now %.1f\n\n",
|
||
traced_insns * 100.0 / weighted_insns);
|
||
}
|
||
if (dump_file)
|
||
fprintf (dump_file, "Duplicated %i insns (%i%%)\n", nduplicated,
|
||
nduplicated * 100 / ninsns);
|
||
|
||
free_original_copy_tables ();
|
||
sbitmap_free (bb_seen);
|
||
free (trace);
|
||
free (counts);
|
||
|
||
return changed;
|
||
}
|
||
|
||
namespace {
|
||
|
||
const pass_data pass_data_tracer =
|
||
{
|
||
GIMPLE_PASS, /* type */
|
||
"tracer", /* name */
|
||
OPTGROUP_NONE, /* optinfo_flags */
|
||
TV_TRACER, /* tv_id */
|
||
0, /* properties_required */
|
||
0, /* properties_provided */
|
||
0, /* properties_destroyed */
|
||
0, /* todo_flags_start */
|
||
TODO_update_ssa, /* todo_flags_finish */
|
||
};
|
||
|
||
class pass_tracer : public gimple_opt_pass
|
||
{
|
||
public:
|
||
pass_tracer (gcc::context *ctxt)
|
||
: gimple_opt_pass (pass_data_tracer, ctxt)
|
||
{}
|
||
|
||
/* opt_pass methods: */
|
||
virtual bool gate (function *)
|
||
{
|
||
return (optimize > 0 && flag_tracer && flag_reorder_blocks);
|
||
}
|
||
|
||
virtual unsigned int execute (function *);
|
||
|
||
}; // class pass_tracer
|
||
|
||
unsigned int
|
||
pass_tracer::execute (function *fun)
|
||
{
|
||
bool changed;
|
||
|
||
if (n_basic_blocks_for_fn (fun) <= NUM_FIXED_BLOCKS + 1)
|
||
return 0;
|
||
|
||
mark_dfs_back_edges ();
|
||
if (dump_file)
|
||
brief_dump_cfg (dump_file, dump_flags);
|
||
|
||
/* Trace formation is done on the fly inside tail_duplicate */
|
||
changed = tail_duplicate ();
|
||
if (changed)
|
||
{
|
||
free_dominance_info (CDI_DOMINATORS);
|
||
/* If we changed the CFG schedule loops for fixup by cleanup_cfg. */
|
||
loops_state_set (LOOPS_NEED_FIXUP);
|
||
}
|
||
|
||
if (dump_file)
|
||
brief_dump_cfg (dump_file, dump_flags);
|
||
|
||
return changed ? TODO_cleanup_cfg : 0;
|
||
}
|
||
} // anon namespace
|
||
|
||
gimple_opt_pass *
|
||
make_pass_tracer (gcc::context *ctxt)
|
||
{
|
||
return new pass_tracer (ctxt);
|
||
}
|