From: Matthias Braun Date: Wed, 1 Aug 2012 16:20:18 +0000 (+0200) Subject: fix bugs in execfreq rework commit X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=3102cb5322441e0003150ff47e221869966f7c36;p=libfirm fix bugs in execfreq rework commit --- diff --git a/ir/ana/execfreq.c b/ir/ana/execfreq.c index be752dd3d..519d90c0c 100644 --- a/ir/ana/execfreq.c +++ b/ir/ana/execfreq.c @@ -90,7 +90,9 @@ static void exec_freq_node_info(void *ctx, FILE *f, const ir_node *irn) (void)ctx; if (!is_Block(irn)) return; - fprintf(f, "execution frequency: %g\n", get_block_execfreq(irn)); + const freq_t *freq = ir_nodehashmap_get(freq_t, &freq_map, irn); + if (freq != NULL) + fprintf(f, "execution frequency: %g\n", get_block_execfreq(irn)); } void init_execfreq(void) @@ -272,7 +274,7 @@ void ir_estimate_execfreq(ir_graph *irg) ir_node *end_block = get_irg_end_block(irg); - for (int idx = dfs_get_n_nodes(dfs) - 1; idx >= 0; --idx) { + for (int idx = size - 1; idx >= 0; --idx) { const ir_node *bb = (ir_node*)dfs_get_post_num_node(dfs, size-idx-1); /* Sum of (execution frequency of predecessor * probability of cf edge) ... */ @@ -330,7 +332,7 @@ void ir_estimate_execfreq(ir_graph *irg) double start_freq = x[start_idx]; double norm = start_freq != 0.0 ? 1.0 / start_freq : 1.0; - for (int idx = dfs_get_n_nodes(dfs) - 1; idx >= 0; --idx) { + for (int idx = size - 1; idx >= 0; --idx) { ir_node *bb = (ir_node *) dfs_get_post_num_node(dfs, size - idx - 1); /* take abs because it sometimes can be -0 in case of endless loops */ diff --git a/ir/be/betranshlp.c b/ir/be/betranshlp.c index c1023f02d..24feebe88 100644 --- a/ir/be/betranshlp.c +++ b/ir/be/betranshlp.c @@ -37,6 +37,7 @@ #include "trouts.h" #include "cgana.h" #include "debug.h" +#include "execfreq_t.h" #include "beirg.h" #include "beabi.h" @@ -114,6 +115,10 @@ static ir_node *transform_block(ir_node *node) copy_node_attr(irg, node, block); block->node_nr = node->node_nr; + /* transfer execfreq value */ + double execfreq = get_block_execfreq(node); + set_block_execfreq(block, execfreq); + /* put the preds in the worklist */ be_enqueue_preds(node);