Adapted to stat events
authorSebastian Hack <hack@ipd.info.uni-karlsruhe.de>
Thu, 21 Jun 2007 16:43:15 +0000 (16:43 +0000)
committerSebastian Hack <hack@ipd.info.uni-karlsruhe.de>
Thu, 21 Jun 2007 16:43:15 +0000 (16:43 +0000)
Fixed a bug in liveness

[r14701]

18 files changed:
ir/be/be_t.h
ir/be/bechordal.c
ir/be/bechordal_main.c
ir/be/beilpsched.c
ir/be/belistsched.c
ir/be/belistsched.h
ir/be/belive.c
ir/be/belive_t.h
ir/be/belower.c
ir/be/bemain.c
ir/be/beschedtrace.c
ir/be/bespill.c
ir/be/bespillslots.c
ir/be/bessadestr.c
ir/be/bestat.c
ir/be/bestatevent.c [deleted file]
ir/be/bestatevent.h
ir/be/betranshlp.c

index 74f0a8e..048ce53 100644 (file)
@@ -72,7 +72,7 @@ struct be_options_t {
        int  scheduler;           /**< the scheduler */
        char ilp_server[128];     /**< the ilp server name */
        char ilp_solver[128];     /**< the ilp solver name */
-       char stat_file_name[256]; /**< name of the file where the statistics are put to */
+       int  statev;              /**< enable stat event dumping */
 };
 
 struct be_main_env_t {
index 74ccaac..b77323e 100644 (file)
@@ -740,11 +740,10 @@ static void pressure(ir_node *block, void *env_ptr)
        be_lv_t *lv                       = env->birg->lv;
 
        int i, n;
+       bitset_pos_t elm;
        unsigned step = 0;
        unsigned pressure = 0;
        struct list_head *head;
-       pset *live_in  = be_lv_pset_put_in(lv, block, pset_new_ptr_default());
-       pset *live_end = be_lv_pset_put_end(lv, block, pset_new_ptr_default());
 
        DBG((dbg, LEVEL_1, "Computing pressure in block %+F\n", block));
        bitset_clear_all(live);
@@ -759,7 +758,8 @@ static void pressure(ir_node *block, void *env_ptr)
         * Make final uses of all values live out of the block.
         * They are necessary to build up real intervals.
         */
-       foreach_pset(live_end, irn) {
+       be_lv_foreach(lv, block, be_lv_state_end, i) {
+               ir_node *irn = be_lv_get_irn(lv, block, i);
                if(has_reg_class(env, irn)) {
                        DBG((dbg, LEVEL_3, "\tMaking live: %+F/%d\n", irn, get_irn_idx(irn)));
                        bitset_set(live, get_irn_idx(irn));
@@ -831,22 +831,11 @@ static void pressure(ir_node *block, void *env_ptr)
                ++step;
        }
 
-       /*
-        * Add initial defs for all values live in.
-        */
-       foreach_pset(live_in, irn) {
-               if(has_reg_class(env, irn)) {
-
-                       /* Mark the value live in. */
-                       bitset_set(live, get_irn_idx(irn));
-
-                       /* Add the def */
+       bitset_foreach(live, elm) {
+               ir_node *irn = get_idx_irn(env->irg, elm);
+               if (be_is_live_in(lv, block, irn))
                        border_def(irn, step, 0);
-               }
        }
-
-       del_pset(live_in);
-       del_pset(live_end);
 }
 
 static void assign(ir_node *block, void *env_ptr)
index d570aff..962f6f8 100644 (file)
@@ -401,16 +401,11 @@ static void pre_spill(const arch_isa_t *isa, int cls_idx, post_spill_env_t *pse)
        chordal_env->border_heads  = pmap_create();
        chordal_env->ignore_colors = bitset_malloc(chordal_env->cls->n_regs);
 
-#ifdef FIRM_STATISTICS
-       if (be_stat_ev_is_active()) {
-               be_stat_tags[STAT_TAG_CLS] = pse->cls->name;
-               be_stat_ev_push(be_stat_tags, STAT_TAG_LAST, be_stat_file);
-
-               /* perform some node statistics. */
-               node_stats(birg, pse->cls, &node_stat);
-               be_stat_ev("phis_before_spill", node_stat.n_phis);
-       }
-#endif /* FIRM_STATISTICS */
+       be_assure_liveness(birg);
+       be_liveness_assure_chk(be_get_birg_liveness(birg));
+       stat_ev_ctx_push("cls", pse->cls->name);
+       stat_ev_dbl("phis_before_spill", node_stat.n_phis);
+       stat_ev_do(node_stats(birg, pse->cls, &node_stat));
 
        /* put all ignore registers into the ignore register set. */
        be_put_ignore_regs(birg, pse->cls, chordal_env->ignore_colors);
@@ -418,13 +413,7 @@ static void pre_spill(const arch_isa_t *isa, int cls_idx, post_spill_env_t *pse)
        be_pre_spill_prepare_constr(chordal_env);
        dump(BE_CH_DUMP_CONSTR, birg->irg, pse->cls, "-constr-pre", dump_ir_block_graph_sched);
 
-#ifdef FIRM_STATISTICS
-       if (be_stat_ev_is_active()) {
-               pse->pre_spill_cost = be_estimate_irg_costs(birg->irg,
-                       birg->main_env->arch_env, birg->exec_freq);
-               be_stat_ev_pop();
-       }
-#endif /* FIRM_STATISTICS */
+       stat_ev_ctx_pop();
 }
 
 /**
@@ -443,22 +432,13 @@ static void post_spill(post_spill_env_t *pse, int iteration) {
        /* some special classes contain only ignore regs, no work to be done */
        if (allocatable_regs > 0) {
 
-#ifdef FIRM_STATISTICS
-               if (be_stat_ev_is_active()) {
-                       double spillcosts = be_estimate_irg_costs(irg, main_env->arch_env, birg->exec_freq) - pse->pre_spill_cost;
-
-                       be_stat_tags[STAT_TAG_CLS] = pse->cls->name;
-                       be_stat_ev_push(be_stat_tags, STAT_TAG_LAST, be_stat_file);
-
-                       be_stat_ev_l("spillcosts", (long) spillcosts);
-
-                       node_stats(birg, pse->cls, &node_stat);
-                       be_stat_ev("phis_after_spill", node_stat.n_phis);
-                       be_stat_ev("mem_phis", node_stat.n_mem_phis);
-                       be_stat_ev("reloads", node_stat.n_reloads);
-                       be_stat_ev("spills", node_stat.n_spills);
-               }
-#endif /* FIRM_STATISTICS */
+               stat_ev_ctx_push("cls", pse->cls->name);
+               stat_ev_do(node_stats(birg, pse->cls, &node_stat));
+               stat_ev_dbl("spillcosts", be_estimate_irg_costs(irg, main_env->arch_env, birg->exec_freq) - pse->pre_spill_cost);
+               stat_ev_dbl("phis_after_spill", node_stat.n_phis);
+               stat_ev_dbl("mem_phis", node_stat.n_mem_phis);
+               stat_ev_dbl("reloads", node_stat.n_reloads);
+               stat_ev_dbl("spills", node_stat.n_spills);
 
                /*
                        If we have a backend provided spiller, post spill is
@@ -496,20 +476,18 @@ static void post_spill(post_spill_env_t *pse, int iteration) {
                chordal_env->ifg = be_create_ifg(chordal_env);
                BE_TIMER_POP(ra_timer.t_ifg);
 
-#ifdef FIRM_STATISTICS
-               if (be_stat_ev_is_active()) {
+               {
                        be_ifg_stat_t stat;
 
-                       be_ifg_stat(birg, chordal_env->ifg, &stat);
-                       be_stat_ev("ifg_nodes", stat.n_nodes);
-                       be_stat_ev("ifg_edges", stat.n_edges);
-                       be_stat_ev("ifg_comps", stat.n_comps);
+                       stat_ev_do(be_ifg_stat(birg, chordal_env->ifg, &stat));
+                       stat_ev_dbl("ifg_nodes", stat.n_nodes);
+                       stat_ev_dbl("ifg_edges", stat.n_edges);
+                       stat_ev_dbl("ifg_comps", stat.n_comps);
 
-                       node_stats(birg, pse->cls, &node_stat);
-                       be_stat_ev("perms_before_coal", node_stat.n_perms);
-                       be_stat_ev("copies_before_coal", node_stat.n_copies);
+                       stat_ev_do(node_stats(birg, pse->cls, &node_stat));
+                       stat_ev_dbl("perms_before_coal", node_stat.n_perms);
+                       stat_ev_dbl("copies_before_coal", node_stat.n_copies);
                }
-#endif /* FIRM_STATISTICS */
 
                /* copy minimization */
                BE_TIMER_PUSH(ra_timer.t_copymin);
@@ -533,14 +511,10 @@ static void post_spill(post_spill_env_t *pse, int iteration) {
                }
                BE_TIMER_POP(ra_timer.t_verify);
 
-#ifdef FIRM_STATISTICS
-               if (be_stat_ev_is_active()) {
-                       node_stats(birg, pse->cls, &node_stat);
-                       be_stat_ev("perms_after_coal", node_stat.n_perms);
-                       be_stat_ev("copies_after_coal", node_stat.n_copies);
-                       be_stat_ev_pop();
-               }
-#endif /* FIRM_STATISTICS */
+               stat_ev_do(node_stats(birg, pse->cls, &node_stat));
+               stat_ev_dbl("perms_after_coal", node_stat.n_perms);
+               stat_ev_dbl("copies_after_coal", node_stat.n_copies);
+               stat_ev_ctx_pop();
 
                /* the ifg exists only if there are allocatable regs */
                be_ifg_free(chordal_env->ifg);
@@ -631,6 +605,9 @@ static void be_ra_chordal_main(be_irg_t *birg)
                }
        }
 
+       be_verify_register_allocation(main_env->arch_env, irg);
+
+
        BE_TIMER_PUSH(ra_timer.t_epilog);
        lower_nodes_after_ra(birg, options.lower_perm_opt & BE_CH_LOWER_PERM_COPY ? 1 : 0);
        dump(BE_CH_DUMP_LOWER, irg, NULL, "-belower-after-ra", dump_ir_block_graph_sched);
index 27d975f..7d9c6a5 100644 (file)
@@ -1901,7 +1901,7 @@ static void create_ilp(ir_node *block, void *walk_env) {
                DBG((env->dbg, LEVEL_1, "ILP to solve: %u variables, %u constraints\n", lpp->var_next, lpp->cst_next));
 
                /* debug stuff, dump lpp when debugging is on  */
-               DEBUG_ONLY(
+               DEBUG_ONLY_NICE {
                        if (firm_dbg_get_mask(env->dbg) > 1) {
                                char buf[1024];
                                FILE *f;
@@ -1913,7 +1913,7 @@ static void create_ilp(ir_node *block, void *walk_env) {
                                snprintf(buf, sizeof(buf), "lpp_block_%lu.mps", get_irn_node_nr(block));
                                lpp_dump(lpp, buf);
                        }
-               );
+               }
 
                /* set solve time limit */
                lpp_set_time_limit(lpp, env->opts->time_limit);
@@ -1944,7 +1944,7 @@ static void create_ilp(ir_node *block, void *walk_env) {
                        char buf[1024];
                        FILE *f;
 
-                       DEBUG_ONLY(
+                       DEBUG_ONLY_NICE {
                                if (firm_dbg_get_mask(env->dbg) >= 2) {
                                        snprintf(buf, sizeof(buf), "lpp_block_%lu.infeasible.txt", get_irn_node_nr(block));
                                        f = fopen(buf, "w");
@@ -1954,7 +1954,7 @@ static void create_ilp(ir_node *block, void *walk_env) {
                                        lpp_dump(lpp, buf);
                                        dump_ir_block_graph(env->irg, "-infeasible");
                                }
-                       )
+                       }
 
                        ir_fprintf(stderr, "ILP found no solution within time (%+F, %+F), falling back to heuristics.\n", block, env->irg);
                        need_heur = 1;
@@ -1973,36 +1973,24 @@ static void create_ilp(ir_node *block, void *walk_env) {
        }
 
        /* apply solution */
-#ifdef FIRM_STATISTICS
-       if (be_stat_ev_is_active()) {
-               be_stat_ev("nodes", ba->block_last_idx);
-               be_stat_ev("vars", lpp ? lpp->var_next : 0);
-               be_stat_ev("csts", lpp ? lpp->cst_next : 0);
-       }
-#endif /* FIRM_STATISTICS */
+       be_stat_ev("nodes", ba->block_last_idx);
+       be_stat_ev("vars", lpp ? lpp->var_next : 0);
+       be_stat_ev("csts", lpp ? lpp->cst_next : 0);
        if (need_heur) {
-#ifdef FIRM_STATISTICS
-               if (be_stat_ev_is_active()) {
                        be_stat_ev("time", -1);
                        be_stat_ev_dbl("opt", 0.0);
-               }
-#endif /* FIRM_STATISTICS */
                list_sched_single_block(env->birg, block, env->be_opts);
        }
        else {
-#ifdef FIRM_STATISTICS
-               if (be_stat_ev_is_active()) {
-                       if (lpp) {
-                               double opt = lpp->sol_state == lpp_optimal ? 100.0 : 100.0 * lpp->best_bound / lpp->objval;
-                               be_stat_ev_dbl("time", lpp->sol_time);
-                               be_stat_ev_dbl("opt", opt);
-                       }
-                       else {
-                               be_stat_ev_dbl("time", 0.0);
-                               be_stat_ev_dbl("opt", 100.0);
-                       }
+               if (lpp) {
+                       double opt = lpp->sol_state == lpp_optimal ? 100.0 : 100.0 * lpp->best_bound / lpp->objval;
+                       be_stat_ev_dbl("time", lpp->sol_time);
+                       be_stat_ev_dbl("opt", opt);
+               }
+               else {
+                       be_stat_ev_dbl("time", 0.0);
+                       be_stat_ev_dbl("opt", 100.0);
                }
-#endif /* FIRM_STATISTICS */
                apply_solution(env, lpp, block);
        }
 
@@ -2026,12 +2014,7 @@ void be_ilp_sched(const be_irg_t *birg, be_options_t *be_opts) {
 
        FIRM_DBG_REGISTER(env.dbg, "firm.be.sched.ilp");
 
-#ifdef FIRM_STATISTICS
-       if (be_stat_ev_is_active()) {
-               be_stat_tags[STAT_TAG_CLS] = "ilpsched";
-               be_stat_ev_push(be_stat_tags, STAT_TAG_LAST, be_stat_file);
-       }
-#endif /* FIRM_STATISTICS */
+       stat_ev_ctx_push("phase", "ilpsched");
 
 //     firm_dbg_set_mask(env.dbg, 1);
 
@@ -2088,11 +2071,7 @@ void be_ilp_sched(const be_irg_t *birg, be_options_t *be_opts) {
        /* notify backend */
        be_ilp_sched_finish_irg_ilp_schedule(sel, birg->irg, env.irg_env);
 
-#ifdef FIRM_STATISTICS
-       if (be_stat_ev_is_active()) {
-               be_stat_ev_pop();
-       }
-#endif /* FIRM_STATISTICS */
+       stat_ev_ctx_pop();
 }
 
 /**
index 511d619..f10c0da 100644 (file)
@@ -612,7 +612,7 @@ static void list_sched_block(ir_node *block, void *env_ptr)
 }
 
 /* List schedule a graph. */
-void list_sched(const be_irg_t *birg, be_options_t *be_opts)
+void list_sched(be_irg_t *birg, be_options_t *be_opts)
 {
        const arch_env_t *arch_env = birg->main_env->arch_env;
        ir_graph         *irg      = birg->irg;
index 496ff77..1e519cc 100644 (file)
@@ -162,7 +162,7 @@ extern const list_sched_selector_t *heuristic_selector;
  * @param birg    The backend irg.
  * @param be_opts The backend options
  */
-void list_sched(const be_irg_t *birg, be_options_t *be_opts);
+void list_sched(be_irg_t *birg, be_options_t *be_opts);
 
 /**
  * List schedule a block.
index 58c5b6b..a26ec2f 100644 (file)
@@ -491,8 +491,10 @@ static void collect_nodes(ir_node *irn, void *data)
 
 static int node_idx_cmp(const void *a, const void *b)
 {
-       int ia = get_irn_idx(a);
-       int ib = get_irn_idx(b);
+       const ir_node *p = *(ir_node **) a;
+       const ir_node *q = *(ir_node **) b;
+       int ia = get_irn_idx(p);
+       int ib = get_irn_idx(q);
        return ia - ib;
 }
 
@@ -541,7 +543,7 @@ void be_liveness_assure_sets(be_lv_t *lv)
 void be_liveness_assure_chk(be_lv_t *lv)
 {
 #ifndef USE_LIVE_CHK
-       be_liveness_assure_sets(be_lv_t *lv);
+       be_liveness_assure_sets(lv);
 #else
        (void) lv;
 #endif
@@ -564,7 +566,9 @@ be_lv_t *be_liveness(ir_graph *irg)
 
        memset(lv, 0, sizeof(lv[0]));
        lv->irg = irg;
+#ifdef USE_LIVE_CHK
        lv->lvc = lv_chk_new(irg);
+#endif
        lv->hook_info.context = lv;
        lv->hook_info.hook._hook_node_info = lv_dump_block;
 
index 3f248fe..1b7041e 100644 (file)
@@ -107,6 +107,7 @@ static INLINE int _be_is_live_xxx(const struct _be_lv_t *li, const ir_node *bloc
                return (lv_chk_bl_xxx(li->lvc, block, irn) & flags) != 0;
 #else
        assert(li->nodes && "node sets must be computed");
+       return 0;
 #endif /* USE_LIVE_CHK */
 }
 
index 16bafc8..b6112eb 100644 (file)
@@ -309,6 +309,7 @@ static void lower_perm_node(ir_node *irn, void *walk_env) {
                        should be ok.
        */
        sched_point = sched_prev(irn);
+       DBG((mod, LEVEL_1, "perm: %+F\n", irn));
        DBG((mod, LEVEL_1, "sched point is %+F\n", sched_point));
        assert(sched_point && "Perm is not scheduled or has no predecessor");
 
@@ -1033,7 +1034,7 @@ found_front:
 static void lower_nodes_after_ra_walker(ir_node *irn, void *walk_env) {
        if (! is_Block(irn) && ! is_Proj(irn)) {
                if (be_is_Perm(irn)) {
-                       int perm_stayed = push_through_perm(irn, walk_env);
+                       int perm_stayed = 1; //push_through_perm(irn, walk_env);
                        if (perm_stayed)
                                lower_perm_node(irn, walk_env);
                }
index 0842d59..311abc7 100644 (file)
@@ -93,7 +93,7 @@ static be_options_t be_options = {
        BE_SCHED_LIST,                     /* scheduler: list scheduler */
        "i44pc52.info.uni-karlsruhe.de",   /* ilp server */
        "cplex",                           /* ilp solver */
-       "",                                /* filename for statistic output */
+       0,                                 /* enable statistic event dumping */
 };
 
 /* config file. */
@@ -154,7 +154,7 @@ static const lc_opt_table_entry_t be_main_options[] = {
        LC_OPT_ENT_BOOL     ("time",     "get backend timing statistics",                       &be_options.timing),
        LC_OPT_ENT_BOOL     ("profile",  "instrument the code for execution count profiling",   &be_options.opt_profile),
        LC_OPT_ENT_ENUM_PTR ("sched",    "select a scheduler",                                  &sched_var),
-       LC_OPT_ENT_STR      ("statfile", "append statistics to file statfile", &be_options.stat_file_name, sizeof(be_options.stat_file_name)),
+       LC_OPT_ENT_BOOL     ("statev",   "dump statistic events",                               &be_options.statev),
 
 #ifdef WITH_ILP
        LC_OPT_ENT_STR ("ilp.server", "the ilp server name", be_options.ilp_server, sizeof(be_options.ilp_server)),
@@ -446,18 +446,12 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
                ir_graph *irg  = birg->irg;
                optimization_state_t state;
                const arch_code_generator_if_t *cg_if;
-               char irg_name[128];
 
                /* set the current graph (this is important for several firm functions) */
                current_ir_graph = irg;
 
 #ifdef FIRM_STATISTICS
-               if(be_stat_ev_is_active()) {
-                       ir_snprintf(irg_name, sizeof(irg_name), "%F", irg);
-                       be_stat_tags[STAT_TAG_CLS] = "<all>";
-                       be_stat_tags[STAT_TAG_IRG] = irg_name;
-                       be_stat_ev_push(be_stat_tags, STAT_TAG_LAST, be_stat_file);
-               }
+               stat_ev_ctx_push_fobj("irg", irg);
 #endif
 
                /* stop and reset timers */
@@ -611,10 +605,7 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
                be_do_stat_reg_pressure(birg);
 
 #ifdef FIRM_STATISTICS
-               if(be_stat_ev_is_active()) {
-                       be_stat_ev_l("costs_before_ra",
-                                       (long) be_estimate_irg_costs(irg, env.arch_env, birg->exec_freq));
-               }
+               stat_ev_dbl("costs_before_ra", be_estimate_irg_costs(irg, env.arch_env, birg->exec_freq));
 #endif
 
                /* Do register allocation */
@@ -623,10 +614,7 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
                BE_TIMER_POP(t_regalloc);
 
 #ifdef FIRM_STATISTICS
-               if(be_stat_ev_is_active()) {
-                       be_stat_ev_l("costs_after_ra",
-                                       (long) be_estimate_irg_costs(irg, env.arch_env, birg->exec_freq));
-               }
+               stat_ev_dbl("costs_before_ra", be_estimate_irg_costs(irg, env.arch_env, birg->exec_freq));
 #endif
 
                dump(DUMP_RA, irg, "-ra", dump_ir_block_graph_sched);
@@ -689,24 +677,18 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
                BE_TIMER_POP(t_other);
 
 #define LC_EMIT(timer)  \
-       if(!be_stat_ev_is_active()) { \
                printf("%-20s: %.3lf msec\n", lc_timer_get_description(timer), (double)lc_timer_elapsed_usec(timer) / 1000.0); \
-       } else { \
-               be_stat_ev_l(lc_timer_get_name(timer), lc_timer_elapsed_msec(timer)); \
-       }
+               stat_ev_dbl(lc_timer_get_name(timer), lc_timer_elapsed_msec(timer));
+
 #define LC_EMIT_RA(timer) \
-       if(!be_stat_ev_is_active()) { \
                printf("\t%-20s: %.3lf msec\n", lc_timer_get_description(timer), (double)lc_timer_elapsed_usec(timer) / 1000.0); \
-       } else { \
-               be_stat_ev_l(lc_timer_get_name(timer), lc_timer_elapsed_msec(timer)); \
-       }
+               stat_ev_dbl(lc_timer_get_name(timer), lc_timer_elapsed_msec(timer)); \
+
                BE_TIMER_ONLY(
-                       if(!be_stat_ev_is_active()) {
-                               printf("==>> IRG %s <<==\n", get_entity_name(get_irg_entity(irg)));
-                               printf("# nodes at begin:  %u\n", num_nodes_b);
-                               printf("# nodes before ra: %u\n", num_nodes_r);
-                               printf("# nodes at end:    %u\n\n", num_nodes_a);
-                       }
+                       printf("==>> IRG %s <<==\n", get_entity_name(get_irg_entity(irg)));
+                       printf("# nodes at begin:  %u\n", num_nodes_b);
+                       printf("# nodes before ra: %u\n", num_nodes_r);
+                       printf("# nodes at end:    %u\n\n", num_nodes_a);
                        LC_EMIT(t_abi);
                        LC_EMIT(t_codegen);
                        LC_EMIT(t_sched);
@@ -742,9 +724,7 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
 #endif /* FIRM_STATISTICS */
                        free_ir_graph(irg);
 #endif /* if 0 */
-               if(be_stat_ev_is_active()) {
-                       be_stat_ev_pop();
-               }
+               stat_ev_ctx_pop();
        }
        be_profile_free();
        be_done_env(&env);
@@ -779,9 +759,14 @@ void be_main(FILE *file_handle, const char *cup_name)
                lc_timer_reset_and_start(t);
        }
 
-#ifdef FIRM_STATISTICS
-       be_init_stat_file(be_options.stat_file_name, cup_name);
-#endif
+       if (be_options.statev) {
+               const char *dot = rindex(cup_name, '.');
+               const char *pos = dot ? dot : cup_name + strlen(cup_name);
+               char       *buf = alloca(pos - cup_name + 1);
+               strncpy(buf, cup_name, pos - cup_name);
+
+               stat_ev_begin(buf);
+       }
 
        /* never build code for pseudo irgs */
        set_visit_pseudo_irgs(0);
@@ -793,16 +778,12 @@ void be_main(FILE *file_handle, const char *cup_name)
        if (be_options.timing == BE_TIME_ON) {
                lc_timer_stop(t);
                lc_timer_leave_high_priority();
-               if(be_stat_ev_is_active()) {
-                       be_stat_ev_l("backend_time", lc_timer_elapsed_msec(t));
-               } else {
-                       printf("%-20s: %lu msec\n", "BEMAINLOOP", lc_timer_elapsed_msec(t));
-               }
+               stat_ev_dbl("backend_time", lc_timer_elapsed_msec(t));
+               printf("%-20s: %lu msec\n", "BEMAINLOOP", lc_timer_elapsed_msec(t));
        }
 
-#ifdef FIRM_STATISTICS
-       be_close_stat_file();
-#endif
+       if (be_options.statev)
+               stat_ev_end();
 }
 
 /** The debug info retriever function. */
index 56a3d1d..a6118aa 100644 (file)
@@ -492,6 +492,7 @@ static trace_env_t *trace_init(const arch_env_t *arch_env, ir_graph *irg) {
        env->liveness   = be_liveness(irg);
        FIRM_DBG_REGISTER(env->dbg, "firm.be.sched.trace");
 
+       be_liveness_assure_chk(env->liveness);
        memset(env->sched_info, 0, nn * sizeof(*(env->sched_info)));
 
        return env;
index 821a61e..86bbb17 100644 (file)
@@ -895,14 +895,10 @@ void be_insert_spills_reloads(spill_env_t *env)
                si->reloaders = NULL;
        }
 
-#ifdef FIRM_STATISTICS
-       if (be_stat_ev_is_active()) {
-               be_stat_ev("spill_spills", env->spill_count);
-               be_stat_ev("spill_reloads", env->reload_count);
-               be_stat_ev("spill_remats", env->remat_count);
-               be_stat_ev("spill_spilled_phis", env->spilled_phi_count);
-       }
-#endif
+       stat_ev_dbl("spill_spills", env->spill_count);
+       stat_ev_dbl("spill_reloads", env->reload_count);
+       stat_ev_dbl("spill_remats", env->remat_count);
+       stat_ev_dbl("spill_spilled_phis", env->spilled_phi_count);
 
        /* Matze: In theory be_ssa_construction should take care of the liveness...
         * try to disable this again in the future */
index 6086523..6ec5fcd 100644 (file)
@@ -624,7 +624,7 @@ static void create_memperms(be_fec_env_t *env)
                // insert node into schedule
                blockend = get_end_of_block_insertion_point(memperm->block);
                sched_add_before(blockend, mempermnode);
-               be_stat_ev("mem_perm", memperm->entrycount);
+               stat_ev_dbl("mem_perm", memperm->entrycount);
 
                i = 0;
                for(entry = memperm->entries; entry != NULL; entry = entry->next, ++i) {
@@ -692,19 +692,13 @@ void be_free_frame_entity_coalescer(be_fec_env_t *env)
 
 void be_assign_entities(be_fec_env_t *env)
 {
-       if(be_stat_ev_is_active()) {
-               int count = set_count(env->spills);
-               be_stat_ev("spillslots", count);
-       }
+       stat_ev_dbl("spillslots", set_count(env->spills));
 
        if(be_coalesce_spill_slots) {
                do_greedy_coalescing(env);
        }
 
-       if(be_stat_ev_is_active()) {
-               int count = count_spillslots(env);
-               be_stat_ev("spillslots_after_coalescing", count);
-       }
+       stat_ev_dbl("spillslots_after_coalescing", count_spillslots(env));
 
        assign_spillslots(env);
 
index 2f6f276..2a6124d 100644 (file)
@@ -392,6 +392,7 @@ void be_ssa_destruction(be_chordal_env_t *chordal_env) {
 
        FIRM_DBG_REGISTER(dbg, "ir.be.ssadestr");
 
+       be_liveness_invalidate(lv);
        be_liveness_assure_sets(lv);
 
        /* create a map for fast lookup of perms: block --> perm */
index 3bb3a88..ad6e65d 100644 (file)
@@ -38,6 +38,7 @@
 #include "firmstat_t.h"
 #include "irtools.h"
 #include "pset.h"
+#include "statev.h"
 
 #include "bearch_t.h"
 #include "bestat.h"
@@ -363,44 +364,6 @@ double be_estimate_irg_costs(ir_graph *irg, const arch_env_t *arch_env, ir_exec_
 
 #ifdef FIRM_STATISTICS
 
-const char *be_stat_tags[STAT_TAG_LAST];
-FILE       *be_stat_file = NULL;
-
-void be_init_stat_file(const char *stat_file_name, const char *sourcefilename)
-{
-       static char time_str[32];
-
-       assert(be_stat_file == NULL);
-
-       /* if we want to do some statistics, push the environment. */
-       if (strlen(stat_file_name) == 0)
-               return;
-
-       be_stat_file = fopen(stat_file_name, "at");
-       if (be_stat_file == NULL) {
-               fprintf(stderr, "Warning couldn't open statfile '%s'\n", stat_file_name);
-               return;
-       }
-
-       /* initialize the statistics tags */
-       ir_snprintf(time_str, sizeof(time_str),"%u", time(NULL));
-
-       be_stat_tags[STAT_TAG_FILE] = sourcefilename;
-       be_stat_tags[STAT_TAG_TIME] = time_str;
-       be_stat_tags[STAT_TAG_IRG]  = "<all>";
-       be_stat_tags[STAT_TAG_CLS]  = "<all>";
-
-       be_stat_ev_push(be_stat_tags, STAT_TAG_LAST, be_stat_file);
-}
-
-void be_close_stat_file()
-{
-       be_stat_ev_pop();
-       if (be_stat_file != NULL) {
-               fclose(be_stat_file);
-               be_stat_file = NULL;
-       }
-}
 
 #else /* FIRM_STATISTICS */
 
diff --git a/ir/be/bestatevent.c b/ir/be/bestatevent.c
deleted file mode 100644 (file)
index 9b74757..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief       Statistic events.
- * @author      Sebastian Hack
- * @date        03.09.2006
- * @version     $Id$
- */
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <assert.h>
-#include <string.h>
-#include <stdio.h>
-
-#include "bestatevent.h"
-
-#define STACK_SIZE 16
-
-typedef struct {
-       FILE *f;
-       char tag[512];
-} ev_env_t;
-
-static ev_env_t envs[STACK_SIZE];
-static unsigned sp = 0;
-
-void be_stat_ev_push(const char **tags, int n_tags, FILE *f)
-{
-       int i;
-       ev_env_t *env;
-
-       assert(sp < STACK_SIZE && "stat event stack full");
-       env = &envs[sp++];
-
-       env->tag[0] = '\0';
-       for(i = 0; i < n_tags; ++i) {
-               strncat(env->tag, tags[i], sizeof(env->tag));
-               strncat(env->tag, ";", sizeof(env->tag));
-       }
-       env->tag[sizeof(env->tag) - 1] = '\0';
-       env->f = f;
-}
-
-void be_stat_ev_pop(void)
-{
-       if (sp == 0)
-               return;
-
-       envs[--sp].f = NULL;
-}
-
-void be_stat_ev(const char *ev, int value)
-{
-       ev_env_t *env;
-
-       if (sp == 0)
-               return;
-
-       env = &envs[sp - 1];
-       if (env->f == NULL)
-               return;
-
-       fprintf(env->f, "%s%s;%d\n", env->tag, ev, value);
-}
-
-void be_stat_ev_l(const char *ev, long value)
-{
-       ev_env_t *env;
-
-       if (sp == 0)
-               return;
-
-       env = &envs[sp - 1];
-       if (env->f == NULL)
-               return;
-
-       fprintf(env->f, "%s%s;%ld\n", env->tag, ev, value);
-}
-
-void be_stat_ev_dbl(const char *ev, double value)
-{
-       ev_env_t *env;
-
-       if (sp == 0)
-               return;
-
-       env = &envs[sp - 1];
-       if (env->f == NULL)
-               return;
-
-       fprintf(env->f, "%s%s;%f\n", env->tag, ev, value);
-}
-
-void be_stat_ev_ull(const char *ev, ulong64 value)
-{
-       ev_env_t *env;
-
-       if (sp == 0)
-               return;
-
-       env = &envs[sp - 1];
-       if (env->f == NULL)
-               return;
-
-       fprintf(env->f, "%s%s;%" ULL_FMT "\n", env->tag, ev, value);
-}
-
-int be_stat_ev_is_active(void)
-{
-       return sp > 0 && envs[sp - 1].f != NULL;
-}
index 4a62563..51cf9d9 100644 (file)
 #include <stdio.h>
 
 #include "firm_types.h"
+#include "statev.h"
 
-void be_stat_ev_push(const char **tags, int n_tags, FILE *f);
-void be_stat_ev_pop(void);
-
-void be_stat_ev(const char *ev, int value);
-void be_stat_ev_l(const char *ev, long value);
-void be_stat_ev_dbl(const char *ev, double value);
-void be_stat_ev_ull(const char *ev, ulong64 value);
-
-int be_stat_ev_is_active(void);
+#define be_stat_ev(name, val)      stat_ev_dbl(name, val)
+#define be_stat_ev_l(name, val)    stat_ev_dbl(name, val)
+#define be_stat_ev_dbl(name, val)  stat_ev_dbl(name, val)
+#define be_stat_ev_ull(name, val)  stat_ev_dbl(name, val)
 
 #endif /* FIRM_BE_BESTATEVENT_H */
index 6a81fa1..0a24191 100644 (file)
@@ -405,4 +405,9 @@ void be_transform_graph(be_irg_t *birg, arch_pretrans_nodes *func, void *cg)
        /* recalculate edges */
        edges_deactivate(irg);
        edges_activate(irg);
+
+       if (birg->lv) {
+               be_liveness_free(birg->lv);
+               birg->lv = be_liveness(birg->irg);
+       }
 }