X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fana%2Fexecfreq.c;h=41909a6843cfb7df6314d753d021db1797ce71d5;hb=f6aeac6a547a52beb3cb663c5e63c05c9c3728ea;hp=1bcf3e6fe8d8d82afb5de1419df5b15b710f3b03;hpb=9e32d446edc895d0a6a8033352376bfc20002790;p=libfirm diff --git a/ir/ana/execfreq.c b/ir/ana/execfreq.c index 1bcf3e6fe..41909a684 100644 --- a/ir/ana/execfreq.c +++ b/ir/ana/execfreq.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved. + * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. * * This file is part of libFirm. * @@ -152,7 +152,6 @@ solve_lgs(gs_matrix_t *mat, double *x, int size) for (i = 0; i < size; ++i) x[i] = init; - gs_matrix_dump(mat, size, size, stderr); stat_ev_dbl("execfreq_matrix_size", size); stat_ev_tim_push(); do { @@ -164,10 +163,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(); @@ -214,8 +212,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)); @@ -259,8 +256,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)); @@ -272,15 +268,11 @@ compute_execfreq(ir_graph * irg, double loop_weight) irg_block_walk_graph(irg, collect_blocks, NULL, freqs); construct_cf_backedges(irg); - /* TODO: edges are corrupt for EDGE_KIND_BLOCK after the local optimize - graph phase merges blocks in the x86 backend */ - edges_deactivate(irg); - edges_activate(irg); - /* edges_assure(irg); */ + edges_assure(irg); 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); @@ -290,15 +282,17 @@ 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); + /* * Add a loop from end to start. * The problem is then an eigenvalue problem: