Don't set copy_attr_func to NULL for nodes without attributes.
[libfirm] / ir / be / bepbqpcoloring.c
index c658814..36dad0a 100644 (file)
@@ -22,7 +22,6 @@
  * @brief       PBQP based register allocation.
  * @author      Thomas Bersch
  * @date        27.11.2009
- * @version     $Id: bechordal.c 26750 2009-11-27 09:37:43Z bersch $
  */
 
 /* miscellaneous includes */
@@ -36,9 +35,9 @@
 #include "iredges_t.h"
 #include "irprintf.h"
 #include "irgwalk.h"
+#include "irtools.h"
 #include "time.h"
-
-/* libfirm/ir/adt includes */
+#include "execfreq_t.h"
 #include "bipartite.h"
 
 /* libfirm/ir/be includes */
@@ -91,6 +90,7 @@ typedef struct be_pbqp_alloc_env_t {
        plist_t                     *rpeo;
        unsigned                    *restr_nodes;
        unsigned                    *ife_edge_num;
+       ir_execfreq_int_factors      execfreq_factors;
        be_chordal_env_t            *env;
 } be_pbqp_alloc_env_t;
 
@@ -219,10 +219,9 @@ static void insert_afe_edge(be_pbqp_alloc_env_t *pbqp_alloc_env, ir_node *src_no
        if (get_edge(pbqp, get_irn_idx(src_node), get_irn_idx(trg_node)) == NULL) {
                if (use_exec_freq) {
                        /* get exec_freq for copy_block */
-                       ir_node       *root_bl   = get_nodes_block(src_node);
-                       ir_node       *copy_bl   = is_Phi(src_node) ? get_Block_cfgpred_block(root_bl, pos) : root_bl;
-                       ir_exec_freq  *exec_freq = be_get_irg_exec_freq(pbqp_alloc_env->irg);
-                       unsigned long  res       = get_block_execfreq_ulong(exec_freq, copy_bl);
+                       ir_node *root_bl = get_nodes_block(src_node);
+                       ir_node *copy_bl = is_Phi(src_node) ? get_Block_cfgpred_block(root_bl, pos) : root_bl;
+                       int      res     = get_block_execfreq_int(&pbqp_alloc_env->execfreq_factors, copy_bl);
 
                        /* create afe-matrix */
                        unsigned row, col;
@@ -320,7 +319,6 @@ static void create_pbqp_coloring_instance(ir_node *block, void *data)
        pbqp_t                      *pbqp_inst          = pbqp_alloc_env->pbqp_inst;
        plist_t                     *temp_list          = plist_new();
        plist_element_t             *el;
-       ir_node                     *irn;
        ir_nodeset_t                 live_nodes;
 #if USE_BIPARTIT_MATCHING
        int                         *assignment         = ALLOCAN(int, cls->n_regs);
@@ -342,11 +340,7 @@ static void create_pbqp_coloring_instance(ir_node *block, void *data)
 
        /* create pbqp nodes, interference edges and reverse perfect elimination order */
        sched_foreach_reverse(block, irn) {
-               ir_node               *live;
-               ir_nodeset_iterator_t  iter;
-
                if (get_irn_mode(irn) == mode_T) {
-                       const ir_edge_t *edge;
                        foreach_out_edge(irn, edge) {
                                ir_node *proj = get_edge_src_irn(edge);
                                if (!arch_irn_consider_in_reg_alloc(cls, proj))
@@ -411,7 +405,6 @@ static void create_pbqp_coloring_instance(ir_node *block, void *data)
                        bipartite_t *bp                  = bipartite_new(cls->n_regs, cls->n_regs);
 
                        /* add all proj after a perm to clique */
-                       const ir_edge_t *edge;
                        foreach_out_edge(irn, edge) {
                                ir_node *proj = get_edge_src_irn(edge);
 
@@ -511,9 +504,7 @@ static void create_pbqp_coloring_instance(ir_node *block, void *data)
 #else
                /* order nodes for perfect elimination order */
                if (get_irn_mode(irn) == mode_T) {
-                       bool             allHaveIFEdges = true;
-                       const ir_edge_t *edge;
-
+                       bool allHaveIFEdges = true;
                        foreach_out_edge(irn, edge) {
                                ir_node *proj = get_edge_src_irn(edge);
                                if (!arch_irn_consider_in_reg_alloc(cls, proj))
@@ -636,9 +627,8 @@ static void be_pbqp_coloring(be_chordal_env_t *env)
 
        printf("#### ----- === Allocating registers of %s (%s) ===\n", cls->name, get_entity_name(get_irg_entity(irg)));
 #endif
-       lv = be_assure_liveness(irg);
-       be_liveness_assure_sets(lv);
-       be_liveness_assure_chk(lv);
+       be_assure_live_sets(irg);
+       lv = be_get_irg_liveness(irg);
 
        /* insert perms */
        assure_doms(irg);
@@ -651,6 +641,7 @@ static void be_pbqp_coloring(be_chordal_env_t *env)
                dump_ir_graph(irg, buf);
        }
 
+       ir_calculate_execfreq_int_factors(&pbqp_alloc_env.execfreq_factors, irg);
 
        /* initialize pbqp allocation data structure */
        pbqp_alloc_env.pbqp_inst        = alloc_pbqp(get_irg_last_idx(irg));  /* initialize pbqp instance */