cleanup/fix optimize_graph_df flag handling
[libfirm] / ir / be / bemain.c
index 959a379..f85257a 100644 (file)
@@ -87,7 +87,7 @@ static be_options_t be_options = {
        0,                                 /* create PIC code */
        BE_VERIFY_WARN,                    /* verification level: warn */
        "",                                /* ilp server */
-       "cplex",                           /* ilp solver */
+       "",                                /* ilp solver */
        0,                                 /* enable statistic event dumping */
        "",                                /* print stat events */
 };
@@ -129,15 +129,15 @@ static const lc_opt_table_entry_t be_main_options[] = {
        LC_OPT_ENT_ENUM_MASK("dump",       "dump irg on several occasions",                       &dump_var),
        LC_OPT_ENT_BOOL     ("omitfp",     "omit frame pointer",                                  &be_options.omit_fp),
        LC_OPT_ENT_BOOL     ("pic",        "create PIC code",                                     &be_options.pic),
-       LC_OPT_ENT_ENUM_PTR ("verify",     "verify the backend irg",                              &verify_var),
+       LC_OPT_ENT_ENUM_INT ("verify",     "verify the backend irg",                              &verify_var),
        LC_OPT_ENT_BOOL     ("time",       "get backend timing statistics",                       &be_options.timing),
        LC_OPT_ENT_BOOL     ("profilegenerate", "instrument the code for execution count profiling",   &be_options.opt_profile_generate),
        LC_OPT_ENT_BOOL     ("profileuse",      "use existing profile data",                           &be_options.opt_profile_use),
        LC_OPT_ENT_BOOL     ("statev",     "dump statistic events",                               &be_options.statev),
-       LC_OPT_ENT_STR      ("filtev",     "filter for stat events (regex if support is active",  &be_options.filtev, sizeof(be_options.filtev)),
+       LC_OPT_ENT_STR      ("filtev",     "filter for stat events (regex if support is active",   be_options.filtev),
 
-       LC_OPT_ENT_STR ("ilp.server", "the ilp server name", be_options.ilp_server, sizeof(be_options.ilp_server)),
-       LC_OPT_ENT_STR ("ilp.solver", "the ilp solver name", be_options.ilp_solver, sizeof(be_options.ilp_solver)),
+       LC_OPT_ENT_STR("ilp.server", "the ilp server name", be_options.ilp_server),
+       LC_OPT_ENT_STR("ilp.solver", "the ilp solver name", be_options.ilp_solver),
        LC_OPT_LAST
 };
 
@@ -413,6 +413,10 @@ static void initialize_birg(be_irg_t *birg, ir_graph *irg, be_main_env_t *env)
        /* set the current graph (this is important for several firm functions) */
        current_ir_graph = irg;
 
+       /* For code generation all unreachable code and Bad nodes should be gone */
+       remove_unreachable_blocks(irg);
+       remove_bads(irg);
+
        /* we do this before critical edge split. As this produces less returns,
           because sometimes (= 164.gzip) multiple returns are slower */
        normalize_n_returns(irg);
@@ -573,7 +577,7 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
                /* set the current graph (this is important for several firm functions) */
                current_ir_graph = irg;
 
-               stat_ev_if {
+               if (stat_ev_enabled) {
                        stat_ev_ctx_push_fobj("bemain_irg", irg);
                        be_stat_ev("bemain_insns_start", be_count_insns(irg));
                        be_stat_ev("bemain_blocks_start", be_count_blocks(irg));
@@ -704,7 +708,7 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
                be_sched_verify(irg, be_options.verify_option);
                be_timer_pop(T_VERIFY);
 
-               stat_ev_if {
+               if (stat_ev_enabled) {
                        stat_ev_dbl("bemain_costs_before_ra",
                                        be_estimate_irg_costs(irg, birg->exec_freq));
                        be_stat_ev("bemain_insns_before_ra", be_count_insns(irg));
@@ -718,21 +722,6 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
 
                dump(DUMP_RA, irg, "ra");
 
-               /* let the code generator prepare the graph for emitter */
-               be_timer_push(T_FINISH);
-               if (arch_env->impl->after_ra != NULL)
-                       arch_env->impl->after_ra(irg);
-               be_timer_pop(T_FINISH);
-
-               /* fix stack offsets */
-               be_timer_push(T_ABI);
-               be_abi_fix_stack_nodes(irg);
-               be_remove_dead_nodes_from_schedule(irg);
-               be_abi_fix_stack_bias(irg);
-               be_timer_pop(T_ABI);
-
-               dump(DUMP_SCHED, irg, "fix_stack_after_ra");
-
                be_timer_push(T_FINISH);
                if (arch_env->impl->finish != NULL)
                        arch_env->impl->finish(irg);
@@ -740,7 +729,7 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
 
                dump(DUMP_FINAL, irg, "finish");
 
-               stat_ev_if {
+               if (stat_ev_enabled) {
                        be_stat_ev("bemain_insns_finish", be_count_insns(irg));
                        be_stat_ev("bemain_blocks_finish", be_count_blocks(irg));
                }
@@ -850,7 +839,7 @@ void be_main(FILE *file_handle, const char *cup_name)
        if (be_options.timing == BE_TIME_ON) {
                ir_timer_stop(t);
                ir_timer_leave_high_priority();
-               stat_ev_if {
+               if (stat_ev_enabled) {
                        stat_ev_dbl("bemain_backend_time", ir_timer_elapsed_msec(t));
                } else {
                        double val = ir_timer_elapsed_usec(t) / 1000.0;