OSDN Git Service

* target-def.h: Remove usage of OBJECT_FORMAT_ROSE.
[pf3gnuchains/gcc-fork.git] / gcc / bb-reorder.c
index 49889ee..e055611 100644 (file)
@@ -141,29 +141,24 @@ int max_entry_frequency;
 gcov_type max_entry_count;
 
 /* Local function prototypes.  */
-static void find_traces                        PARAMS ((int *, struct trace *));
-static basic_block rotate_loop         PARAMS ((edge, struct trace *, int));
-static void mark_bb_visited            PARAMS ((basic_block, int));
-static void find_traces_1_round                PARAMS ((int, int, gcov_type,
-                                                struct trace *, int *, int,
-                                                fibheap_t *));
-static basic_block copy_bb             PARAMS ((basic_block, edge,
-                                                basic_block, int));
-static fibheapkey_t bb_to_key          PARAMS ((basic_block));
-static bool better_edge_p              PARAMS ((basic_block, edge, int, int,
-                                                int, int));
-static void connect_traces             PARAMS ((int, struct trace *));
-static bool copy_bb_p                  PARAMS ((basic_block, int));
-static int get_uncond_jump_length      PARAMS ((void));
+static void find_traces (int *, struct trace *);
+static basic_block rotate_loop (edge, struct trace *, int);
+static void mark_bb_visited (basic_block, int);
+static void find_traces_1_round (int, int, gcov_type, struct trace *, int *,
+                                int, fibheap_t *);
+static basic_block copy_bb (basic_block, edge, basic_block, int);
+static fibheapkey_t bb_to_key (basic_block);
+static bool better_edge_p (basic_block, edge, int, int, int, int);
+static void connect_traces (int, struct trace *);
+static bool copy_bb_p (basic_block, int);
+static int get_uncond_jump_length (void);
 \f
 /* Find the traces for Software Trace Cache.  Chain each trace through
    RBI()->next.  Store the number of traces to N_TRACES and description of
    traces to TRACES.  */
 
 static void
-find_traces (n_traces, traces)
-     int *n_traces;
-     struct trace *traces;
+find_traces (int *n_traces, struct trace *traces)
 {
   int i;
   edge e;
@@ -222,10 +217,7 @@ find_traces (n_traces, traces)
    (with sequential number TRACE_N).  */
 
 static basic_block
-rotate_loop (back_edge, trace, trace_n)
-     edge back_edge;
-     struct trace *trace;
-     int trace_n;
+rotate_loop (edge back_edge, struct trace *trace, int trace_n)
 {
   basic_block bb;
 
@@ -339,9 +331,7 @@ rotate_loop (back_edge, trace, trace_n)
 /* This function marks BB that it was visited in trace number TRACE.  */
 
 static void
-mark_bb_visited (bb, trace)
-     basic_block bb;
-     int trace;
+mark_bb_visited (basic_block bb, int trace)
 {
   RBI (bb)->visited = trace;
   if (bbd[bb->index].heap)
@@ -361,15 +351,9 @@ mark_bb_visited (bb, trace)
    *HEAP and stores starting points for the next round into new *HEAP.  */
 
 static void
-find_traces_1_round (branch_th, exec_th, count_th, traces, n_traces, round,
-                    heap)
-     int branch_th;
-     int exec_th;
-     gcov_type count_th;
-     struct trace *traces;
-     int *n_traces;
-     int round;
-     fibheap_t *heap;
+find_traces_1_round (int branch_th, int exec_th, gcov_type count_th,
+                    struct trace *traces, int *n_traces, int round,
+                    fibheap_t *heap)
 {
   /* Heap for discarded basic blocks which are possible starting points for
      the next round.  */
@@ -390,8 +374,9 @@ find_traces_1_round (branch_th, exec_th, count_th, traces, n_traces, round,
        fprintf (rtl_dump_file, "Getting bb %d\n", bb->index);
 
       /* If the BB's frequency is too low send BB to the next round.  */
-      if (bb->frequency < exec_th || bb->count < count_th
-         || ((round < N_ROUNDS - 1) && probably_never_executed_bb_p (bb)))
+      if (round < N_ROUNDS - 1
+         && (bb->frequency < exec_th || bb->count < count_th
+             || probably_never_executed_bb_p (bb)))
        {
          int key = bb_to_key (bb);
          bbd[bb->index].heap = new_heap;
@@ -448,12 +433,6 @@ find_traces_1_round (branch_th, exec_th, count_th, traces, n_traces, round,
                  || prob < branch_th || freq < exec_th || e->count < count_th)
                continue;
 
-             /* If the destination has multiple precessesors, and can be
-                duplicated cheaper than a jump, don't allow it to be added
-                to a trace.  We'll duplicate it when connecting traces.  */
-             if (e->dest->pred->pred_next && copy_bb_p (e->dest, 0))
-               continue;
-
              if (better_edge_p (bb, e, prob, freq, best_prob, best_freq))
                {
                  best_edge = e;
@@ -462,6 +441,13 @@ find_traces_1_round (branch_th, exec_th, count_th, traces, n_traces, round,
                }
            }
 
+         /* If the best destination has multiple predecessors, and can be
+            duplicated cheaper than a jump, don't allow it to be added
+            to a trace.  We'll duplicate it when connecting traces.  */
+         if (best_edge && best_edge->dest->pred->pred_next
+             && copy_bb_p (best_edge->dest, 0))
+           best_edge = NULL;
+
          /* Add all non-selected successors to the heaps.  */
          for (e = bb->succ; e; e = e->succ_next)
            {
@@ -663,11 +649,7 @@ find_traces_1_round (branch_th, exec_th, count_th, traces, n_traces, round,
    (TRACE is a number of trace which OLD_BB is duplicated to).  */
 
 static basic_block
-copy_bb (old_bb, e, bb, trace)
-     basic_block old_bb;
-     edge e;
-     basic_block bb;
-     int trace;
+copy_bb (basic_block old_bb, edge e, basic_block bb, int trace)
 {
   basic_block new_bb;
 
@@ -715,8 +697,7 @@ copy_bb (old_bb, e, bb, trace)
 /* Compute and return the key (for the heap) of the basic block BB.  */
 
 static fibheapkey_t
-bb_to_key (bb)
-     basic_block bb;
+bb_to_key (basic_block bb)
 {
   edge e;
 
@@ -754,13 +735,8 @@ bb_to_key (bb)
    BEST_PROB; similarly for frequency.  */
 
 static bool
-better_edge_p (bb, e, prob, freq, best_prob, best_freq)
-     basic_block bb;
-     edge e;
-     int prob;
-     int freq;
-     int best_prob;
-     int best_freq;
+better_edge_p (basic_block bb, edge e, int prob, int freq, int best_prob,
+              int best_freq)
 {
   bool is_better_edge;
 
@@ -797,9 +773,7 @@ better_edge_p (bb, e, prob, freq, best_prob, best_freq)
 /* Connect traces in array TRACES, N_TRACES is the count of traces.  */
 
 static void
-connect_traces (n_traces, traces)
-     int n_traces;
-     struct trace *traces;
+connect_traces (int n_traces, struct trace *traces)
 {
   int i;
   bool *connected;
@@ -922,15 +896,17 @@ connect_traces (n_traces, traces)
                    edge best2 = NULL;
                    int best2_len = 0;
 
-                   /* If the destination trace is only one block
-                      long, then no need to search the successor
+                   /* If the destination is a start of a trace which is only
+                      one block long, then no need to search the successor
                       blocks of the trace.  Accept it.  */
-                  if (traces[bbd[e->dest->index].start_of_trace].length == 1)
-                    {
-                      best = e;
-                      try_copy = true;
-                      continue;
-                    }
+                   if (bbd[e->dest->index].start_of_trace >= 0
+                       && traces[bbd[e->dest->index].start_of_trace].length
+                          == 1)
+                     {
+                       best = e;
+                       try_copy = true;
+                       continue;
+                     }
 
                    for (e2 = e->dest->succ; e2; e2 = e2->succ_next)
                      {
@@ -1019,9 +995,7 @@ connect_traces (n_traces, traces)
    when code size is allowed to grow by duplication.  */
 
 static bool
-copy_bb_p (bb, code_may_grow)
-     basic_block bb;
-     int code_may_grow;
+copy_bb_p (basic_block bb, int code_may_grow)
 {
   int size = 0;
   int max_size = uncond_jump_length;
@@ -1060,7 +1034,7 @@ copy_bb_p (bb, code_may_grow)
 /* Return the length of unconditional jump instruction.  */
 
 static int
-get_uncond_jump_length ()
+get_uncond_jump_length (void)
 {
   rtx label, jump;
   int length;
@@ -1078,7 +1052,7 @@ get_uncond_jump_length ()
 /* Reorder basic blocks.  The main entry point to this file.  */
 
 void
-reorder_basic_blocks ()
+reorder_basic_blocks (void)
 {
   int n_traces;
   int i;
@@ -1097,7 +1071,7 @@ reorder_basic_blocks ()
 
   /* We are estimating the lenght of uncond jump insn only once since the code
      for getting the insn lenght always returns the minimal length now.  */
-  if (uncond_jump_length == 0) 
+  if (uncond_jump_length == 0)
     uncond_jump_length = get_uncond_jump_length ();
 
   /* We need to know some information for each basic block.  */