put execfreq in block-attrs instead of hashmap
authorMatthias Braun <matthias.braun@kit.edu>
Thu, 23 Aug 2012 09:00:58 +0000 (11:00 +0200)
committerMatthias Braun <matthias.braun@kit.edu>
Thu, 23 Aug 2012 11:33:13 +0000 (13:33 +0200)
The hashmap used to point to blocks which have already been deleted.

ir/ana/execfreq.c
ir/ir/irtypes.h

index 519d90c..35c5c65 100644 (file)
 
 #define MAX_INT_FREQ 1000000
 
-typedef struct freq_t {
-       double freq;
-} freq_t;
-
-static ir_nodehashmap_t freq_map;
-static struct obstack   obst;
-static hook_entry_t     hook;
+static hook_entry_t hook;
 
 double get_block_execfreq(const ir_node *block)
 {
-       const freq_t *freq = ir_nodehashmap_get(freq_t, &freq_map, block);
-       if (freq == NULL)
-               return 0.0;
-       return freq->freq;
+       return block->attr.block.execfreq;
 }
 
 void set_block_execfreq(ir_node *block, double newfreq)
 {
-       freq_t *freq = ir_nodehashmap_get(freq_t, &freq_map, block);
-       if (freq == NULL) {
-               freq = OALLOC(&obst, freq_t);
-               ir_nodehashmap_insert(&freq_map, block, freq);
-       }
-       freq->freq = newfreq;
+       block->attr.block.execfreq = newfreq;
 }
 
 static void exec_freq_node_info(void *ctx, FILE *f, const ir_node *irn)
@@ -90,16 +76,13 @@ static void exec_freq_node_info(void *ctx, FILE *f, const ir_node *irn)
        (void)ctx;
        if (!is_Block(irn))
                return;
-       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));
+       double freq = get_block_execfreq(irn);
+       if (freq != 0.0)
+               fprintf(f, "execution frequency: %g\n", freq);
 }
 
 void init_execfreq(void)
 {
-       ir_nodehashmap_init(&freq_map);
-       obstack_init(&obst);
-
        memset(&hook, 0, sizeof(hook));
        hook.hook._hook_node_info = exec_freq_node_info;
        register_hook(hook_node_info, &hook);
@@ -108,9 +91,6 @@ void init_execfreq(void)
 void exit_execfreq(void)
 {
        unregister_hook(hook_node_info, &hook);
-
-       obstack_free(&obst, NULL);
-       ir_nodehashmap_destroy(&freq_map);
 }
 
 
index eeff0db..d4dddf8 100644 (file)
@@ -209,6 +209,7 @@ typedef struct block_attr {
        bitset_t *backedge;         /**< Bitfield n set to true if pred n is backedge.*/
        ir_entity *entity;          /**< entitiy representing this block */
        ir_node  *phis;             /**< The list of Phi nodes in this block. */
+       double    execfreq;         /**< block execution frequency */
 } block_attr;
 
 /** Cond attributes. */