X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fstat%2Ffirmstat.c;h=103e9d6ac91cc6c310697a08e9e4ca28cbb07d37;hb=f6aeac6a547a52beb3cb663c5e63c05c9c3728ea;hp=f665ee943061876dabd399c41464f811b8c4285e;hpb=602a065664be1be0038b551da457ce228207a80b;p=libfirm diff --git a/ir/stat/firmstat.c b/ir/stat/firmstat.c index f665ee943..103e9d6ac 100644 --- a/ir/stat/firmstat.c +++ b/ir/stat/firmstat.c @@ -597,10 +597,10 @@ static ir_op *stat_get_irn_op(ir_node *node) } /* if */ break; case iro_Sel: - if (get_irn_op(get_Sel_ptr(node)) == op_Sel) { + if (is_Sel(get_Sel_ptr(node))) { /* special case, a Sel of a Sel, count on extra counter */ op = status->op_SelSel ? status->op_SelSel : op; - if (get_irn_op(get_Sel_ptr(get_Sel_ptr(node))) == op_Sel) { + if (is_Sel(get_Sel_ptr(get_Sel_ptr(node)))) { /* special case, a Sel of a Sel of a Sel, count on extra counter */ op = status->op_SelSelSel ? status->op_SelSelSel : op; } /* if */ @@ -722,7 +722,7 @@ static void update_extbb_info(ir_node *node, graph_entry_t *graph) cnt_inc(&eb_entry->cnt[bcnt_nodes]); /* don't count keep-alive edges */ - if (get_irn_op(node) == op_End) + if (is_End(node)) return; arity = get_irn_arity(node); @@ -804,7 +804,7 @@ static void stat_update_call(ir_node *call, graph_entry_t *graph) /* found a call, this function is not a leaf */ graph->is_leaf = 0; - if (get_irn_op(ptr) == op_SymConst) { + if (is_SymConst(ptr)) { if (get_SymConst_kind(ptr) == symconst_addr_ent) { /* ok, we seems to know the entity */ ent = get_SymConst_entity(ptr); @@ -872,7 +872,7 @@ static void stat_update_call_2(ir_node *call, graph_entry_t *graph) if (is_Bad(block)) return; - if (get_irn_op(ptr) == op_SymConst) { + if (is_SymConst(ptr)) { if (get_SymConst_kind(ptr) == symconst_addr_ent) { /* ok, we seems to know the entity */ ent = get_SymConst_entity(ptr); @@ -989,12 +989,6 @@ static void update_node_stat(ir_node *node, void *env) /* handle statistics for special node types */ switch (op->code) { - case iro_Const: - if (status->stat_options & FIRMSTAT_COUNT_CONSTS) { - /* check properties of constants */ - stat_update_const(status, node, graph); - } /* if */ - break; case iro_Call: /* check for properties that depends on calls like recursion/leaf/indirect call */ stat_update_call(node, graph); @@ -1010,6 +1004,20 @@ static void update_node_stat(ir_node *node, void *env) default: ; } /* switch */ + + /* we want to count the constant IN nodes, not the CSE'ed constant's itself */ + if (status->stat_options & FIRMSTAT_COUNT_CONSTS) { + int i; + + for (i = get_irn_arity(node) - 1; i >= 0; --i) { + ir_node *pred = get_irn_n(node, i); + + if (is_Const(pred)) { + /* check properties of constants */ + stat_update_const(status, pred, graph); + } /* if */ + } /* for */ + } /* if */ } /* update_node_stat */ /** @@ -1291,15 +1299,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 */ @@ -1653,14 +1659,15 @@ static void stat_irg_block_walk(void *ctx, ir_graph *irg, ir_node *node, generic * @param kind the optimization kind */ static void removed_due_opt(ir_node *n, hmap_opt_entry_t *hmap, hook_opt_kind kind) { - ir_op *op = stat_get_irn_op(n); - opt_entry_t *entry = opt_get_entry(op, hmap); + opt_entry_t *entry; + ir_op *op = stat_get_irn_op(n); /* ignore CSE for Constants */ if (kind == HOOK_OPT_CSE && (is_Const(n) || is_SymConst(n))) return; /* increase global value */ + entry = opt_get_entry(op, hmap); cnt_inc(&entry->count); } /* removed_due_opt */ @@ -2177,8 +2184,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;