X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fstat%2Ffirmstat.c;h=55f61937ca35cf8c7ffab60dc35e7adae6e3d5f6;hb=00ac040bae07059a0dc7ed804c424702a1fcaa36;hp=521fa037b215b967b26cc5a379c9cb54624fc468;hpb=4b1138a9eee25ce11adbb7d7162eaa49421e8b51;p=libfirm diff --git a/ir/stat/firmstat.c b/ir/stat/firmstat.c index 521fa037b..55f61937c 100644 --- a/ir/stat/firmstat.c +++ b/ir/stat/firmstat.c @@ -23,9 +23,7 @@ * @author Michael Beck * @version $Id$ */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif +#include "config.h" #ifdef FIRM_STATISTICS @@ -212,6 +210,7 @@ static void opcode_clear_entry(node_entry_t *elem) { cnt_clr(&elem->cnt_alive); cnt_clr(&elem->new_node); cnt_clr(&elem->into_Id); + cnt_clr(&elem->normalized); } /* opcode_clear_entry */ /** @@ -970,7 +969,7 @@ static void update_node_stat(ir_node *node, void *env) node_entry_t *entry; ir_op *op = stat_get_irn_op(node); - int arity = get_irn_arity(node); + int i, arity = get_irn_arity(node); entry = opcode_get_entry(op, graph->opcode_hash); @@ -1001,6 +1000,16 @@ static void update_node_stat(ir_node *node, void *env) /* check address properties */ stat_update_address(get_Store_ptr(node), graph); break; + case iro_Phi: + /* check for non-strict Phi nodes */ + for (i = arity - 1; i >= 0; --i) { + ir_node *pred = get_Phi_pred(node, i); + if (is_Unknown(pred)) { + /* found an Unknown predecessor, graph is not strict */ + graph->is_strict = 0; + break; + } + } default: ; } /* switch */ @@ -1186,6 +1195,7 @@ static void update_graph_stat(graph_entry_t *global, graph_entry_t *graph) graph->is_leaf_call = LCS_UNKNOWN; graph->is_recursive = 0; graph->is_chain_call = 1; + graph->is_strict = 1; /* create new block counter */ graph->block_hash = new_pset(block_cmp, 5); @@ -1299,15 +1309,13 @@ static void update_graph_stat_2(graph_entry_t *global, graph_entry_t *graph) * Register a dumper. */ static void stat_register_dumper(const dumper_t *dumper) { - dumper_t *p = xmalloc(sizeof(*p)); + dumper_t *p = XMALLOC(dumper_t); - if (p) { - memcpy(p, dumper, sizeof(*p)); + memcpy(p, dumper, sizeof(*p)); - p->next = status->dumper; - p->status = status; - status->dumper = p; - } + p->next = status->dumper; + p->status = status; + status->dumper = p; /* FIXME: memory leak */ } /* stat_register_dumper */ @@ -1529,6 +1537,36 @@ static void stat_turn_into_id(void *ctx, ir_node *node) { STAT_LEAVE; } /* stat_turn_into_id */ +/** + * Hook: A node is normalized + * + * @param ctx the hook context + * @param node the IR node that was normalized + */ +static void stat_normalize(void *ctx, ir_node *node) { + (void) ctx; + if (! status->stat_options) + return; + + STAT_ENTER; + { + node_entry_t *entry; + graph_entry_t *graph; + ir_op *op = stat_get_irn_op(node); + + /* increase global value */ + graph = graph_get_entry(NULL, status->irg_hash); + entry = opcode_get_entry(op, graph->opcode_hash); + cnt_inc(&entry->normalized); + + /* increase local value */ + graph = graph_get_entry(current_ir_graph, status->irg_hash); + entry = opcode_get_entry(op, graph->opcode_hash); + cnt_inc(&entry->normalized); + } + STAT_LEAVE; +} /* stat_normalize */ + /** * Hook: A new graph was created * @@ -1552,6 +1590,7 @@ static void stat_new_graph(void *ctx, ir_graph *irg, ir_entity *ent) { graph->is_leaf_call = 0; graph->is_recursive = 0; graph->is_chain_call = 0; + graph->is_strict = 1; graph->is_analyzed = 0; } STAT_LEAVE; @@ -2186,8 +2225,7 @@ void firm_init_stat(unsigned enable_options) if (! (enable_options & FIRMSTAT_ENABLED)) return; - status = xmalloc(sizeof(*status)); - memset(status, 0, sizeof(*status)); + status = XMALLOCZ(stat_info_t); /* enable statistics */ status->stat_options = enable_options & FIRMSTAT_ENABLED ? enable_options : 0; @@ -2197,6 +2235,7 @@ void firm_init_stat(unsigned enable_options) HOOK(hook_free_ir_op, stat_free_ir_op); HOOK(hook_new_node, stat_new_node); HOOK(hook_turn_into_id, stat_turn_into_id); + HOOK(hook_normalize, stat_normalize); HOOK(hook_new_graph, stat_new_graph); HOOK(hook_free_graph, stat_free_graph); HOOK(hook_irg_walk, stat_irg_walk);