OSDN Git Service

patch for PR rtl-optimization/25130
[pf3gnuchains/gcc-fork.git] / gcc / tracer.c
index cddc5b9..b65c316 100644 (file)
@@ -48,6 +48,7 @@
 #include "timevar.h"
 #include "params.h"
 #include "coverage.h"
+#include "tree-pass.h"
 
 static int count_insns (basic_block);
 static bool ignore_bb_p (basic_block);
@@ -65,13 +66,13 @@ static int branch_ratio_cutoff;
 /* Return true if BB has been seen - it is connected to some trace
    already.  */
 
-#define seen(bb) (bb->rbi->visited || bb->rbi->next)
+#define seen(bb) (bb->il.rtl->visited || bb->aux)
 
 /* Return true if we should ignore the basic block for purposes of tracing.  */
 static bool
 ignore_bb_p (basic_block bb)
 {
-  if (bb->index < 0)
+  if (bb->index < NUM_FIXED_BLOCKS)
     return true;
   if (!maybe_hot_bb_p (bb))
     return true;
@@ -280,7 +281,7 @@ tail_duplicate (void)
              e = find_edge (bb, bb2);
 
              nduplicated += counts [bb2->index];
-             bb2 = duplicate_block (bb2, e);
+             bb2 = duplicate_block (bb2, e, bb);
 
              /* Reconsider the original copy of block we've duplicated.
                 Removing the most common predecessor may make it to be
@@ -292,8 +293,8 @@ tail_duplicate (void)
                fprintf (dump_file, "Duplicated %i as %i [%i]\n",
                         old->index, bb2->index, bb2->frequency);
            }
-         bb->rbi->next = bb2;
-         bb2->rbi->visited = 1;
+         bb->aux = bb2;
+         bb2->il.rtl->visited = 1;
          bb = bb2;
          /* In case the trace became infrequent, stop duplicating.  */
          if (ignore_bb_p (bb))
@@ -328,28 +329,28 @@ layout_superblocks (void)
     {
       edge_iterator ei;
       edge e, best = NULL;
-      while (end->rbi->next)
-       end = end->rbi->next;
+      while (end->aux)
+       end = end->aux;
 
       FOR_EACH_EDGE (e, ei, end->succs)
        if (e->dest != EXIT_BLOCK_PTR
            && e->dest != single_succ (ENTRY_BLOCK_PTR)
-           && !e->dest->rbi->visited
+           && !e->dest->il.rtl->visited
            && (!best || EDGE_FREQUENCY (e) > EDGE_FREQUENCY (best)))
          best = e;
 
       if (best)
        {
-         end->rbi->next = best->dest;
-         best->dest->rbi->visited = 1;
+         end->aux = best->dest;
+         best->dest->il.rtl->visited = 1;
        }
       else
        for (; bb != EXIT_BLOCK_PTR; bb = bb->next_bb)
          {
-           if (!bb->rbi->visited)
+           if (!bb->il.rtl->visited)
              {
-               end->rbi->next = bb;
-               bb->rbi->visited = 1;
+               end->aux = bb;
+               bb->il.rtl->visited = 1;
                break;
              }
          }
@@ -362,11 +363,9 @@ layout_superblocks (void)
 void
 tracer (unsigned int flags)
 {
-  if (n_basic_blocks <= 1)
+  if (n_basic_blocks <= NUM_FIXED_BLOCKS + 1)
     return;
 
-  timevar_push (TV_TRACER);
-
   cfg_layout_initialize (flags);
   mark_dfs_back_edges ();
   if (dump_file)
@@ -379,6 +378,39 @@ tracer (unsigned int flags)
 
   /* Merge basic blocks in duplicated traces.  */
   cleanup_cfg (CLEANUP_EXPENSIVE);
+}
+\f
+static bool
+gate_handle_tracer (void)
+{
+  return (optimize > 0 && flag_tracer);
+}
 
-  timevar_pop (TV_TRACER);
+/* Run tracer.  */
+static void
+rest_of_handle_tracer (void)
+{
+  if (dump_file)
+    dump_flow_info (dump_file);
+  tracer (0);
+  cleanup_cfg (CLEANUP_EXPENSIVE);
+  reg_scan (get_insns (), max_reg_num ());
 }
+
+struct tree_opt_pass pass_tracer =
+{
+  "tracer",                             /* name */
+  gate_handle_tracer,                   /* gate */
+  rest_of_handle_tracer,                /* execute */
+  NULL,                                 /* sub */
+  NULL,                                 /* next */
+  0,                                    /* static_pass_number */
+  TV_TRACER,                            /* tv_id */
+  0,                                    /* properties_required */
+  0,                                    /* properties_provided */
+  0,                                    /* properties_destroyed */
+  0,                                    /* todo_flags_start */
+  TODO_dump_func,                       /* todo_flags_finish */
+  'T'                                   /* letter */
+};
+