X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fana%2Fexecfreq.c;h=c6cbf1ecc85cb065620a10dd3a962e0f303348c6;hb=1552a7cecf3066be6397e8d8ed64cbfa505efd56;hp=37ce2d9600d7df18c65da709af7aa2d3fbe8b586;hpb=fc2759fa267ba4b074c2ac570c1b9d47cc943612;p=libfirm diff --git a/ir/ana/execfreq.c b/ir/ana/execfreq.c index 37ce2d960..c6cbf1ecc 100644 --- a/ir/ana/execfreq.c +++ b/ir/ana/execfreq.c @@ -24,9 +24,7 @@ * @date 28.05.2006 * @version $Id$ */ -#ifdef HAVE_CONFIG_H #include "config.h" -#endif #include #include @@ -163,10 +161,9 @@ solve_lgs(gs_matrix_t *mat, double *x, int size) #ifdef COMPARE_AGAINST_GAUSSJORDAN { - double *nw = xmalloc(size * size * sizeof(*nw)); - double *nx = xmalloc(size * sizeof(*nx)); + double *nw = XMALLOCN(double, size * size); + double *nx = XMALLOCNZ(double, size); - memset(nx, 0, size * sizeof(*nx)); gs_matrix_export(mat, nw, size); stat_ev_tim_push(); @@ -184,13 +181,19 @@ solve_lgs(gs_matrix_t *mat, double *x, int size) static double get_cf_probability(ir_node *bb, int pos, double loop_weight) { - double sum = 0.0; - double cur = 0.0; - const ir_node *pred = get_Block_cfgpred_block(bb, pos); - const ir_loop *pred_loop = get_irn_loop(pred); - int pred_depth = get_loop_depth(pred_loop); + double sum = 0.0; + double cur = 0.0; + const ir_node *pred = get_Block_cfgpred_block(bb, pos); + const ir_loop *pred_loop; + int pred_depth; const ir_edge_t *edge; + if (is_Bad(pred)) + return 0; + + pred_loop = get_irn_loop(pred); + pred_depth = get_loop_depth(pred_loop); + cur = get_loop_depth(get_irn_loop(bb)) < get_loop_depth(get_irn_loop(pred)) ? 1.0 : loop_weight; foreach_block_succ(pred, edge) { @@ -213,8 +216,7 @@ static void exec_freq_node_info(void *ctx, FILE *f, const ir_node *irn) ir_exec_freq *create_execfreq(ir_graph *irg) { - ir_exec_freq *execfreq = xmalloc(sizeof(execfreq[0])); - memset(execfreq, 0, sizeof(execfreq[0])); + ir_exec_freq *execfreq = XMALLOCZ(ir_exec_freq); execfreq->set = new_set(cmp_freq, 32); memset(&execfreq->hook, 0, sizeof(execfreq->hook)); @@ -258,8 +260,7 @@ compute_execfreq(ir_graph * irg, double loop_weight) * => they can "flow" from start to end. */ dfs = dfs_new(&absgraph_irg_cfg_succ, irg); - ef = xmalloc(sizeof(ef[0])); - memset(ef, 0, sizeof(ef[0])); + ef = XMALLOCZ(ir_exec_freq); ef->min_non_zero = HUGE_VAL; /* initialize with a reasonable large number. */ freqs = ef->set = new_set(cmp_freq, dfs_get_n_nodes(dfs)); @@ -275,7 +276,7 @@ compute_execfreq(ir_graph * irg, double loop_weight) size = dfs_get_n_nodes(dfs); mat = gs_new_matrix(size, size); - x = xmalloc(size*sizeof(*x)); + x = XMALLOCN(double, size); for (idx = dfs_get_n_nodes(dfs) - 1; idx >= 0; --idx) { ir_node *bb = (ir_node *) dfs_get_post_num_node(dfs, size - idx - 1); @@ -285,13 +286,13 @@ compute_execfreq(ir_graph * irg, double loop_weight) freq = set_insert_freq(freqs, bb); freq->idx = idx; - gs_matrix_set(mat, idx, idx, -1.0); for(i = get_Block_n_cfgpreds(bb) - 1; i >= 0; --i) { ir_node *pred = get_Block_cfgpred_block(bb, i); int pred_idx = size - dfs_get_post_num(dfs, pred) - 1; gs_matrix_set(mat, idx, pred_idx, get_cf_probability(bb, i, loop_weight)); } + gs_matrix_set(mat, idx, idx, -1.0); } dfs_free(dfs);