First full implementation with LFTR
[libfirm] / ir / stat / firmstat.c
index d03ab24..5116496 100644 (file)
@@ -863,7 +863,8 @@ static void update_node_stat(ir_node *node, void *env)
 
   /* count extended block edges */
   if (status->stat_options & FIRMSTAT_COUNT_EXTBB) {
-    undate_extbb_info(node, graph);
+    if (graph->irg != get_const_code_irg())
+      undate_extbb_info(node, graph);
   }
 
   /* handle statistics for special node types */
@@ -1006,16 +1007,17 @@ static void update_graph_stat(graph_entry_t *global, graph_entry_t *graph)
   graph->block_hash = new_pset(block_cmp, 5);
 
   /* we need dominator info */
-  if (graph->irg != get_const_code_irg())
+  if (graph->irg != get_const_code_irg()) {
     if (get_irg_dom_state(graph->irg) != dom_consistent)
       compute_doms(graph->irg);
 
-  if (status->stat_options & FIRMSTAT_COUNT_EXTBB) {
-    /* we need extended basic blocks */
-    compute_extbb(graph->irg);
+    if (status->stat_options & FIRMSTAT_COUNT_EXTBB) {
+      /* we need extended basic blocks */
+      compute_extbb(graph->irg);
 
-    /* create new extbb counter */
-    graph->extbb_hash = new_pset(block_cmp, 5);
+      /* create new extbb counter */
+      graph->extbb_hash = new_pset(block_cmp, 5);
+    }
   }
 
   /* count the nodes in the graph */
@@ -1718,14 +1720,14 @@ void stat_be_block_sched_ready(ir_graph *irg, ir_node *block, int num_ready)
 /**
  * Update the permutation statistic of a block
  *
- * @param ctx        the hook context
  * @param class_name the name of the register class
+ * @param n_regs     number of registers in the register class
  * @param perm       the perm node
  * @param block      the block containing the perm
  * @param size       the size of the perm
  * @param real_size  number of pairs with different registers
  */
-void stat_be_block_stat_perm(void *ctx, const char *class_name, int n_regs, ir_node *perm, ir_node *block,
+void stat_be_block_stat_perm(const char *class_name, int n_regs, ir_node *perm, ir_node *block,
                              int size, int real_size)
 {
   if (! status->stat_options)
@@ -1754,7 +1756,6 @@ void stat_be_block_stat_perm(void *ctx, const char *class_name, int n_regs, ir_n
 /**
  * Update the permutation statistic of a single perm
  *
- * @param ctx        the hook context
  * @param class_name the name of the register class
  * @param perm       the perm node
  * @param block      the block containing the perm
@@ -1762,7 +1763,7 @@ void stat_be_block_stat_perm(void *ctx, const char *class_name, int n_regs, ir_n
  * @param size       length of the cycle/chain
  * @param n_ops      the number of ops representing this cycle/chain after lowering
  */
-void stat_be_block_stat_permcycle(void *ctx, const char *class_name, ir_node *perm, ir_node *block,
+void stat_be_block_stat_permcycle(const char *class_name, ir_node *perm, ir_node *block,
                                   int is_chain, int size, int n_ops)
 {
   if (! status->stat_options)
@@ -1954,8 +1955,6 @@ void firm_init_stat(unsigned enable_options)
   HOOK(hook_func_call,                          stat_func_call);
   HOOK(hook_arch_dep_replace_mul_with_shifts,   stat_arch_dep_replace_mul_with_shifts);
   HOOK(hook_arch_dep_replace_division_by_const, stat_arch_dep_replace_division_by_const);
-  HOOK(hook_be_block_stat_perm,                 stat_be_block_stat_perm);
-  HOOK(hook_be_block_stat_permcycle,            stat_be_block_stat_permcycle);
 
   obstack_init(&status->cnts);
   obstack_init(&status->be_data);
@@ -2051,6 +2050,11 @@ void stat_term(void) {
   }
 }
 
+/* returns 1 if statistics were initialized, 0 otherwise */
+int stat_is_active(void) {
+  return status != (stat_info_t *)&status_disable;
+}
+
 #else
 
 /* initialize the statistics module. */