belive: cleanup livness assure/invalidate API
authorMatthias Braun <matze@braunis.de>
Wed, 21 Dec 2011 17:16:12 +0000 (18:16 +0100)
committerMatthias Braun <matze@braunis.de>
Thu, 22 Dec 2011 15:49:27 +0000 (16:49 +0100)
This also plugs liveness related memory leaks

28 files changed:
ir/be/bechordal.c
ir/be/bechordal_draw.c
ir/be/bechordal_main.c
ir/be/becopyopt.c
ir/be/beirg.c
ir/be/beirg.h
ir/be/belive.c
ir/be/belive.h
ir/be/belive_t.h
ir/be/belower.c
ir/be/bemain.c
ir/be/bepbqpcoloring.c
ir/be/bepeephole.c
ir/be/beprefalloc.c
ir/be/beschedtrace.c
ir/be/bespill.c
ir/be/bespillbelady.c
ir/be/bespilldaemel.c
ir/be/bespillslots.c
ir/be/bespillutil.c
ir/be/bessadestr.c
ir/be/bestat.c
ir/be/bestate.c
ir/be/betranshlp.c
ir/be/beverify.c
ir/be/ia32/ia32_address_mode.c
ir/be/ia32/ia32_fpu.c
ir/be/ia32/ia32_x87.c

index ae5f29e..24126a1 100644 (file)
@@ -501,16 +501,12 @@ void be_ra_chordal_color(be_chordal_env_t *chordal_env)
 {
        be_chordal_alloc_env_t env;
        char buf[256];
-       be_lv_t *lv;
        const arch_register_class_t *cls = chordal_env->cls;
 
-       int colors_n          = arch_register_class_n_regs(cls);
-       ir_graph *irg         = chordal_env->irg;
-
-       lv = be_assure_liveness(irg);
-       be_liveness_assure_sets(lv);
-       be_liveness_assure_chk(lv);
+       int       colors_n = arch_register_class_n_regs(cls);
+       ir_graph *irg      = chordal_env->irg;
 
+       be_assure_live_sets(irg);
        assure_doms(irg);
 
        env.chordal_env   = chordal_env;
index 570c591..d502d94 100644 (file)
@@ -386,17 +386,16 @@ static void draw_block(ir_node *bl, void *data)
 
 static void draw(draw_chordal_env_t *env, const rect_t *start_box)
 {
+       ir_graph  *irg = env->chordal_env->irg;
        plotter_t *p = env->plotter;
-       be_lv_t *lv;
        rect_t bbox;
 
        bbox.x = bbox.y = 0;
        bbox.w = start_box->w + 2 * env->opts->x_margin;
        bbox.h = start_box->h + 2 * env->opts->y_margin;
 
-       lv = be_assure_liveness(env->chordal_env->irg);
-       be_liveness_assure_sets(lv);
-       be_liveness_assure_chk(lv);
+       be_assure_live_sets(irg);
+       be_assure_live_chk(irg);
 
        p->vtab->begin(p, &bbox);
        irg_block_walk_graph(env->chordal_env->irg, draw_block, NULL, env);
index 6bf0e7b..192a571 100644 (file)
@@ -246,8 +246,7 @@ static void pre_spill(post_spill_env_t *pse, const arch_register_class_t *cls)
        chordal_env->border_heads     = pmap_create();
        chordal_env->allocatable_regs = bitset_malloc(chordal_env->cls->n_regs);
 
-       be_assure_liveness(irg);
-       be_liveness_assure_chk(be_get_irg_liveness(irg));
+       be_assure_live_chk(irg);
 
        if (stat_ev_enabled) {
                pse->pre_spill_cost = be_estimate_irg_costs(irg, exec_freq);
@@ -379,8 +378,6 @@ static void be_ra_chordal_main(ir_graph *irg)
 
        be_timer_push(T_RA_PROLOG);
 
-       be_assure_liveness(irg);
-
        chordal_env.obst             = &obst;
        chordal_env.opts             = &options;
        chordal_env.irg              = irg;
@@ -451,7 +448,7 @@ static void be_ra_chordal_main(ir_graph *irg)
        dump(BE_CH_DUMP_LOWER, irg, NULL, "belower-after-ra");
 
        obstack_free(&obst, NULL);
-       be_liveness_invalidate(be_get_irg_liveness(irg));
+       be_invalidate_live_sets(irg);
        be_timer_pop(T_RA_EPILOG);
 
        be_timer_pop(T_RA_OTHER);
index e624545..acc6402 100644 (file)
@@ -1031,7 +1031,7 @@ void co_driver(be_chordal_env_t *cenv)
        if (selected_copyopt->copyopt == void_algo)
                return;
 
-       be_liveness_assure_chk(be_get_irg_liveness(cenv->irg));
+       be_assure_live_chk(cenv->irg);
 
        co = new_copy_opt(cenv, cost_func);
        co_build_ou_structure(co);
index d0ee0ea..36504b5 100644 (file)
 #include "belive.h"
 #include "bedomfront.h"
 
-be_lv_t *be_assure_liveness(ir_graph *irg)
-{
-       be_irg_t *birg = be_birg_from_irg(irg);
-       if (birg->lv != NULL)
-               return birg->lv;
-
-       return birg->lv = be_liveness(birg->irg);
-}
-
 void be_assure_dom_front(ir_graph *irg)
 {
        be_irg_t *birg = be_birg_from_irg(irg);
@@ -59,6 +50,30 @@ void be_invalidate_dom_front(ir_graph *irg)
        birg->dom_front = NULL;
 }
 
+void be_invalidate_live_sets(ir_graph *irg)
+{
+       be_irg_t *birg = be_birg_from_irg(irg);
+       be_liveness_invalidate_sets(birg->lv);
+}
+
+void be_invalidate_live_chk(ir_graph *irg)
+{
+       be_irg_t *birg = be_birg_from_irg(irg);
+       be_liveness_invalidate_chk(birg->lv);
+}
+
+void be_assure_live_sets(ir_graph *irg)
+{
+       be_irg_t *birg = be_birg_from_irg(irg);
+       be_liveness_compute_sets(birg->lv);
+}
+
+void be_assure_live_chk(ir_graph *irg)
+{
+       be_irg_t *birg = be_birg_from_irg(irg);
+       be_liveness_compute_chk(birg->lv);
+}
+
 void be_free_birg(ir_graph *irg)
 {
        be_irg_t *birg = be_birg_from_irg(irg);
index a964520..8b4e19e 100644 (file)
 #include "be_t.h"
 #include "irtypes.h"
 
-be_lv_t *be_assure_liveness(ir_graph *irg);
-
 void be_assure_dom_front(ir_graph *irg);
 void be_invalidate_dom_front(ir_graph *irg);
 
+void be_assure_live_sets(ir_graph *irg);
+void be_assure_live_chk(ir_graph *irg);
+/**
+ * Liveness is invalid (call when nodes have been added but the control
+ * flow has not been changed)
+ */
+void be_invalidate_live_sets(ir_graph *irg);
+/**
+ * Call when control flow has changed.
+ * be_invalidate_live_sets() is called.
+ */
+void be_invalidate_live_chk(ir_graph *irg);
+
 /**
  * frees all memory allocated by birg structures (liveness, dom_front, ...).
  * The memory of the birg structure itself is not freed.
index b5918ff..e2719c0 100644 (file)
@@ -48,12 +48,6 @@ DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
 
 #define LV_STD_SIZE             64
 
-/* if defined, use binary search for already live nodes, else linear */
-#define LV_USE_BINARY_SEARCH
-#undef  LV_INTESIVE_CHECKS
-
-void be_live_chk_compare(be_lv_t *lv, lv_chk_t *lvc);
-
 /**
  * Filter out some nodes for which we never need liveness.
  *
@@ -89,8 +83,6 @@ int (be_is_live_end)(const be_lv_t *lv, const ir_node *block, const ir_node *irn
        return _be_is_live_xxx(lv, block, irn, be_lv_state_end);
 }
 
-
-#ifdef LV_USE_BINARY_SEARCH
 static inline unsigned _be_liveness_bsearch(be_lv_info_t *arr, unsigned idx)
 {
        be_lv_info_t *payload = arr + 1;
@@ -120,39 +112,9 @@ static inline unsigned _be_liveness_bsearch(be_lv_info_t *arr, unsigned idx)
                res = lo;
        } while (lo < hi);
 
-#ifdef LV_INTESIVE_CHECKS
-       {
-               unsigned i;
-               for (i = res; i < n; ++i)
-                       assert(payload[i].node.idx >= idx);
-
-               for (i = 0; i < res; ++i)
-                       assert(payload[i].node.idx < idx);
-       }
-#endif
-
        return res;
 }
 
-#else
-
-/**
- * This function searches linearly for the node in the array.
- */
-static inline unsigned _be_liveness_bsearch(be_lv_info_t *arr, unsigned idx)
-{
-       unsigned n  = arr[0].head.n_members;
-       unsigned i;
-
-       for (i = 0; i < n; ++i) {
-               if (arr[i + 1].node.idx == idx)
-                       return i;
-       }
-
-       return i;
-}
-#endif
-
 be_lv_info_node_t *be_lv_get(const be_lv_t *li, const ir_node *bl,
                              const ir_node *irn)
 {
@@ -231,20 +193,6 @@ static be_lv_info_node_t *be_lv_get_or_set(be_lv_t *li, ir_node *bl,
                res->flags  = 0;
        }
 
-#ifdef LV_INTESIVE_CHECKS
-       {
-               unsigned i;
-               unsigned n = irn_live[0].head.n_members;
-               unsigned last = 0;
-               be_lv_info_t *payload = &irn_live[1];
-
-               for (i = 0; i < n; ++i) {
-                       assert(payload[i].node.idx >= last);
-                       last = payload[i].node.idx;
-               }
-       }
-#endif
-
        return res;
 }
 
@@ -457,21 +405,34 @@ static void collect_liveness_nodes(ir_node *irn, void *data)
                nodes[get_irn_idx(irn)] = irn;
 }
 
-static void compute_liveness(be_lv_t *lv)
+void be_liveness_compute_sets(be_lv_t *lv)
 {
        ir_node **nodes;
-       int i, n;
+       int       i;
+       int       n;
+       unsigned  last_idx;
+
+       if (lv->sets_valid)
+               return;
+
+       be_timer_push(T_LIVE);
+       last_idx = get_irg_last_idx(lv->irg);
+       if (last_idx >= bitset_size(lv->nodes)) {
+               bitset_free(lv->nodes);
+               lv->nodes = bitset_malloc(last_idx * 2);
+       } else {
+               bitset_clear_all(lv->nodes);
+       }
+       ir_nodehashmap_init(&lv->map);
+       obstack_init(&lv->obst);
 
-       stat_ev_tim_push();
        n = get_irg_last_idx(lv->irg);
        nodes = NEW_ARR_F(ir_node *, n);
        memset(nodes, 0, sizeof(nodes[0]) * n);
 
-       /*
-        * inserting the variables sorted by their ID is probably
+       /* inserting the variables sorted by their ID is probably
         * more efficient since the binary sorted set insertion
-        * will not need to move around the data.
-        */
+        * will not need to move around the data. */
        irg_walk_graph(lv->irg, NULL, collect_liveness_nodes, nodes);
 
        re.lv      = lv;
@@ -485,96 +446,63 @@ static void compute_liveness(be_lv_t *lv)
        DEL_ARR_F(nodes);
        free(re.visited);
        register_hook(hook_node_info, &lv->hook_info);
-       stat_ev_tim_pop("be_lv_sets_cons");
-}
 
-void be_liveness_assure_sets(be_lv_t *lv)
-{
-       if (!lv->nodes) {
-               be_timer_push(T_LIVE);
+       be_timer_pop(T_LIVE);
 
-               lv->nodes = bitset_malloc(2 * get_irg_last_idx(lv->irg));
-               ir_nodehashmap_init(&lv->map);
-               obstack_init(&lv->obst);
-               compute_liveness(lv);
-               /* be_live_chk_compare(lv, lv->lvc); */
+       lv->sets_valid = true;
+}
 
-               be_timer_pop(T_LIVE);
-       }
+void be_liveness_compute_chk(be_lv_t *lv)
+{
+       if (lv->lvc != NULL)
+               return;
+       lv->lvc = lv_chk_new(lv->irg);
 }
 
-void be_liveness_assure_chk(be_lv_t *lv)
+void be_liveness_invalidate_sets(be_lv_t *lv)
 {
-#ifndef USE_LIVE_CHK
-       be_timer_push(t_verify);
-       be_liveness_assure_sets(lv);
-       be_timer_pop(t_verify);
-#else
-       (void) lv;
-#endif
+       if (!lv->sets_valid)
+               return;
+       unregister_hook(hook_node_info, &lv->hook_info);
+       obstack_free(&lv->obst, NULL);
+       ir_nodehashmap_destroy(&lv->map);
+       lv->sets_valid = false;
 }
 
-void be_liveness_invalidate(be_lv_t *lv)
+void be_liveness_invalidate_chk(be_lv_t *lv)
 {
-       if (lv && lv->nodes) {
-               unregister_hook(hook_node_info, &lv->hook_info);
-               obstack_free(&lv->obst, NULL);
-               ir_nodehashmap_destroy(&lv->map);
-               bitset_free(lv->nodes);
-               lv->nodes = NULL;
-       }
+       be_liveness_invalidate_sets(lv);
+
+       if (lv->lvc == NULL)
+               return;
+       lv_chk_free(lv->lvc);
+       lv->lvc = NULL;
 }
 
-/* Compute the inter block liveness for a graph. */
-be_lv_t *be_liveness(ir_graph *irg)
+be_lv_t *be_liveness_new(ir_graph *irg)
 {
        be_lv_t *lv = XMALLOCZ(be_lv_t);
 
-       lv->irg  = irg;
-#ifdef USE_LIVE_CHK
-       lv->lvc  = lv_chk_new(lv->irg);
-#endif
+       lv->irg = irg;
        lv->hook_info.context = lv;
        lv->hook_info.hook._hook_node_info = be_dump_liveness_block;
+       lv->nodes = bitset_malloc(2 * get_irg_last_idx(lv->irg));
 
        return lv;
 }
 
-void be_liveness_recompute(be_lv_t *lv)
-{
-       unsigned last_idx;
-
-       be_timer_push(T_LIVE);
-       last_idx = get_irg_last_idx(lv->irg);
-       if (last_idx >= bitset_size(lv->nodes)) {
-               bitset_free(lv->nodes);
-               lv->nodes = bitset_malloc(last_idx * 2);
-       } else
-               bitset_clear_all(lv->nodes);
-
-       ir_nodehashmap_destroy(&lv->map);
-       obstack_free(&lv->obst, NULL);
-
-       ir_nodehashmap_init(&lv->map);
-       obstack_init(&lv->obst);
-       compute_liveness(lv);
-
-       be_timer_pop(T_LIVE);
-}
-
-
 void be_liveness_free(be_lv_t *lv)
 {
-       be_liveness_invalidate(lv);
-#ifdef USE_LIVE_CHK
-       lv_chk_free(lv->lvc);
-#endif
+       be_liveness_invalidate_sets(lv);
+       be_liveness_invalidate_chk(lv);
+
+       bitset_free(lv->nodes);
        xfree(lv);
 }
 
 void be_liveness_remove(be_lv_t *lv, const ir_node *irn)
 {
-       if (lv->nodes) {
+       if (lv->sets_valid) {
                unsigned idx = get_irn_idx(irn);
                lv_remove_walker_t w;
 
@@ -594,7 +522,7 @@ void be_liveness_remove(be_lv_t *lv, const ir_node *irn)
 void be_liveness_introduce(be_lv_t *lv, ir_node *irn)
 {
        /* Don't compute liveness information for non-data nodes. */
-       if (lv->nodes && is_liveness_node(irn)) {
+       if (lv->sets_valid && is_liveness_node(irn)) {
                re.lv      = lv;
                re.visited = bitset_malloc(get_irg_last_idx(lv->irg));
                liveness_for_node(irn);
@@ -686,7 +614,7 @@ static void collect_node(ir_node *irn, void *data)
        obstack_ptr_grow(obst, irn);
 }
 
-void be_live_chk_compare(be_lv_t *lv, lv_chk_t *lvc)
+static void be_live_chk_compare(be_lv_t *lv, lv_chk_t *lvc)
 {
        ir_graph *irg    = lv->irg;
 
@@ -739,5 +667,6 @@ void be_live_chk_compare(be_lv_t *lv, lv_chk_t *lvc)
 BE_REGISTER_MODULE_CONSTRUCTOR(be_init_live)
 void be_init_live(void)
 {
+       (void)be_live_chk_compare;
        FIRM_DBG_REGISTER(dbg, "firm.be.liveness");
 }
index 792633c..311448b 100644 (file)
@@ -47,7 +47,7 @@ typedef enum {
  * Compute the inter block liveness for a graph.
  * @param irg The graph.
  */
-be_lv_t *be_liveness(ir_graph *irg);
+be_lv_t *be_liveness_new(ir_graph *irg);
 
 /**
  * Free the liveness information.
@@ -55,9 +55,21 @@ be_lv_t *be_liveness(ir_graph *irg);
 void be_liveness_free(be_lv_t *lv);
 
 /**
- * Recompute the complete liveness information.
+ * (Re)compute the liveness information if necessary.
  */
-void be_liveness_recompute(be_lv_t *lv);
+void be_liveness_compute_sets(be_lv_t *lv);
+void be_liveness_compute_chk(be_lv_t *lv);
+
+/**
+ * Invalidate the liveness information.
+ * You must call this if you modify the program and do not
+ * update the liveness with the be_liveness_{update,remove,introduce}
+ * functions.
+ * @note If changed the control flow then you must also call
+ *       be_liveness_invalidate_chk()
+ */
+void be_liveness_invalidate_sets(be_lv_t *lv);
+void be_liveness_invalidate_chk(be_lv_t *lv);
 
 /**
  * Update the liveness information for a single node.
@@ -148,25 +160,4 @@ void be_liveness_nodes_live_at(const be_lv_t *lv,
                                const arch_register_class_t *cls,
                                const ir_node *pos, ir_nodeset_t *live);
 
-/**
- * Make sure the live sets are computed.
- * @param lv The liveness information.
- */
-void be_liveness_assure_sets(be_lv_t *lv);
-
-/**
- * Make sure all information needed for liveness checks is available.
- * @param lv The liveness information.
- */
-void be_liveness_assure_chk(be_lv_t *lv);
-
-/**
- * Invalidate the liveness information.
- * You must call this if you modify the program and do not
- * update the liveness with the be_liveness_{update,remove,introduce}
- * functions.
- * @param lv The liveness info.
- */
-void be_liveness_invalidate(be_lv_t *lv);
-
-#endif /* FIRM_BE_BELIVE_H */
+#endif
index 5b5da70..6d79f01 100644 (file)
 #ifndef FIRM_BE_BELIVE_T_H
 #define FIRM_BE_BELIVE_T_H
 
+#include <stdbool.h>
 #include "be_types.h"
 #include "irgraph_t.h"
 #include "irnodehashmap.h"
 #include "irhooks.h"
+#include "irlivechk.h"
 #include "statev.h"
 
 #include "pset.h"
 
 #include "belive.h"
 
-#define USE_LIVE_CHK
-
-#ifdef USE_LIVE_CHK
-#include "irlivechk.h"
-#endif
-
 struct be_lv_t {
        ir_nodehashmap_t map;
        struct obstack   obst;
+       bool             sets_valid;
        ir_graph        *irg;
        bitset_t        *nodes;
        hook_entry_t     hook_info;
-#ifdef USE_LIVE_CHK
        lv_chk_t        *lvc;
-#endif
 };
 
 typedef struct be_lv_info_node_t be_lv_info_node_t;
@@ -102,15 +97,12 @@ static inline unsigned _be_is_live_xxx(const be_lv_t *li, const ir_node *block,
 {
        unsigned res;
 
-       if (li->nodes != NULL) {
+       if (li->sets_valid) {
                be_lv_info_node_t *info = be_lv_get(li, block, irn);
                res = info != NULL ? (info->flags & flags) != 0 : 0;
-       }
-
-#ifdef USE_LIVE_CHK
-       else
+       } else {
                res = (lv_chk_bl_xxx(li->lvc, block, irn) & flags) != 0;
-#endif
+       }
 
        return res;
 }
index 77006e6..83b60f6 100644 (file)
@@ -832,10 +832,9 @@ void assure_constraints(ir_graph *irg)
 
        ir_nodehashmap_destroy(&cenv.op_set);
        obstack_free(&cenv.obst, NULL);
-       be_liveness_invalidate(be_get_irg_liveness(irg));
+       be_invalidate_live_sets(irg);
 }
 
-
 /**
  * Push nodes that do not need to be permed through the Perm.
  * This is commonly a reload cascade at block ends.
@@ -1014,7 +1013,7 @@ void lower_nodes_after_ra(ir_graph *irg, int do_copy)
        env.do_copy = do_copy;
 
        /* we will need interference */
-       be_liveness_assure_chk(be_get_irg_liveness(irg));
+       be_assure_live_chk(irg);
 
        irg_walk_graph(irg, NULL, lower_nodes_after_ra_walker, &env);
 }
index 918e887..d6e5579 100644 (file)
@@ -429,6 +429,7 @@ static void initialize_birg(be_irg_t *birg, ir_graph *irg, be_main_env_t *env)
        birg->irg = irg;
        birg->main_env = env;
        obstack_init(&birg->obst);
+       birg->lv = be_liveness_new(irg);
 
        edges_deactivate_kind(irg, EDGE_KIND_DEP);
        edges_activate_kind(irg, EDGE_KIND_DEP);
index 14ce7b3..8ca92cf 100644 (file)
@@ -636,9 +636,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);
index ba0ae65..951e247 100644 (file)
@@ -324,10 +324,12 @@ ir_node *be_peephole_IncSP_IncSP(ir_node *node)
 
 void be_peephole_opt(ir_graph *irg)
 {
+#if 0
        /* we sometimes find BadE nodes in float apps like optest_float.c or
         * kahansum.c for example... */
-       be_liveness_invalidate(be_get_irg_liveness(irg));
-       be_liveness_assure_sets(be_assure_liveness(irg));
+       be_invalidate_live_sets(irg);
+#endif
+       be_assure_live_sets(irg);
 
        arch_env = be_get_irg_arch_env(irg);
        lv       = be_get_irg_liveness(irg);
index 9266204..338b7a4 100644 (file)
@@ -2010,8 +2010,8 @@ static void be_pref_alloc_cls(void)
 {
        size_t i;
 
-       lv = be_assure_liveness(irg);
-       be_liveness_assure_sets(lv);
+       be_assure_live_sets(irg);
+       lv = be_get_irg_liveness(irg);
 
        ir_reserve_resources(irg, IR_RESOURCE_IRN_LINK);
 
@@ -2109,8 +2109,7 @@ static void be_pref_alloc(ir_graph *new_irg)
 
                /* we most probably constructed new Phis so liveness info is invalid
                 * now */
-               /* TODO: test liveness_introduce */
-               be_liveness_invalidate(lv);
+               be_invalidate_live_sets(irg);
                free(normal_regs);
 
                stat_ev_ctx_pop("regcls");
index 3c1865c..0308ebf 100644 (file)
@@ -524,10 +524,10 @@ static trace_env_t *trace_init(ir_graph *irg)
 
        env->curr_time  = 0;
        env->sched_info = NEW_ARR_F(trace_irn_t, nn);
-       env->liveness   = be_liveness(irg);
+       env->liveness   = be_get_irg_liveness(irg);
        FIRM_DBG_REGISTER(env->dbg, "firm.be.sched.trace");
 
-       be_liveness_assure_chk(env->liveness);
+       be_assure_live_chk(irg);
        memset(env->sched_info, 0, nn * sizeof(*(env->sched_info)));
 
        return env;
@@ -540,7 +540,6 @@ static trace_env_t *trace_init(ir_graph *irg)
 static void trace_free(void *data)
 {
        trace_env_t *env = (trace_env_t*)data;
-       be_liveness_free(env->liveness);
        DEL_ARR_F(env->sched_info);
        free(env);
 }
index 5719205..fa542d9 100644 (file)
@@ -235,7 +235,7 @@ void be_pre_spill_prepare_constr(ir_graph *irg,
        env.irg = irg;
        env.cls = cls;
 
-       be_assure_liveness(irg);
+       be_assure_live_sets(irg);
 
        irg_block_walk_graph(irg, pre_spill_prepare_constr_walker, NULL, &env);
 }
index 90de2e7..7424d3d 100644 (file)
@@ -946,7 +946,7 @@ static void be_spill_belady(ir_graph *irg, const arch_register_class_t *rcls)
 {
        int i;
 
-       be_liveness_assure_sets(be_assure_liveness(irg));
+       be_assure_live_sets(irg);
 
        stat_ev_tim_push();
        assure_loopinfo(irg);
index ac33e1f..4f058bf 100644 (file)
@@ -369,7 +369,7 @@ static void be_spill_daemel(ir_graph *irg, const arch_register_class_t *new_cls)
        if (n_regs == 0)
                return;
 
-       be_liveness_assure_sets(be_assure_liveness(irg));
+       be_assure_live_sets(irg);
 
        spill_env     = be_new_spill_env(irg);
        cls           = new_cls;
index ce7e9c1..fe4df32 100644 (file)
@@ -752,7 +752,7 @@ be_fec_env_t *be_new_frame_entity_coalescer(ir_graph *irg)
 {
        be_fec_env_t *env = XMALLOCZ(be_fec_env_t);
 
-       be_liveness_assure_chk(be_assure_liveness(irg));
+       be_assure_live_chk(irg);
 
        obstack_init(&env->obst);
        env->irg            = irg;
index 079c879..a390ca2 100644 (file)
@@ -1041,7 +1041,7 @@ void be_insert_spills_reloads(spill_env_t *env)
 
        /* Matze: In theory be_ssa_construction should take care of the liveness...
         * try to disable this again in the future */
-       be_liveness_invalidate(be_get_irg_liveness(env->irg));
+       be_invalidate_live_sets(env->irg);
 
        be_remove_dead_nodes_from_schedule(env->irg);
 
index 168eaea..dc1180f 100644 (file)
@@ -365,11 +365,10 @@ void be_ssa_destruction(be_chordal_env_t *chordal_env)
        insert_all_perms_env_t insert_perms_env;
        pmap     *perm_map = pmap_create();
        ir_graph *irg      = chordal_env->irg;
-       be_lv_t  *lv       = be_assure_liveness(irg);
 
        FIRM_DBG_REGISTER(dbg, "ir.be.ssadestr");
 
-       be_liveness_invalidate(lv);
+       be_invalidate_live_sets(irg);
 
        /* create a map for fast lookup of perms: block --> perm */
        irg_walk_graph(irg, clear_link, collect_phis_walker, chordal_env);
@@ -379,20 +378,16 @@ void be_ssa_destruction(be_chordal_env_t *chordal_env)
        insert_perms_env.perm_map = perm_map;
        irg_block_walk_graph(irg, insert_all_perms_walker, NULL, &insert_perms_env);
 
-       // Matze: really needed here?
-       // Sebastian: Yes. the walker function uses interference.
-       be_liveness_invalidate(lv);
-
        if (chordal_env->opts->dump_flags & BE_CH_DUMP_SSADESTR)
                dump_ir_graph(irg, "ssa_destr_perms_placed");
 
-       be_liveness_assure_chk(lv);
+       be_assure_live_chk(irg);
 
        DBG((dbg, LEVEL_1, "Setting regs and placing dupls...\n"));
        irg_block_walk_graph(irg, set_regs_or_place_dupls_walker, NULL, chordal_env);
 
-       /* TODO: unfortunately updating doesn't work yet. */
-       be_liveness_invalidate(lv);
+       /* unfortunately updating doesn't work yet. */
+       be_invalidate_live_chk(irg);
 
        if (chordal_env->opts->dump_flags & BE_CH_DUMP_SSADESTR)
                dump_ir_graph(irg, "ssa_destr_regs_set");
index 1fc426d..b65552a 100644 (file)
@@ -105,7 +105,7 @@ void be_do_stat_reg_pressure(ir_graph *irg, const arch_register_class_t *cls)
        env.insn_count   = 0;
        env.max_pressure = 0;
        env.regpressure  = 0;
-       be_liveness_assure_sets(be_assure_liveness(irg));
+       be_assure_live_sets(irg);
        env.lv           = be_get_irg_liveness(irg);
        env.cls          = cls;
 
index 146640d..1e3bf3e 100644 (file)
@@ -525,9 +525,9 @@ void be_assure_state(ir_graph *irg, const arch_register_t *reg, void *func_env,
 {
        minibelady_env_t env;
        spill_info_t *info;
-       be_lv_t *lv = be_assure_liveness(irg);
+       be_lv_t *lv = be_get_irg_liveness(irg);
 
-       be_liveness_assure_sets(lv);
+       be_assure_live_sets(irg);
        assure_loopinfo(irg);
 
        obstack_init(&env.obst);
index 8b8e2ca..5158d4d 100644 (file)
@@ -420,9 +420,7 @@ void be_transform_graph(ir_graph *irg, arch_pretrans_nodes *func)
        free_loop_information(irg);
        clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
 
-       be_liveness_invalidate(be_get_irg_liveness(irg));
-       /* Hack for now, something is buggy with invalidate liveness... */
-       be_birg_from_irg(irg)->lv = NULL;
+       be_invalidate_live_chk(irg);
        be_invalidate_dom_front(irg);
 
        /* recalculate edges */
index a3614e1..d421fe6 100644 (file)
@@ -130,25 +130,21 @@ int be_verify_register_pressure(ir_graph *irg, const arch_register_class_t *cls)
 {
        be_verify_register_pressure_env_t env;
 
-       env.lv                  = be_liveness(irg);
+       env.lv                  = be_liveness_new(irg);
        env.irg                 = irg;
        env.cls                 = cls;
        env.registers_available = be_get_n_allocatable_regs(irg, cls);
        env.problem_found       = 0;
 
-       be_liveness_assure_sets(env.lv);
+       be_liveness_compute_sets(env.lv);
        irg_block_walk_graph(irg, verify_liveness_walker, NULL, &env);
        be_liveness_free(env.lv);
 
        return ! env.problem_found;
 }
 
-
-
 /*--------------------------------------------------------------------------- */
 
-
-
 typedef struct be_verify_schedule_env_t_ {
        int       problem_found; /**< flags indicating a problem */
        bitset_t *scheduled;     /**< bitset of scheduled nodes */
@@ -880,12 +876,11 @@ bool be_verify_register_allocation(ir_graph *new_irg)
 {
        irg           = new_irg;
        arch_env      = be_get_irg_arch_env(irg);
-       lv            = be_liveness(irg);
+       lv            = be_liveness_new(irg);
        problem_found = false;
 
-       be_liveness_assure_sets(lv);
+       be_liveness_compute_sets(lv);
        irg_block_walk_graph(irg, verify_block_register_allocation, NULL, NULL);
-
        be_liveness_free(lv);
 
        return !problem_found;
@@ -1001,7 +996,7 @@ static void lv_check_walker(ir_node *bl, void *data)
 void be_liveness_check(be_lv_t *lv)
 {
        lv_walker_t w;
-       be_lv_t *fresh = be_liveness(lv->irg);
+       be_lv_t *fresh = be_liveness_new(lv->irg);
 
        w.lv   = lv;
        w.data = fresh;
index faaade4..66f8ff4 100644 (file)
@@ -525,7 +525,10 @@ static void mark_non_address_nodes(ir_node *node, void *env)
 
 void ia32_calculate_non_address_mode_nodes(ir_graph *irg)
 {
-       be_lv_t *lv = be_assure_liveness(irg);
+       be_lv_t *lv;
+
+       be_assure_live_chk(irg);
+       lv = be_get_irg_liveness(irg);
 
        non_address_mode_nodes = bitset_malloc(get_irg_last_idx(irg));
 
index 5faca75..54e0680 100644 (file)
@@ -275,7 +275,7 @@ static void rewire_fpu_mode_nodes(ir_graph *irg)
                        be_liveness_update(lv, env.state_nodes[i]);
                }
        } else {
-               be_liveness_invalidate(be_get_irg_liveness(irg));
+               be_invalidate_live_sets(irg);
        }
 
        /* set registers for the phis */
@@ -288,7 +288,7 @@ static void rewire_fpu_mode_nodes(ir_graph *irg)
        be_ssa_construction_destroy(&senv);
        DEL_ARR_F(env.state_nodes);
 
-       be_liveness_invalidate(be_get_irg_liveness(irg));
+       be_invalidate_live_sets(irg);
 }
 
 void ia32_setup_fpu_mode(ir_graph *irg)
index 71795a1..81d4417 100644 (file)
@@ -2282,9 +2282,8 @@ void ia32_x87_simulate_graph(ir_graph *irg)
        sim.worklist = new_waitq();
        waitq_put(sim.worklist, start_block);
 
-       be_assure_liveness(irg);
+       be_assure_live_sets(irg);
        sim.lv = be_get_irg_liveness(irg);
-       be_liveness_assure_sets(sim.lv);
 
        /* Calculate the liveness for all nodes. We must precalculate this info,
         * because the simulator adds new nodes (possible before Phi nodes) which