do not free the graph after emitting it (this should only change the peak memory...
[libfirm] / ir / be / bespilldaemel.c
index 26ef48e..2950f69 100644 (file)
 
 /**
  * @file
- * @brief       Naiv spilling algorithm
+ * @brief       Naive spilling algorithm
  * @author      Matthias Braun
  * @date        20.09.2005
  * @version     $Id: bespillbelady.c 13913 2007-05-18 12:48:56Z matze $
- * @summary
- *   This implements a naiv spilling algorithm. It is design to produce similar
+ * @brief
+ *   This implements a naive spilling algorithm. It is designed to produce similar
  *   effects to the spill decisions produced by traditional graph coloring
  *   register allocators that spill while they are coloring the graph.
  *
@@ -33,9 +33,7 @@
  *   Spilling in this context means placing a spill instruction behind the
  *   definition of the value and a reload before each usage.
  */
-#ifdef HAVE_CONFIG_H
 #include "config.h"
-#endif
 
 #include "debug.h"
 
 #include "error.h"
 
 #include "beirg.h"
-#include "bespilloptions.h"
 #include "bespill.h"
+#include "bespillutil.h"
 #include "bemodule.h"
 #include "besched.h"
-#include "bearch_t.h"
+#include "bearch.h"
 #include "be_t.h"
-#include "benode_t.h"
+#include "benode.h"
 #include "beirg.h"
+#include "belive.h"
 
 DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
 
 static spill_env_t                 *spill_env;
 static int                          n_regs;
-static const arch_env_t            *arch_env;
 static const arch_register_class_t *cls;
 static const be_lv_t               *lv;
 static bitset_t                    *spilled_nodes;
@@ -188,7 +186,7 @@ static void do_spilling(ir_nodeset_t *live_nodes, ir_node *node)
                return;
        DBG((dbg, LEVEL_2, "\tspills needed after %+F: %d\n", node, spills_needed));
 
-       candidates = alloca(n_live_nodes * sizeof(candidates[0]));
+       candidates = ALLOCAN(spill_candidate_t, n_live_nodes);
 
        /* construct array with spill candidates and calculate their costs */
        i = 0;
@@ -223,7 +221,7 @@ static void do_spilling(ir_nodeset_t *live_nodes, ir_node *node)
                cand_node = candidate->node;
                ++cand_idx;
 
-               if (arch_irn_is(cand_node, dont_spill))
+               if (arch_irn_is(skip_Proj_const(cand_node), dont_spill))
                        continue;
 
                /* make sure the node is not an argument of the instruction */
@@ -316,7 +314,7 @@ static void spill_block(ir_node *block, void *data)
 
        /* construct set of live nodes at end of block */
        ir_nodeset_init(&live_nodes);
-       be_liveness_end_of_block(lv, arch_env, cls, block, &live_nodes);
+       be_liveness_end_of_block(lv, cls, block, &live_nodes);
 
        /* remove already spilled nodes from liveset */
        foreach_ir_nodeset(&live_nodes, node, iter) {
@@ -390,7 +388,6 @@ void be_spill_daemel(be_irg_t *birg, const arch_register_class_t *new_cls)
        be_liveness_assure_sets(be_assure_liveness(birg));
 
        spill_env     = be_new_spill_env(birg);
-       arch_env      = be_get_birg_arch_env(birg);
        cls           = new_cls;
        lv            = be_get_birg_liveness(birg);
        spilled_nodes = bitset_malloc(get_irg_last_idx(irg));