used new set_irg_doms_inconsistent() to invalidate dom and postdom
[libfirm] / ir / stat / stat_dmp.c
index 6ed10e0..c2f97d9 100644 (file)
@@ -137,6 +137,9 @@ static void simple_dump_opt_hash(dumper_t *dmp, pset *set, int index)
  */
 static void simple_dump_real_func_calls(dumper_t *dmp, counter_t *cnt)
 {
+  if (! dmp->f)
+    return;
+
   if (! cnt_eq(cnt, 0)) {
     fprintf(dmp->f, "\nReal Function Calls optimized:\n");
     fprintf(dmp->f, "%-16s %8u\n",
@@ -149,6 +152,9 @@ static void simple_dump_real_func_calls(dumper_t *dmp, counter_t *cnt)
  */
 static void simple_dump_tail_recursion(dumper_t *dmp, unsigned num_tail_recursion)
 {
+  if (! dmp->f)
+    return;
+
   if (num_tail_recursion > 0) {
     fprintf(dmp->f, "\nTail recursion optimized:\n");
     fprintf(dmp->f, "%-16s %8u\n", "Call", num_tail_recursion);
@@ -160,6 +166,9 @@ static void simple_dump_tail_recursion(dumper_t *dmp, unsigned num_tail_recursio
  */
 static void simple_dump_edges(dumper_t *dmp, counter_t *cnt)
 {
+  if (! dmp->f)
+    return;
+
   fprintf(dmp->f, "%-16s %8d\n", "Edges", cnt->cnt[0]);
 }
 
@@ -170,6 +179,10 @@ static void simple_dump_graph(dumper_t *dmp, graph_entry_t *entry)
 {
   int i, dump_opts = 1;
   block_entry_t *b_entry;
+  extbb_entry_t *eb_entry;
+
+  if (! dmp->f)
+    return;
 
   if (entry->irg) {
     ir_graph *const_irg = get_const_code_irg();
@@ -237,7 +250,7 @@ static void simple_dump_graph(dumper_t *dmp, graph_entry_t *entry)
     for (b_entry = pset_first(entry->block_hash);
               b_entry;
               b_entry = pset_next(entry->block_hash)) {
-      fprintf(dmp->f, "BLK %12ld %12u %12u %12u %12u %12u %4.8f\n",
+      fprintf(dmp->f, "BLK   %6ld %12u %12u %12u %12u %12u %4.8f\n",
              b_entry->block_nr,
              b_entry->cnt_nodes.cnt[0],
              b_entry->cnt_edges.cnt[0],
@@ -247,6 +260,24 @@ static void simple_dump_graph(dumper_t *dmp, graph_entry_t *entry)
              (double)b_entry->cnt_edges.cnt[0] / (double)b_entry->cnt_nodes.cnt[0]
       );
     }
+
+    if (dmp->status->stat_options & FIRMSTAT_COUNT_EXTBB) {
+      /* dump extended block info */
+      fprintf(dmp->f, "\n%12s %12s %12s %12s %12s %12s %12s\n", "Extbb Nr", "Nodes", "intern E", "incoming E", "outgoing E", "Phi", "quot");
+      for (eb_entry = pset_first(entry->extbb_hash);
+           eb_entry;
+           eb_entry = pset_next(entry->extbb_hash)) {
+        fprintf(dmp->f, "ExtBB %6ld %12u %12u %12u %12u %12u %4.8f\n",
+          eb_entry->block_nr,
+          eb_entry->cnt_nodes.cnt[0],
+          eb_entry->cnt_edges.cnt[0],
+          eb_entry->cnt_in_edges.cnt[0],
+          eb_entry->cnt_out_edges.cnt[0],
+          eb_entry->cnt_phi_data.cnt[0],
+          (double)eb_entry->cnt_edges.cnt[0] / (double)eb_entry->cnt_nodes.cnt[0]
+        );
+      }
+    }
   }
 }
 
@@ -258,6 +289,9 @@ static void simple_dump_const_tbl(dumper_t *dmp, const constant_info_t *tbl)
   int i;
   counter_t sum;
 
+  if (! dmp->f)
+    return;
+
   cnt_clr(&sum);
 
   fprintf(dmp->f, "\nConstant Information:\n");
@@ -296,6 +330,9 @@ static void simple_init(dumper_t *dmp, const char *name)
 
   snprintf(fname, sizeof(fname), "%s.txt", name);
   dmp->f = fopen(fname, "w");
+  if (! dmp->f) {
+    perror(fname);
+  }
 }
 
 /**
@@ -303,7 +340,8 @@ static void simple_init(dumper_t *dmp, const char *name)
  */
 static void simple_finish(dumper_t *dmp)
 {
-  fclose(dmp->f);
+  if (dmp->f)
+    fclose(dmp->f);
   dmp->f = NULL;
 }
 
@@ -364,9 +402,11 @@ static void csv_count_nodes(dumper_t *dmp, graph_entry_t *graph, counter_t cnt[]
 static void csv_dump_graph(dumper_t *dmp, graph_entry_t *entry)
 {
   const char *name;
-
   counter_t cnt[4];
 
+  if (! dmp->f)
+    return;
+
   if (entry->irg && !entry->is_deleted) {
     ir_graph *const_irg = get_const_code_irg();
 
@@ -411,6 +451,9 @@ static void csv_init(dumper_t *dmp, const char *name)
 
   snprintf(fname, sizeof(fname), "%s.csv", name);
   dmp->f = fopen(fname, "a");
+  if (! dmp->f) {
+    perror(fname);
+  }
 }
 
 /**
@@ -418,7 +461,8 @@ static void csv_init(dumper_t *dmp, const char *name)
  */
 static void csv_finish(dumper_t *dmp)
 {
-  fclose(dmp->f);
+  if (dmp->f)
+    fclose(dmp->f);
   dmp->f = NULL;
 }