diff options
author | kan <kan@FreeBSD.org> | 2004-07-28 03:11:36 +0000 |
---|---|---|
committer | kan <kan@FreeBSD.org> | 2004-07-28 03:11:36 +0000 |
commit | 5e00ec74d8ce58f99801200d4d3d0412c7cc1b28 (patch) | |
tree | 052f4bb635f2bea2c5e350bd60c902be100a0d1e /contrib/gcc/tracer.c | |
parent | 87b8398a7d9f9bf0e28bbcd54a4fc27db2125f38 (diff) | |
download | FreeBSD-src-5e00ec74d8ce58f99801200d4d3d0412c7cc1b28.zip FreeBSD-src-5e00ec74d8ce58f99801200d4d3d0412c7cc1b28.tar.gz |
Gcc 3.4.2 20040728.
Diffstat (limited to 'contrib/gcc/tracer.c')
-rw-r--r-- | contrib/gcc/tracer.c | 98 |
1 files changed, 51 insertions, 47 deletions
diff --git a/contrib/gcc/tracer.c b/contrib/gcc/tracer.c index 970b5f4..b01238e 100644 --- a/contrib/gcc/tracer.c +++ b/contrib/gcc/tracer.c @@ -1,6 +1,6 @@ /* The tracer pass for the GNU compiler. Contributed by Jan Hubicka, SuSE Labs. - Copyright (C) 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of GCC. @@ -35,6 +35,8 @@ #include "config.h" #include "system.h" +#include "coretypes.h" +#include "tm.h" #include "tree.h" #include "rtl.h" #include "hard-reg-set.h" @@ -43,18 +45,18 @@ #include "cfglayout.h" #include "fibheap.h" #include "flags.h" +#include "timevar.h" #include "params.h" -#include "profile.h" - -static int count_insns PARAMS ((basic_block)); -static bool ignore_bb_p PARAMS ((basic_block)); -static bool better_p PARAMS ((edge, edge)); -static edge find_best_successor PARAMS ((basic_block)); -static edge find_best_predecessor PARAMS ((basic_block)); -static int find_trace PARAMS ((basic_block, basic_block *)); -static void tail_duplicate PARAMS ((void)); -static void layout_superblocks PARAMS ((void)); -static bool ignore_bb_p PARAMS ((basic_block)); +#include "coverage.h" + +static int count_insns (basic_block); +static bool ignore_bb_p (basic_block); +static bool better_p (edge, edge); +static edge find_best_successor (basic_block); +static edge find_best_predecessor (basic_block); +static int find_trace (basic_block, basic_block *); +static void tail_duplicate (void); +static void layout_superblocks (void); /* Minimal outgoing edge probability considered for superblock formation. */ static int probability_cutoff; @@ -63,12 +65,11 @@ static int branch_ratio_cutoff; /* Return true if BB has been seen - it is connected to some trace already. */ -#define seen(bb) (RBI (bb)->visited || RBI (bb)->next) +#define seen(bb) (bb->rbi->visited || bb->rbi->next) /* Return true if we should ignore the basic block for purposes of tracing. */ static bool -ignore_bb_p (bb) - basic_block bb; +ignore_bb_p (basic_block bb) { if (bb->index < 0) return true; @@ -80,13 +81,14 @@ ignore_bb_p (bb) /* Return number of instructions in the block. */ static int -count_insns (bb) - basic_block bb; +count_insns (basic_block bb) { rtx insn; int n = 0; - for (insn = bb->head; insn != NEXT_INSN (bb->end); insn = NEXT_INSN (insn)) + for (insn = BB_HEAD (bb); + insn != NEXT_INSN (BB_END (bb)); + insn = NEXT_INSN (insn)) if (active_insn_p (insn)) n++; return n; @@ -94,8 +96,7 @@ count_insns (bb) /* Return true if E1 is more frequent than E2. */ static bool -better_p (e1, e2) - edge e1, e2; +better_p (edge e1, edge e2) { if (e1->count != e2->count) return e1->count > e2->count; @@ -113,8 +114,7 @@ better_p (e1, e2) /* Return most frequent successor of basic block BB. */ static edge -find_best_successor (bb) - basic_block bb; +find_best_successor (basic_block bb) { edge e; edge best = NULL; @@ -132,8 +132,7 @@ find_best_successor (bb) /* Return most frequent predecessor of basic block BB. */ static edge -find_best_predecessor (bb) - basic_block bb; +find_best_predecessor (basic_block bb) { edge e; edge best = NULL; @@ -153,9 +152,7 @@ find_best_predecessor (bb) Return number of basic blocks recorded. */ static int -find_trace (bb, trace) - basic_block bb; - basic_block *trace; +find_trace (basic_block bb, basic_block *trace) { int i = 0; edge e; @@ -197,7 +194,7 @@ find_trace (bb, trace) if profitable. */ static void -tail_duplicate () +tail_duplicate (void) { fibnode_t *blocks = xcalloc (last_basic_block, sizeof (fibnode_t)); basic_block *trace = xmalloc (sizeof (basic_block) * n_basic_blocks); @@ -209,7 +206,7 @@ tail_duplicate () int max_dup_insns; basic_block bb; - if (profile_info.count_profiles_merged && flag_branch_probabilities) + if (profile_info && flag_branch_probabilities) probability_cutoff = PARAM_VALUE (TRACER_MIN_BRANCH_PROBABILITY_FEEDBACK); else probability_cutoff = PARAM_VALUE (TRACER_MIN_BRANCH_PROBABILITY); @@ -230,7 +227,7 @@ tail_duplicate () weighted_insns += n * bb->frequency; } - if (profile_info.count_profiles_merged && flag_branch_probabilities) + if (profile_info && flag_branch_probabilities) cover_insns = PARAM_VALUE (TRACER_DYNAMIC_COVERAGE_FEEDBACK); else cover_insns = PARAM_VALUE (TRACER_DYNAMIC_COVERAGE); @@ -285,7 +282,7 @@ tail_duplicate () bb2 = cfg_layout_duplicate_bb (bb2, e); /* Reconsider the original copy of block we've duplicated. - Removing the most common predecesor may make it to be + Removing the most common predecessor may make it to be head. */ blocks[old->index] = fibheap_insert (heap, -old->frequency, old); @@ -294,8 +291,8 @@ tail_duplicate () fprintf (rtl_dump_file, "Duplicated %i as %i [%i]\n", old->index, bb2->index, bb2->frequency); } - RBI (bb)->next = bb2; - RBI (bb2)->visited = 1; + bb->rbi->next = bb2; + bb2->rbi->visited = 1; bb = bb2; /* In case the trace became infrequent, stop duplicating. */ if (ignore_bb_p (bb)) @@ -315,13 +312,13 @@ tail_duplicate () fibheap_delete (heap); } -/* Connect the superblocks into linear seuqence. At the moment we attempt to keep +/* Connect the superblocks into linear sequence. At the moment we attempt to keep the original order as much as possible, but the algorithm may be made smarter later if needed. BB reordering pass should void most of the benefits of such change though. */ static void -layout_superblocks () +layout_superblocks (void) { basic_block end = ENTRY_BLOCK_PTR->succ->dest; basic_block bb = ENTRY_BLOCK_PTR->succ->dest->next_bb; @@ -329,42 +326,46 @@ layout_superblocks () while (bb != EXIT_BLOCK_PTR) { edge e, best = NULL; - while (RBI (end)->next) - end = RBI (end)->next; + while (end->rbi->next) + end = end->rbi->next; for (e = end->succ; e; e = e->succ_next) if (e->dest != EXIT_BLOCK_PTR && e->dest != ENTRY_BLOCK_PTR->succ->dest - && !RBI (e->dest)->visited + && !e->dest->rbi->visited && (!best || EDGE_FREQUENCY (e) > EDGE_FREQUENCY (best))) best = e; if (best) { - RBI (end)->next = best->dest; - RBI (best->dest)->visited = 1; + end->rbi->next = best->dest; + best->dest->rbi->visited = 1; } else - for (; bb != EXIT_BLOCK_PTR; bb=bb->next_bb) + for (; bb != EXIT_BLOCK_PTR; bb = bb->next_bb) { - if (!RBI (bb)->visited) + if (!bb->rbi->visited) { - RBI (end)->next = bb; - RBI (bb)->visited = 1; + end->rbi->next = bb; + bb->rbi->visited = 1; break; } } } } -/* Main entry point to this file. */ +/* Main entry point to this file. FLAGS is the set of flags to pass + to cfg_layout_initialize(). */ void -tracer () +tracer (unsigned int flags) { if (n_basic_blocks <= 1) return; - cfg_layout_initialize (); + + timevar_push (TV_TRACER); + + cfg_layout_initialize (flags); mark_dfs_back_edges (); if (rtl_dump_file) dump_flow_info (rtl_dump_file); @@ -373,6 +374,9 @@ tracer () if (rtl_dump_file) dump_flow_info (rtl_dump_file); cfg_layout_finalize (); + /* Merge basic blocks in duplicated traces. */ cleanup_cfg (CLEANUP_EXPENSIVE); + + timevar_pop (TV_TRACER); } |