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 assert(!is_Proj(before) && !be_is_Keep(before));
244 /* put reload into list */
245 rel = obstack_alloc(&env->obst, sizeof(rel[0]));
246 rel->next = info->reloaders;
247 rel->reloader = before;
248 rel->rematted_node = NULL;
250 rel->remat_cost_delta = REMAT_COST_INFINITE;
252 rel->remat_cost_delta = 0;
255 info->reloaders = rel;
256 assert(info->reload_cls == NULL || info->reload_cls == reload_cls);
257 info->reload_cls = reload_cls;
259 DBG((dbg, LEVEL_1, "creating spillinfo for %+F, will be reloaded before %+F, may%s be rematerialized\n",
260 to_spill, before, allow_remat ? "" : " not"));
264 * Returns the point at which you can insert a node that should be executed
265 * before block @p block when coming from pred @p pos.
268 ir_node *get_block_insertion_point(ir_node *block, int pos)
270 ir_node *predblock, *last;
272 /* simply add the reload to the beginning of the block if we only have 1
273 * predecessor. We don't need to check for phis as there can't be any in a
274 * block with only 1 pred. */
275 if(get_Block_n_cfgpreds(block) == 1) {
276 assert(!is_Phi(sched_first(block)));
277 return sched_first(block);
280 /* We have to reload the value in pred-block */
281 predblock = get_Block_cfgpred_block(block, pos);
282 last = sched_last(predblock);
284 /* we might have projs and keepanys behind the jump... */
285 while(is_Proj(last) || be_is_Keep(last)) {
286 last = sched_prev(last);
287 assert(!sched_is_end(last));
291 last = sched_next(last);
292 /* last node must be a cfop, only exception is the start block */
293 assert(last == get_irg_start_block(get_irn_irg(block)));
296 /* add the reload before the (cond-)jump */
300 void be_add_reload_on_edge(spill_env_t *env, ir_node *to_spill, ir_node *block,
301 int pos, const arch_register_class_t *reload_cls,
304 ir_node *before = get_block_insertion_point(block, pos);
305 be_add_reload(env, to_spill, before, reload_cls, allow_remat);
308 void be_spill_phi(spill_env_t *env, ir_node *node)
313 assert(is_Phi(node));
315 ir_nodeset_insert(&env->mem_phis, node);
317 /* create spillinfos for the phi arguments */
318 spill = get_spillinfo(env, node);
319 for(i = 0, arity = get_irn_arity(node); i < arity; ++i) {
320 ir_node *arg = get_irn_n(node, i);
321 get_spillinfo(env, arg);
324 /* if we had a spill for the phi value before, then remove this spill from
325 * schedule, as we will remove it in the insert spill/reload phase
327 if(spill->spill != NULL && !is_Phi(spill->spill)) {
328 assert(spill->old_spill == NULL);
329 spill->old_spill = spill->spill;
336 * / ___|_ __ ___ __ _| |_ ___ / ___| _ __ (_) | |___
337 * | | | '__/ _ \/ _` | __/ _ \ \___ \| '_ \| | | / __|
338 * | |___| | | __/ (_| | || __/ ___) | |_) | | | \__ \
339 * \____|_| \___|\__,_|\__\___| |____/| .__/|_|_|_|___/
344 * Schedules a node after an instruction. That is the place after all projs and
345 * phis that are scheduled after the instruction. This function also skips phi
346 * nodes at the beginning of a block
349 void sched_add_after_insn(ir_node *sched_after, ir_node *node)
351 ir_node *next = sched_next(sched_after);
352 while(is_Proj(next) || is_Phi(next) || be_is_Keep(next)) {
353 next = sched_next(next);
355 assert(next != NULL);
357 if(sched_is_end(next)) {
358 sched_add_after(sched_last(get_nodes_block(sched_after)), node);
360 sched_add_before(next, node);
367 * @param senv the spill environment
368 * @param irn the node that should be spilled
369 * @param ctx_irn an user of the spilled node
371 * @return a be_Spill node
374 void spill_irn(spill_env_t *env, spill_info_t *spillinfo)
376 optimization_state_t opt;
377 ir_node *to_spill = spillinfo->to_spill;
379 DBG((dbg, LEVEL_1, "spilling %+F ... ", to_spill));
381 /* Trying to spill an already spilled value, no need for a new spill
382 * node then, we can simply connect to the same one for this reload
384 * Normally reloads get simply rematerialized instead of spilled again; this
385 * can happen annyway when the reload is the pred of a phi to spill)
387 if (be_is_Reload(to_spill)) {
388 spillinfo->spill = get_irn_n(to_spill, be_pos_Reload_mem);
389 DB((dbg, LEVEL_1, "skip reload, using existing spill %+F\n", spillinfo->spill));
393 assert(!(arch_irn_is(env->arch_env, to_spill, dont_spill)
394 && "Attempt to spill a node marked 'dont_spill'"));
396 /* some backends have virtual noreg/unknown nodes that are not scheduled */
397 if(!sched_is_scheduled(to_spill)) {
398 spillinfo->spill = new_NoMem();
404 * We switch on optimizations here to get CSE. This is needed as the STA
405 * backends has some extra spill phases and we want to make use of those
406 * spills instead of creating new ones.
408 save_optimization_state(&opt);
410 spillinfo->spill = be_spill(env->arch_env, to_spill);
411 restore_optimization_state(&opt);
412 if (! sched_is_scheduled(spillinfo->spill)) {
413 DB((dbg, LEVEL_1, "add spill %+F after %+F\n", spillinfo->spill, to_spill));
414 #ifdef FIRM_STATISTICS
417 sched_add_after_insn(to_spill, spillinfo->spill);
419 DB((dbg, LEVEL_1, "re-using spill %+F after %+F\n", spillinfo->spill, to_spill));
424 void spill_node(spill_env_t *env, spill_info_t *spillinfo);
427 * If the first usage of a Phi result would be out of memory
428 * there is no sense in allocating a register for it.
429 * Thus we spill it and all its operands to the same spill slot.
430 * Therefore the phi/dataB becomes a phi/Memory
432 * @param senv the spill environment
433 * @param phi the Phi node that should be spilled
434 * @param ctx_irn an user of the spilled node
437 void spill_phi(spill_env_t *env, spill_info_t *spillinfo)
439 ir_node *phi = spillinfo->to_spill;
441 int arity = get_irn_arity(phi);
442 ir_node *block = get_nodes_block(phi);
447 DBG((dbg, LEVEL_1, "spilling Phi %+F:\n", phi));
448 /* build a new PhiM */
449 ins = alloca(sizeof(ir_node*) * arity);
450 for(i = 0; i < arity; ++i) {
451 ins[i] = get_irg_bad(env->irg);
453 spillinfo->spill = new_r_Phi(env->irg, block, arity, ins, mode_M);
454 #ifdef FIRM_STATISTICS
455 env->spilled_phi_count++;
458 for(i = 0; i < arity; ++i) {
459 ir_node *arg = get_irn_n(phi, i);
460 spill_info_t *arg_info = get_spillinfo(env, arg);
462 spill_node(env, arg_info);
464 set_irn_n(spillinfo->spill, i, arg_info->spill);
466 DBG((dbg, LEVEL_1, "... done spilling Phi %+F, created PhiM %+F\n", phi, spillinfo->spill));
468 /* rewire reloads from old_spill to phi */
469 if (spillinfo->old_spill != NULL) {
470 const ir_edge_t *edge, *next;
471 ir_node *old_spill = spillinfo->old_spill;
473 DBG((dbg, LEVEL_1, "old spill found, rewiring reloads:\n"));
475 foreach_out_edge_safe(old_spill, edge, next) {
476 ir_node *reload = get_edge_src_irn(edge);
477 int pos = get_edge_src_pos(edge);
479 DBG((dbg, LEVEL_1, "\tset input %d of %+F to %+F\n", pos, reload, spillinfo->spill));
481 assert(be_is_Reload(reload) || is_Phi(reload));
482 set_irn_n(reload, pos, spillinfo->spill);
484 DBG((dbg, LEVEL_1, "\tset input of %+F to BAD\n", old_spill));
485 set_irn_n(old_spill, be_pos_Spill_val, new_Bad());
486 /* sched_remove(old_spill); */
487 spillinfo->old_spill = NULL;
494 * @param senv the spill environment
495 * @param to_spill the node that should be spilled
498 void spill_node(spill_env_t *env, spill_info_t *spillinfo)
502 /* the node should be tagged for spilling already... */
503 if(spillinfo->spill != NULL)
506 to_spill = spillinfo->to_spill;
508 if (is_Phi(to_spill) && ir_nodeset_contains(&env->mem_phis, to_spill)) {
509 spill_phi(env, spillinfo);
511 spill_irn(env, spillinfo);
518 * | _ \ ___ _ __ ___ __ _| |_ ___ _ __(_) __ _| (_)_______
519 * | |_) / _ \ '_ ` _ \ / _` | __/ _ \ '__| |/ _` | | |_ / _ \
520 * | _ < __/ | | | | | (_| | || __/ | | | (_| | | |/ / __/
521 * |_| \_\___|_| |_| |_|\__,_|\__\___|_| |_|\__,_|_|_/___\___|
526 * Tests whether value @p arg is available before node @p reloader
527 * @returns 1 if value is available, 0 otherwise
530 int is_value_available(spill_env_t *env, ir_node *arg, ir_node *reloader)
532 if(is_Unknown(arg) || arg == new_NoMem())
538 if(arg == get_irg_frame(env->irg))
541 /* hack for now (happens when command should be inserted at end of block) */
542 if(is_Block(reloader)) {
547 * Ignore registers are always available
549 if(arch_irn_is(env->arch_env, arg, ignore)) {
553 /* the following test does not work while spilling,
554 * because the liveness info is not adapted yet to the effects of the
555 * additional spills/reloads.
558 /* we want to remat before the insn reloader
559 * thus an arguments is alive if
560 * - it interferes with the reloaders result
561 * - or it is (last-) used by reloader itself
563 if (values_interfere(env->birg->lv, reloader, arg)) {
567 arity = get_irn_arity(reloader);
568 for (i = 0; i < arity; ++i) {
569 ir_node *rel_arg = get_irn_n(reloader, i);
579 * Checks whether the node can principally be rematerialized
582 int is_remat_node(spill_env_t *env, ir_node *node)
584 const arch_env_t *arch_env = env->arch_env;
586 assert(!be_is_Spill(node));
588 if(arch_irn_is(arch_env, node, rematerializable))
595 * Check if a node is rematerializable. This tests for the following conditions:
597 * - The node itself is rematerializable
598 * - All arguments of the node are available or also rematerialisable
599 * - The costs for the rematerialisation operation is less or equal a limit
601 * Returns the costs needed for rematerialisation or something
602 * >= REMAT_COST_INFINITE if remat is not possible.
605 int check_remat_conditions_costs(spill_env_t *env, ir_node *spilled,
606 ir_node *reloader, int parentcosts)
612 if(!is_remat_node(env, spilled))
613 return REMAT_COST_INFINITE;
615 if(be_is_Reload(spilled)) {
618 costs += arch_get_op_estimated_cost(env->arch_env, spilled);
620 if(parentcosts + costs >= env->reload_cost + env->spill_cost) {
621 return REMAT_COST_INFINITE;
625 for(i = 0, arity = get_irn_arity(spilled); i < arity; ++i) {
626 ir_node *arg = get_irn_n(spilled, i);
628 if(is_value_available(env, arg, reloader))
631 /* we have to rematerialize the argument as well */
633 /* we only support rematerializing 1 argument at the moment,
634 * so that we don't have to care about register pressure
636 return REMAT_COST_INFINITE;
640 costs += check_remat_conditions_costs(env, arg, reloader, parentcosts + costs);
641 if(parentcosts + costs >= env->reload_cost + env->spill_cost)
642 return REMAT_COST_INFINITE;
649 * Re-materialize a node.
651 * @param senv the spill environment
652 * @param spilled the node that was spilled
653 * @param reloader a irn that requires a reload
656 ir_node *do_remat(spill_env_t *env, ir_node *spilled, ir_node *reloader)
663 if(is_Block(reloader)) {
666 bl = get_nodes_block(reloader);
669 ins = alloca(get_irn_arity(spilled) * sizeof(ins[0]));
670 for(i = 0, arity = get_irn_arity(spilled); i < arity; ++i) {
671 ir_node *arg = get_irn_n(spilled, i);
673 if(is_value_available(env, arg, reloader)) {
676 ins[i] = do_remat(env, arg, reloader);
677 #ifdef FIRM_STATISTICS
678 /* don't count the recursive call as remat */
684 /* create a copy of the node */
685 res = new_ir_node(get_irn_dbg_info(spilled), env->irg, bl,
686 get_irn_op(spilled), get_irn_mode(spilled),
687 get_irn_arity(spilled), ins);
688 copy_node_attr(spilled, res);
689 new_backedge_info(res);
692 DBG((dbg, LEVEL_1, "Insert remat %+F of %+F before reloader %+F\n", res, spilled, reloader));
694 /* insert in schedule */
695 sched_add_before(reloader, res);
696 #ifdef FIRM_STATISTICS
703 double be_get_spill_costs(spill_env_t *env, ir_node *to_spill, ir_node *after)
705 ir_node *block = get_nodes_block(after);
706 double freq = get_block_execfreq(env->exec_freq, block);
708 return env->spill_cost * freq;
711 double be_get_reload_costs(spill_env_t *env, ir_node *to_spill, ir_node *before)
713 ir_node *block = get_nodes_block(before);
714 double freq = get_block_execfreq(env->exec_freq, block);
717 /* is the node rematerializable? */
718 int costs = check_remat_conditions_costs(env, to_spill, before, 0);
719 if(costs < env->reload_cost)
723 return env->reload_cost * freq;
726 double be_get_reload_costs_on_edge(spill_env_t *env, ir_node *to_spill,
727 ir_node *block, int pos)
729 ir_node *before = get_block_insertion_point(block, pos);
730 return be_get_reload_costs(env, to_spill, before);
735 * |_ _|_ __ ___ ___ _ __| |_ | _ \ ___| | ___ __ _ __| |___
736 * | || '_ \/ __|/ _ \ '__| __| | |_) / _ \ |/ _ \ / _` |/ _` / __|
737 * | || | | \__ \ __/ | | |_ | _ < __/ | (_) | (_| | (_| \__ \
738 * |___|_| |_|___/\___|_| \__| |_| \_\___|_|\___/ \__,_|\__,_|___/
742 void be_insert_spills_reloads(spill_env_t *env)
744 const arch_env_t *arch_env = env->arch_env;
745 const ir_exec_freq *exec_freq = env->exec_freq;
747 ir_nodeset_iterator_t iter;
750 /* create all phi-ms first, this is needed so, that phis, hanging on
751 spilled phis work correctly */
752 foreach_ir_nodeset(&env->mem_phis, node, iter) {
753 spill_info_t *info = get_spillinfo(env, node);
754 spill_node(env, info);
757 /* process each spilled node */
758 for (si = set_first(env->spills); si; si = set_next(env->spills)) {
760 ir_node *to_spill = si->to_spill;
761 ir_mode *mode = get_irn_mode(to_spill);
762 ir_node **copies = NEW_ARR_F(ir_node*, 0);
763 double all_remat_costs = 0; /** costs when we would remat all nodes */
766 DBG((dbg, LEVEL_1, "\nhandling all reloaders of %+F:\n", to_spill));
768 /* determine possibility of rematerialisations */
770 for (rld = si->reloaders; rld != NULL; rld = rld->next) {
773 int remat_cost_delta;
775 ir_node *reloader = rld->reloader;
777 if(rld->rematted_node != NULL) {
778 DBG((dbg, LEVEL_2, "\tforced remat %+F before %+F\n",
779 rld->rematted_node, reloader));
782 if(rld->remat_cost_delta >= REMAT_COST_INFINITE) {
783 DBG((dbg, LEVEL_2, "\treload before %+F is forbidden\n",
785 all_remat_costs = REMAT_COST_INFINITE;
789 remat_cost = check_remat_conditions_costs(env, to_spill,
791 if(remat_cost >= REMAT_COST_INFINITE) {
792 DBG((dbg, LEVEL_2, "\tremat before %+F not possible\n",
794 rld->remat_cost_delta = REMAT_COST_INFINITE;
795 all_remat_costs = REMAT_COST_INFINITE;
799 remat_cost_delta = remat_cost - env->reload_cost;
800 rld->remat_cost_delta = remat_cost_delta;
801 block = get_nodes_block(reloader);
802 freq = get_block_execfreq(exec_freq, block);
803 all_remat_costs += remat_cost_delta * freq;
804 DBG((dbg, LEVEL_2, "\tremat costs delta before %+F: "
805 "%d (rel %f)\n", reloader, remat_cost_delta,
806 remat_cost_delta * freq));
808 if(all_remat_costs < REMAT_COST_INFINITE) {
809 ir_node *block = get_nodes_block(to_spill);
810 double freq = get_block_execfreq(exec_freq, block);
811 /* we don't need the costs for the spill if we can remat
813 all_remat_costs -= env->spill_cost * freq;
815 DBG((dbg, LEVEL_2, "\tspill costs %d (rel %f)\n",
816 env->spill_cost, env->spill_cost * freq));
819 if(all_remat_costs < 0) {
820 DBG((dbg, LEVEL_1, "\nforcing remats of all reloaders (%f)\n",
826 /* go through all reloads for this spill */
827 for (rld = si->reloaders; rld != NULL; rld = rld->next) {
828 ir_node *copy; /* a reload is a "copy" of the original value */
830 if (rld->rematted_node != NULL) {
831 copy = rld->rematted_node;
832 sched_add_before(rld->reloader, copy);
833 } else if (be_do_remats &&
834 (force_remat || rld->remat_cost_delta < 0)) {
835 copy = do_remat(env, to_spill, rld->reloader);
837 /* make sure we have a spill */
838 if (si->spill == NULL) {
842 /* create a reload */
843 copy = be_reload(arch_env, si->reload_cls, rld->reloader, mode,
845 #ifdef FIRM_STATISTICS
850 DBG((dbg, LEVEL_1, " %+F of %+F before %+F\n",
851 copy, to_spill, rld->reloader));
852 ARR_APP1(ir_node*, copies, copy);
855 /* if we had any reloads or remats, then we need to reconstruct the
856 * SSA form for the spilled value */
857 if (ARR_LEN(copies) > 0) {
858 be_ssa_construction_env_t senv;
859 /* be_lv_t *lv = be_get_birg_liveness(env->birg); */
861 be_ssa_construction_init(&senv, env->birg);
862 be_ssa_construction_add_copy(&senv, to_spill);
863 be_ssa_construction_add_copies(&senv, copies, ARR_LEN(copies));
864 be_ssa_construction_fix_users(&senv, to_spill);
867 /* no need to enable this as long as we invalidate liveness
868 after this function... */
869 be_ssa_construction_update_liveness_phis(&senv);
870 be_liveness_update(to_spill);
871 len = ARR_LEN(copies);
872 for(i = 0; i < len; ++i) {
873 be_liveness_update(lv, copies[i]);
876 be_ssa_construction_destroy(&senv);
880 si->reloaders = NULL;
883 #ifdef FIRM_STATISTICS
884 if (be_stat_ev_is_active()) {
885 be_stat_ev("spill_spills", env->spill_count);
886 be_stat_ev("spill_reloads", env->reload_count);
887 be_stat_ev("spill_remats", env->remat_count);
888 be_stat_ev("spill_spilled_phis", env->spilled_phi_count);
892 be_remove_dead_nodes_from_schedule(env->irg);
893 /* Matze: In theory be_ssa_construction should take care of the liveness...
894 * try to disable this again in the future */
895 be_invalidate_liveness(env->birg);
898 void be_init_spill(void)
900 FIRM_DBG_REGISTER(dbg, "firm.be.spill");
903 BE_REGISTER_MODULE_CONSTRUCTOR(be_init_spill);