Bugfixes
[libfirm] / ir / be / bespillilp.c
index 4970343..6898c2c 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <lpp/lpp.h>
 #include <lpp/lpp_net.h>
+#include <lpp/lpp_cplex.h>
 
 #include "be_t.h"
 #include "belive_t.h"
@@ -39,8 +40,8 @@
 
 #define DBG_LEVEL SET_LEVEL_3
 
-#define DUMP_SOLUTION
-#define DUMP_ILP
+#undef DUMP_SOLUTION
+#undef DUMP_ILP
 
 #define LPP_SERVER "i44pc52"
 #define LPP_SOLVER "cplex"
@@ -387,6 +388,9 @@ static void process_block(ir_node *bl, void *data)
                step++;
        }
 
+       if(bl == get_irg_start_block(get_irn_irg(bl)))
+               goto end;
+
        /*
         * Here, only the phis in the block and the values live in are in the
         * live set.
@@ -433,6 +437,8 @@ static void process_block(ir_node *bl, void *data)
                }
        }
 
+end:
+
   del_pset(live);
 }
 
@@ -567,7 +573,7 @@ static void writeback_results(spill_ilp_t *si)
                /* Go through all live ranges of the node. */
     list_for_each_entry(live_range_t, lr, &uh->head, list) {
       int spilled = is_spilled(si, lr);
-                       int rematd  = !is_zero(lpp_get_var_sol(si->lpp, lr->is_remat_var));
+                       // int rematd  = !is_zero(lpp_get_var_sol(si->lpp, lr->is_remat_var));
 
                        if(spilled && !is_end_of_block_use(lr)) {
                                ir_node *bl      = get_nodes_block(lr->user);
@@ -623,21 +629,10 @@ void be_spill_ilp(const be_main_session_env_t *session_env,
        si.enable_store   = 0;
 
        firm_dbg_set_mask(si.dbg, DBG_LEVEL);
-  irg_block_walk_graph(session_env->irg, process_block, NULL, &si);
+       irg_block_walk_graph(session_env->irg, process_block, NULL, &si);
        if(si.enable_store)
                add_store_costs(&si);
 
-       DBG((si.dbg, LEVEL_1, "%F\n", session_env->irg));
-  lpp_solve_net(si.lpp, LPP_SERVER, LPP_SOLVER);
-       assert(lpp_is_sol_valid(si.lpp) && "ILP not feasible");
-
-  // assert(lpp_is_sol_valid(si.lpp) && "solution of ILP must be valid");
-
-       DBG((si.dbg, LEVEL_1, "\tnodes: %d, vars: %d, csts: %d\n",
-                               set_count(si.irn_use_heads), si.lpp->var_next, si.lpp->cst_next));
-       DBG((si.dbg, LEVEL_1, "\titerations: %d, solution time: %g\n",
-                               si.lpp->iterations, si.lpp->sol_time));
-
 #ifdef DUMP_ILP
        {
                FILE *f;
@@ -650,6 +645,18 @@ void be_spill_ilp(const be_main_session_env_t *session_env,
        }
 #endif
 
+       DBG((si.dbg, LEVEL_1, "%F\n", session_env->irg));
+//     lpp_solve_net(si.lpp, LPP_SERVER, LPP_SOLVER);
+       lpp_solve_cplex(si.lpp);
+       assert(lpp_is_sol_valid(si.lpp) && "ILP not feasible");
+
+       assert(lpp_is_sol_valid(si.lpp) && "solution of ILP must be valid");
+
+       DBG((si.dbg, LEVEL_1, "\tnodes: %d, vars: %d, csts: %d\n",
+                               set_count(si.irn_use_heads), si.lpp->var_next, si.lpp->cst_next));
+       DBG((si.dbg, LEVEL_1, "\titerations: %d, solution time: %g\n",
+                               si.lpp->iterations, si.lpp->sol_time));
+
 #ifdef DUMP_SOLUTION
        {
                FILE *f;