2 * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * @brief implementation of the spill/reload placement abstraction layer
23 * @author Daniel Grund, Sebastian Hack, Matthias Braun
36 #include "iredges_t.h"
37 #include "irbackedge_t.h"
47 #include "irnodeset.h"
51 #include "besched_t.h"
55 #include "bechordal_t.h"
56 #include "bejavacoal.h"
57 #include "benodesets.h"
58 #include "bespilloptions.h"
59 #include "bestatevent.h"
60 #include "bessaconstr.h"
62 #include "beintlive_t.h"
65 DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
67 #define REMAT_COST_INFINITE 1000
69 typedef struct reloader_t reloader_t;
73 ir_node *rematted_node;
74 int remat_cost_delta; /** costs needed for rematerialization,
75 compared to placing a reload */
78 typedef struct spill_info_t spill_info_t;
80 ir_node *to_spill; /**< the value that should get spilled */
81 reloader_t *reloaders; /**< list of places where the value should get
83 ir_node *spill; /**< the spill node, or a PhiM node */
84 ir_node *old_spill; /**< if we had the value of a phi spilled before but
85 not the phi itself then this field contains the
86 spill for the phi value */
87 const arch_register_class_t *reload_cls; /** the register class in which the
88 reload should be placed */
92 const arch_env_t *arch_env;
96 int spill_cost; /**< the cost of a single spill node */
97 int reload_cost; /**< the cost of a reload node */
98 set *spills; /**< all spill_info_t's, which must be
100 ir_nodeset_t mem_phis; /**< set of all spilled phis. */
101 ir_exec_freq *exec_freq;
103 #ifdef FIRM_STATISTICS
104 unsigned spill_count;
105 unsigned reload_count;
106 unsigned remat_count;
107 unsigned spilled_phi_count;
112 * Compare two spill infos.
115 int cmp_spillinfo(const void *x, const void *y, size_t size)
117 const spill_info_t *xx = x;
118 const spill_info_t *yy = y;
119 return xx->to_spill != yy->to_spill;
123 * Returns spill info for a specific value (the value that is to be spilled)
126 spill_info_t *get_spillinfo(const spill_env_t *env, ir_node *value)
128 spill_info_t info, *res;
129 int hash = nodeset_hash(value);
131 info.to_spill = value;
132 res = set_find(env->spills, &info, sizeof(info), hash);
135 info.reloaders = NULL;
137 info.old_spill = NULL;
138 info.reload_cls = NULL;
139 res = set_insert(env->spills, &info, sizeof(info), hash);
145 spill_env_t *be_new_spill_env(be_irg_t *birg)
147 const arch_env_t *arch_env = birg->main_env->arch_env;
149 spill_env_t *env = xmalloc(sizeof(env[0]));
150 env->spills = new_set(cmp_spillinfo, 1024);
151 env->irg = be_get_birg_irg(birg);
153 env->arch_env = arch_env;
154 ir_nodeset_init(&env->mem_phis);
155 env->spill_cost = arch_env->isa->spill_cost;
156 env->reload_cost = arch_env->isa->reload_cost;
157 env->exec_freq = be_get_birg_exec_freq(birg);
158 obstack_init(&env->obst);
160 #ifdef FIRM_STATISTICS
161 env->spill_count = 0;
162 env->reload_count = 0;
163 env->remat_count = 0;
164 env->spilled_phi_count = 0;
170 void be_delete_spill_env(spill_env_t *env)
172 del_set(env->spills);
173 ir_nodeset_destroy(&env->mem_phis);
174 obstack_free(&env->obst, NULL);
180 * | _ \| | __ _ ___ ___ | _ \ ___| | ___ __ _ __| |___
181 * | |_) | |/ _` |/ __/ _ \ | |_) / _ \ |/ _ \ / _` |/ _` / __|
182 * | __/| | (_| | (_| __/ | _ < __/ | (_) | (_| | (_| \__ \
183 * |_| |_|\__,_|\___\___| |_| \_\___|_|\___/ \__,_|\__,_|___/
187 void be_add_remat(spill_env_t *env, ir_node *to_spill, ir_node *before,
188 ir_node *rematted_node)
190 spill_info_t *spill_info;
191 reloader_t *reloader;
193 spill_info = get_spillinfo(env, to_spill);
195 /* add the remat information */
196 reloader = obstack_alloc(&env->obst, sizeof(reloader[0]));
197 reloader->next = spill_info->reloaders;
198 reloader->reloader = before;
199 reloader->rematted_node = rematted_node;
200 reloader->remat_cost_delta = 0; /* We will never have a cost win over a
201 reload since we're not even allowed to
204 spill_info->reloaders = reloader;
206 DBG((dbg, LEVEL_1, "creating spillinfo for %+F, will be rematerialized before %+F\n",
210 void be_add_reload(spill_env_t *env, ir_node *to_spill, ir_node *before,
211 const arch_register_class_t *reload_cls, int allow_remat)
216 info = get_spillinfo(env, to_spill);
218 if (is_Phi(to_spill)) {
221 /* create spillinfos for the phi arguments */
222 for (i = 0, arity = get_irn_arity(to_spill); i < arity; ++i) {
223 ir_node *arg = get_irn_n(to_spill, i);
224 get_spillinfo(env, arg);
228 /* hackery... sometimes the morgan algo spilled the value of a phi,
229 * the belady algo decides later to spill the whole phi, then sees the
230 * spill node and adds a reload for that spill node, problem is the
231 * reload gets attach to that same spill (and is totally unnecessary)
233 if (info->old_spill != NULL &&
234 (before == info->old_spill || value_dominates(before, info->old_spill)))
236 printf("spilledphi hack was needed...\n");
237 before = sched_next(info->old_spill);
242 /* put reload into list */
243 rel = obstack_alloc(&env->obst, sizeof(rel[0]));
244 rel->next = info->reloaders;
245 rel->reloader = before;
246 rel->rematted_node = NULL;
248 rel->remat_cost_delta = REMAT_COST_INFINITE;
250 rel->remat_cost_delta = 0;
253 info->reloaders = rel;
254 assert(info->reload_cls == NULL || info->reload_cls == reload_cls);
255 info->reload_cls = reload_cls;
257 DBG((dbg, LEVEL_1, "creating spillinfo for %+F, will be reloaded before %+F, may%s be rematerialized\n",
258 to_spill, before, allow_remat ? "" : " not"));
262 * Returns the point at which you can insert a node that should be executed
263 * before block @p block when coming from pred @p pos.
266 ir_node *get_block_insertion_point(ir_node *block, int pos)
268 ir_node *predblock, *last;
270 /* simply add the reload to the beginning of the block if we only have 1
271 * predecessor. We don't need to check for phis as there can't be any in a
272 * block with only 1 pred. */
273 if(get_Block_n_cfgpreds(block) == 1) {
274 assert(!is_Phi(sched_first(block)));
275 return sched_first(block);
278 /* We have to reload the value in pred-block */
279 predblock = get_Block_cfgpred_block(block, pos);
280 last = sched_last(predblock);
282 /* we might have projs and keepanys behind the jump... */
283 while(is_Proj(last) || be_is_Keep(last)) {
284 last = sched_prev(last);
285 assert(!sched_is_end(last));
289 last = sched_next(last);
290 /* last node must be a cfop, only exception is the start block */
291 assert(last == get_irg_start_block(get_irn_irg(block)));
294 /* add the reload before the (cond-)jump */
298 void be_add_reload_on_edge(spill_env_t *env, ir_node *to_spill, ir_node *block,
299 int pos, const arch_register_class_t *reload_cls,
302 ir_node *before = get_block_insertion_point(block, pos);
303 be_add_reload(env, to_spill, before, reload_cls, allow_remat);
306 void be_spill_phi(spill_env_t *env, ir_node *node)
311 assert(is_Phi(node));
313 ir_nodeset_insert(&env->mem_phis, node);
315 /* create spillinfos for the phi arguments */
316 spill = get_spillinfo(env, node);
317 for(i = 0, arity = get_irn_arity(node); i < arity; ++i) {
318 ir_node *arg = get_irn_n(node, i);
319 get_spillinfo(env, arg);
322 /* if we had a spill for the phi value before, then remove this spill from
323 * schedule, as we will remove it in the insert spill/reload phase
325 if(spill->spill != NULL && !is_Phi(spill->spill)) {
326 assert(spill->old_spill == NULL);
327 spill->old_spill = spill->spill;
334 * / ___|_ __ ___ __ _| |_ ___ / ___| _ __ (_) | |___
335 * | | | '__/ _ \/ _` | __/ _ \ \___ \| '_ \| | | / __|
336 * | |___| | | __/ (_| | || __/ ___) | |_) | | | \__ \
337 * \____|_| \___|\__,_|\__\___| |____/| .__/|_|_|_|___/
342 * Schedules a node after an instruction. That is the place after all projs and
343 * phis that are scheduled after the instruction. This function also skips phi
344 * nodes at the beginning of a block
347 void sched_add_after_insn(ir_node *sched_after, ir_node *node)
349 ir_node *next = sched_next(sched_after);
350 while(is_Proj(next) || is_Phi(next) || be_is_Keep(next)) {
351 next = sched_next(next);
353 assert(next != NULL);
355 if(sched_is_end(next)) {
356 sched_add_after(sched_last(get_nodes_block(sched_after)), node);
358 sched_add_before(next, node);
365 * @param senv the spill environment
366 * @param irn the node that should be spilled
367 * @param ctx_irn an user of the spilled node
369 * @return a be_Spill node
372 void spill_irn(spill_env_t *env, spill_info_t *spillinfo)
374 optimization_state_t opt;
375 ir_node *to_spill = spillinfo->to_spill;
377 DBG((dbg, LEVEL_1, "spilling %+F ... ", to_spill));
379 /* Trying to spill an already spilled value, no need for a new spill
380 * node then, we can simply connect to the same one for this reload
382 * Normally reloads get simply rematerialized instead of spilled again; this
383 * can happen annyway when the reload is the pred of a phi to spill)
385 if (be_is_Reload(to_spill)) {
386 spillinfo->spill = get_irn_n(to_spill, be_pos_Reload_mem);
387 DB((dbg, LEVEL_1, "skip reload, using existing spill %+F\n", spillinfo->spill));
391 assert(!(arch_irn_is(env->arch_env, to_spill, dont_spill)
392 && "Attempt to spill a node marked 'dont_spill'"));
394 /* some backends have virtual noreg/unknown nodes that are not scheduled */
395 if(!sched_is_scheduled(to_spill)) {
396 spillinfo->spill = new_NoMem();
402 * We switch on optimizations here to get CSE. This is needed as the STA
403 * backends has some extra spill phases and we want to make use of those
404 * spills instead of creating new ones.
406 save_optimization_state(&opt);
408 spillinfo->spill = be_spill(env->arch_env, to_spill);
409 restore_optimization_state(&opt);
410 if (! sched_is_scheduled(spillinfo->spill)) {
411 DB((dbg, LEVEL_1, "add spill %+F after %+F\n", spillinfo->spill, to_spill));
412 #ifdef FIRM_STATISTICS
415 sched_add_after_insn(to_spill, spillinfo->spill);
417 DB((dbg, LEVEL_1, "re-using spill %+F after %+F\n", spillinfo->spill, to_spill));
422 void spill_node(spill_env_t *env, spill_info_t *spillinfo);
425 * If the first usage of a Phi result would be out of memory
426 * there is no sense in allocating a register for it.
427 * Thus we spill it and all its operands to the same spill slot.
428 * Therefore the phi/dataB becomes a phi/Memory
430 * @param senv the spill environment
431 * @param phi the Phi node that should be spilled
432 * @param ctx_irn an user of the spilled node
435 void spill_phi(spill_env_t *env, spill_info_t *spillinfo)
437 ir_node *phi = spillinfo->to_spill;
439 int arity = get_irn_arity(phi);
440 ir_node *block = get_nodes_block(phi);
445 DBG((dbg, LEVEL_1, "spilling Phi %+F:\n", phi));
446 /* build a new PhiM */
447 ins = alloca(sizeof(ir_node*) * arity);
448 for(i = 0; i < arity; ++i) {
449 ins[i] = get_irg_bad(env->irg);
451 spillinfo->spill = new_r_Phi(env->irg, block, arity, ins, mode_M);
452 #ifdef FIRM_STATISTICS
453 env->spilled_phi_count++;
456 for(i = 0; i < arity; ++i) {
457 ir_node *arg = get_irn_n(phi, i);
458 spill_info_t *arg_info = get_spillinfo(env, arg);
460 spill_node(env, arg_info);
462 set_irn_n(spillinfo->spill, i, arg_info->spill);
464 DBG((dbg, LEVEL_1, "... done spilling Phi %+F, created PhiM %+F\n", phi, spillinfo->spill));
466 /* rewire reloads from old_spill to phi */
467 if (spillinfo->old_spill != NULL) {
468 const ir_edge_t *edge, *next;
469 ir_node *old_spill = spillinfo->old_spill;
471 DBG((dbg, LEVEL_1, "old spill found, rewiring reloads:\n"));
473 foreach_out_edge_safe(old_spill, edge, next) {
474 ir_node *reload = get_edge_src_irn(edge);
475 int pos = get_edge_src_pos(edge);
477 DBG((dbg, LEVEL_1, "\tset input %d of %+F to %+F\n", pos, reload, spillinfo->spill));
479 assert(be_is_Reload(reload) || is_Phi(reload));
480 set_irn_n(reload, pos, spillinfo->spill);
482 DBG((dbg, LEVEL_1, "\tset input of %+F to BAD\n", old_spill));
483 set_irn_n(old_spill, be_pos_Spill_val, new_Bad());
484 /* sched_remove(old_spill); */
485 spillinfo->old_spill = NULL;
492 * @param senv the spill environment
493 * @param to_spill the node that should be spilled
496 void spill_node(spill_env_t *env, spill_info_t *spillinfo)
500 /* the node should be tagged for spilling already... */
501 if(spillinfo->spill != NULL)
504 to_spill = spillinfo->to_spill;
506 if (is_Phi(to_spill) && ir_nodeset_contains(&env->mem_phis, to_spill)) {
507 spill_phi(env, spillinfo);
509 spill_irn(env, spillinfo);
516 * | _ \ ___ _ __ ___ __ _| |_ ___ _ __(_) __ _| (_)_______
517 * | |_) / _ \ '_ ` _ \ / _` | __/ _ \ '__| |/ _` | | |_ / _ \
518 * | _ < __/ | | | | | (_| | || __/ | | | (_| | | |/ / __/
519 * |_| \_\___|_| |_| |_|\__,_|\__\___|_| |_|\__,_|_|_/___\___|
524 * Tests whether value @p arg is available before node @p reloader
525 * @returns 1 if value is available, 0 otherwise
528 int is_value_available(spill_env_t *env, ir_node *arg, ir_node *reloader)
530 if(is_Unknown(arg) || arg == new_NoMem())
536 if(arg == get_irg_frame(env->irg))
539 /* hack for now (happens when command should be inserted at end of block) */
540 if(is_Block(reloader)) {
545 * Ignore registers are always available
547 if(arch_irn_is(env->arch_env, arg, ignore)) {
551 /* the following test does not work while spilling,
552 * because the liveness info is not adapted yet to the effects of the
553 * additional spills/reloads.
556 /* we want to remat before the insn reloader
557 * thus an arguments is alive if
558 * - it interferes with the reloaders result
559 * - or it is (last-) used by reloader itself
561 if (values_interfere(env->birg->lv, reloader, arg)) {
565 arity = get_irn_arity(reloader);
566 for (i = 0; i < arity; ++i) {
567 ir_node *rel_arg = get_irn_n(reloader, i);
577 * Checks whether the node can principally be rematerialized
580 int is_remat_node(spill_env_t *env, ir_node *node)
582 const arch_env_t *arch_env = env->arch_env;
584 assert(!be_is_Spill(node));
586 if(arch_irn_is(arch_env, node, rematerializable))
593 * Check if a node is rematerializable. This tests for the following conditions:
595 * - The node itself is rematerializable
596 * - All arguments of the node are available or also rematerialisable
597 * - The costs for the rematerialisation operation is less or equal a limit
599 * Returns the costs needed for rematerialisation or something
600 * >= REMAT_COST_INFINITE if remat is not possible.
603 int check_remat_conditions_costs(spill_env_t *env, ir_node *spilled,
604 ir_node *reloader, int parentcosts)
610 if(!is_remat_node(env, spilled))
611 return REMAT_COST_INFINITE;
613 if(be_is_Reload(spilled)) {
616 costs += arch_get_op_estimated_cost(env->arch_env, spilled);
618 if(parentcosts + costs >= env->reload_cost + env->spill_cost) {
619 return REMAT_COST_INFINITE;
623 for(i = 0, arity = get_irn_arity(spilled); i < arity; ++i) {
624 ir_node *arg = get_irn_n(spilled, i);
626 if(is_value_available(env, arg, reloader))
629 /* we have to rematerialize the argument as well */
631 /* we only support rematerializing 1 argument at the moment,
632 * so that we don't have to care about register pressure
634 return REMAT_COST_INFINITE;
638 costs += check_remat_conditions_costs(env, arg, reloader, parentcosts + costs);
639 if(parentcosts + costs >= env->reload_cost + env->spill_cost)
640 return REMAT_COST_INFINITE;
647 * Re-materialize a node.
649 * @param senv the spill environment
650 * @param spilled the node that was spilled
651 * @param reloader a irn that requires a reload
654 ir_node *do_remat(spill_env_t *env, ir_node *spilled, ir_node *reloader)
661 if(is_Block(reloader)) {
664 bl = get_nodes_block(reloader);
667 ins = alloca(get_irn_arity(spilled) * sizeof(ins[0]));
668 for(i = 0, arity = get_irn_arity(spilled); i < arity; ++i) {
669 ir_node *arg = get_irn_n(spilled, i);
671 if(is_value_available(env, arg, reloader)) {
674 ins[i] = do_remat(env, arg, reloader);
675 #ifdef FIRM_STATISTICS
676 /* don't count the recursive call as remat */
682 /* create a copy of the node */
683 res = new_ir_node(get_irn_dbg_info(spilled), env->irg, bl,
684 get_irn_op(spilled), get_irn_mode(spilled),
685 get_irn_arity(spilled), ins);
686 copy_node_attr(spilled, res);
687 new_backedge_info(res);
690 DBG((dbg, LEVEL_1, "Insert remat %+F of %+F before reloader %+F\n", res, spilled, reloader));
692 /* insert in schedule */
693 sched_add_before(reloader, res);
694 #ifdef FIRM_STATISTICS
701 double be_get_spill_costs(spill_env_t *env, ir_node *to_spill, ir_node *after)
703 ir_node *block = get_nodes_block(after);
704 double freq = get_block_execfreq(env->exec_freq, block);
706 return env->spill_cost * freq;
709 double be_get_reload_costs(spill_env_t *env, ir_node *to_spill, ir_node *before)
711 ir_node *block = get_nodes_block(before);
712 double freq = get_block_execfreq(env->exec_freq, block);
715 /* is the node rematerializable? */
716 int costs = check_remat_conditions_costs(env, to_spill, before, 0);
717 if(costs < env->reload_cost)
721 return env->reload_cost * freq;
724 double be_get_reload_costs_on_edge(spill_env_t *env, ir_node *to_spill,
725 ir_node *block, int pos)
727 ir_node *before = get_block_insertion_point(block, pos);
728 return be_get_reload_costs(env, to_spill, before);
733 * |_ _|_ __ ___ ___ _ __| |_ | _ \ ___| | ___ __ _ __| |___
734 * | || '_ \/ __|/ _ \ '__| __| | |_) / _ \ |/ _ \ / _` |/ _` / __|
735 * | || | | \__ \ __/ | | |_ | _ < __/ | (_) | (_| | (_| \__ \
736 * |___|_| |_|___/\___|_| \__| |_| \_\___|_|\___/ \__,_|\__,_|___/
740 void be_insert_spills_reloads(spill_env_t *env)
742 const arch_env_t *arch_env = env->arch_env;
743 const ir_exec_freq *exec_freq = env->exec_freq;
745 ir_nodeset_iterator_t iter;
748 /* create all phi-ms first, this is needed so, that phis, hanging on
749 spilled phis work correctly */
750 foreach_ir_nodeset(&env->mem_phis, node, iter) {
751 spill_info_t *info = get_spillinfo(env, node);
752 spill_node(env, info);
755 /* process each spilled node */
756 for (si = set_first(env->spills); si; si = set_next(env->spills)) {
758 ir_node *to_spill = si->to_spill;
759 ir_mode *mode = get_irn_mode(to_spill);
760 ir_node **copies = NEW_ARR_F(ir_node*, 0);
761 double all_remat_costs = 0; /** costs when we would remat all nodes */
764 DBG((dbg, LEVEL_1, "\nhandling all reloaders of %+F:\n", to_spill));
766 /* determine possibility of rematerialisations */
768 for (rld = si->reloaders; rld != NULL; rld = rld->next) {
771 int remat_cost_delta;
773 ir_node *reloader = rld->reloader;
775 if(rld->rematted_node != NULL) {
776 DBG((dbg, LEVEL_2, "\tforced remat %+F before %+F\n",
777 rld->rematted_node, reloader));
780 if(rld->remat_cost_delta >= REMAT_COST_INFINITE) {
781 DBG((dbg, LEVEL_2, "\treload before %+F is forbidden\n",
783 all_remat_costs = REMAT_COST_INFINITE;
787 remat_cost = check_remat_conditions_costs(env, to_spill,
789 if(remat_cost >= REMAT_COST_INFINITE) {
790 DBG((dbg, LEVEL_2, "\tremat before %+F not possible\n",
792 rld->remat_cost_delta = REMAT_COST_INFINITE;
793 all_remat_costs = REMAT_COST_INFINITE;
797 remat_cost_delta = remat_cost - env->reload_cost;
798 rld->remat_cost_delta = remat_cost_delta;
799 block = get_nodes_block(reloader);
800 freq = get_block_execfreq(exec_freq, block);
801 all_remat_costs += remat_cost_delta * freq;
802 DBG((dbg, LEVEL_2, "\tremat costs delta before %+F: "
803 "%d (rel %f)\n", reloader, remat_cost_delta,
804 remat_cost_delta * freq));
806 if(all_remat_costs < REMAT_COST_INFINITE) {
807 ir_node *block = get_nodes_block(to_spill);
808 double freq = get_block_execfreq(exec_freq, block);
809 /* we don't need the costs for the spill if we can remat
811 all_remat_costs -= env->spill_cost * freq;
813 DBG((dbg, LEVEL_2, "\tspill costs %d (rel %f)\n",
814 env->spill_cost, env->spill_cost * freq));
817 if(all_remat_costs < 0) {
818 DBG((dbg, LEVEL_1, "\nforcing remats of all reloaders (%f)\n",
824 /* go through all reloads for this spill */
825 for (rld = si->reloaders; rld != NULL; rld = rld->next) {
826 ir_node *copy; /* a reload is a "copy" of the original value */
828 if (rld->rematted_node != NULL) {
829 copy = rld->rematted_node;
830 sched_add_before(rld->reloader, copy);
831 } else if (be_do_remats &&
832 (force_remat || rld->remat_cost_delta < 0)) {
833 copy = do_remat(env, to_spill, rld->reloader);
835 /* make sure we have a spill */
836 if (si->spill == NULL) {
840 /* create a reload */
841 copy = be_reload(arch_env, si->reload_cls, rld->reloader, mode,
843 #ifdef FIRM_STATISTICS
848 DBG((dbg, LEVEL_1, " %+F of %+F before %+F\n",
849 copy, to_spill, rld->reloader));
850 ARR_APP1(ir_node*, copies, copy);
853 /* if we had any reloads or remats, then we need to reconstruct the
854 * SSA form for the spilled value */
855 if (ARR_LEN(copies) > 0) {
856 be_ssa_construction_env_t senv;
857 /* be_lv_t *lv = be_get_birg_liveness(env->birg); */
859 be_ssa_construction_init(&senv, env->birg);
860 be_ssa_construction_add_copy(&senv, to_spill);
861 be_ssa_construction_add_copies(&senv, copies, ARR_LEN(copies));
862 be_ssa_construction_fix_users(&senv, to_spill);
865 /* no need to enable this as long as we invalidate liveness
866 after this function... */
867 be_ssa_construction_update_liveness_phis(&senv);
868 be_liveness_update(to_spill);
869 len = ARR_LEN(copies);
870 for(i = 0; i < len; ++i) {
871 be_liveness_update(lv, copies[i]);
874 be_ssa_construction_destroy(&senv);
878 si->reloaders = NULL;
881 #ifdef FIRM_STATISTICS
882 if (be_stat_ev_is_active()) {
883 be_stat_ev("spill_spills", env->spill_count);
884 be_stat_ev("spill_reloads", env->reload_count);
885 be_stat_ev("spill_remats", env->remat_count);
886 be_stat_ev("spill_spilled_phis", env->spilled_phi_count);
890 be_remove_dead_nodes_from_schedule(env->irg);
891 /* Matze: In theory be_ssa_construction should take care of the liveness...
892 * try to disable this again in the future */
893 be_invalidate_liveness(env->birg);
896 void be_init_spill(void)
898 FIRM_DBG_REGISTER(dbg, "firm.be.spill");
901 BE_REGISTER_MODULE_CONSTRUCTOR(be_init_spill);