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;
121 return xx->to_spill != yy->to_spill;
125 * Returns spill info for a specific value (the value that is to be spilled)
128 spill_info_t *get_spillinfo(const spill_env_t *env, ir_node *value)
130 spill_info_t info, *res;
131 int hash = nodeset_hash(value);
133 info.to_spill = value;
134 res = set_find(env->spills, &info, sizeof(info), hash);
137 info.reloaders = NULL;
139 info.old_spill = NULL;
140 info.reload_cls = NULL;
141 res = set_insert(env->spills, &info, sizeof(info), hash);
147 spill_env_t *be_new_spill_env(be_irg_t *birg)
149 const arch_env_t *arch_env = birg->main_env->arch_env;
151 spill_env_t *env = xmalloc(sizeof(env[0]));
152 env->spills = new_set(cmp_spillinfo, 1024);
153 env->irg = be_get_birg_irg(birg);
155 env->arch_env = arch_env;
156 ir_nodeset_init(&env->mem_phis);
157 env->spill_cost = arch_env->isa->spill_cost;
158 env->reload_cost = arch_env->isa->reload_cost;
159 env->exec_freq = be_get_birg_exec_freq(birg);
160 obstack_init(&env->obst);
162 #ifdef FIRM_STATISTICS
163 env->spill_count = 0;
164 env->reload_count = 0;
165 env->remat_count = 0;
166 env->spilled_phi_count = 0;
172 void be_delete_spill_env(spill_env_t *env)
174 del_set(env->spills);
175 ir_nodeset_destroy(&env->mem_phis);
176 obstack_free(&env->obst, NULL);
182 * | _ \| | __ _ ___ ___ | _ \ ___| | ___ __ _ __| |___
183 * | |_) | |/ _` |/ __/ _ \ | |_) / _ \ |/ _ \ / _` |/ _` / __|
184 * | __/| | (_| | (_| __/ | _ < __/ | (_) | (_| | (_| \__ \
185 * |_| |_|\__,_|\___\___| |_| \_\___|_|\___/ \__,_|\__,_|___/
189 void be_add_remat(spill_env_t *env, ir_node *to_spill, ir_node *before,
190 ir_node *rematted_node)
192 spill_info_t *spill_info;
193 reloader_t *reloader;
195 spill_info = get_spillinfo(env, to_spill);
197 /* add the remat information */
198 reloader = obstack_alloc(&env->obst, sizeof(reloader[0]));
199 reloader->next = spill_info->reloaders;
200 reloader->reloader = before;
201 reloader->rematted_node = rematted_node;
202 reloader->remat_cost_delta = 0; /* We will never have a cost win over a
203 reload since we're not even allowed to
206 spill_info->reloaders = reloader;
208 DBG((dbg, LEVEL_1, "creating spillinfo for %+F, will be rematerialized before %+F\n",
212 void be_add_reload(spill_env_t *env, ir_node *to_spill, ir_node *before,
213 const arch_register_class_t *reload_cls, int allow_remat)
218 info = get_spillinfo(env, to_spill);
220 if (is_Phi(to_spill)) {
223 /* create spillinfos for the phi arguments */
224 for (i = 0, arity = get_irn_arity(to_spill); i < arity; ++i) {
225 ir_node *arg = get_irn_n(to_spill, i);
226 get_spillinfo(env, arg);
230 /* hackery... sometimes the morgan algo spilled the value of a phi,
231 * the belady algo decides later to spill the whole phi, then sees the
232 * spill node and adds a reload for that spill node, problem is the
233 * reload gets attach to that same spill (and is totally unnecessary)
235 if (info->old_spill != NULL &&
236 (before == info->old_spill || value_dominates(before, info->old_spill)))
238 printf("spilledphi hack was needed...\n");
239 before = sched_next(info->old_spill);
244 assert(!is_Proj(before) && !be_is_Keep(before));
246 /* put reload into list */
247 rel = obstack_alloc(&env->obst, sizeof(rel[0]));
248 rel->next = info->reloaders;
249 rel->reloader = before;
250 rel->rematted_node = NULL;
252 rel->remat_cost_delta = REMAT_COST_INFINITE;
254 rel->remat_cost_delta = 0;
257 info->reloaders = rel;
258 assert(info->reload_cls == NULL || info->reload_cls == reload_cls);
259 info->reload_cls = reload_cls;
261 DBG((dbg, LEVEL_1, "creating spillinfo for %+F, will be reloaded before %+F, may%s be rematerialized\n",
262 to_spill, before, allow_remat ? "" : " not"));
266 * Returns the point at which you can insert a node that should be executed
267 * before block @p block when coming from pred @p pos.
270 ir_node *get_block_insertion_point(ir_node *block, int pos)
272 ir_node *predblock, *last;
274 /* simply add the reload to the beginning of the block if we only have 1
275 * predecessor. We don't need to check for phis as there can't be any in a
276 * block with only 1 pred. */
277 if(get_Block_n_cfgpreds(block) == 1) {
278 assert(!is_Phi(sched_first(block)));
279 return sched_first(block);
282 /* We have to reload the value in pred-block */
283 predblock = get_Block_cfgpred_block(block, pos);
284 last = sched_last(predblock);
286 /* we might have projs and keepanys behind the jump... */
287 while(is_Proj(last) || be_is_Keep(last)) {
288 last = sched_prev(last);
289 assert(!sched_is_end(last));
293 last = sched_next(last);
294 /* last node must be a cfop, only exception is the start block */
295 assert(last == get_irg_start_block(get_irn_irg(block)));
298 /* add the reload before the (cond-)jump */
302 void be_add_reload_on_edge(spill_env_t *env, ir_node *to_spill, ir_node *block,
303 int pos, const arch_register_class_t *reload_cls,
306 ir_node *before = get_block_insertion_point(block, pos);
307 be_add_reload(env, to_spill, before, reload_cls, allow_remat);
310 void be_spill_phi(spill_env_t *env, ir_node *node)
315 assert(is_Phi(node));
317 ir_nodeset_insert(&env->mem_phis, node);
319 /* create spillinfos for the phi arguments */
320 spill = get_spillinfo(env, node);
321 for(i = 0, arity = get_irn_arity(node); i < arity; ++i) {
322 ir_node *arg = get_irn_n(node, i);
323 get_spillinfo(env, arg);
326 /* if we had a spill for the phi value before, then remove this spill from
327 * schedule, as we will remove it in the insert spill/reload phase
329 if(spill->spill != NULL && !is_Phi(spill->spill)) {
330 assert(spill->old_spill == NULL);
331 spill->old_spill = spill->spill;
338 * / ___|_ __ ___ __ _| |_ ___ / ___| _ __ (_) | |___
339 * | | | '__/ _ \/ _` | __/ _ \ \___ \| '_ \| | | / __|
340 * | |___| | | __/ (_| | || __/ ___) | |_) | | | \__ \
341 * \____|_| \___|\__,_|\__\___| |____/| .__/|_|_|_|___/
346 * Schedules a node after an instruction. That is the place after all projs and
347 * phis that are scheduled after the instruction. This function also skips phi
348 * nodes at the beginning of a block
351 void sched_add_after_insn(ir_node *sched_after, ir_node *node)
353 ir_node *next = sched_next(sched_after);
354 while(is_Proj(next) || is_Phi(next) || be_is_Keep(next)) {
355 next = sched_next(next);
357 assert(next != NULL);
359 if(sched_is_end(next)) {
360 sched_add_after(sched_last(get_nodes_block(sched_after)), node);
362 sched_add_before(next, node);
369 * @param senv the spill environment
370 * @param irn the node that should be spilled
371 * @param ctx_irn an user of the spilled node
373 * @return a be_Spill node
376 void spill_irn(spill_env_t *env, spill_info_t *spillinfo)
378 optimization_state_t opt;
379 ir_node *to_spill = spillinfo->to_spill;
381 DBG((dbg, LEVEL_1, "spilling %+F ... ", to_spill));
383 /* Trying to spill an already spilled value, no need for a new spill
384 * node then, we can simply connect to the same one for this reload
386 * Normally reloads get simply rematerialized instead of spilled again; this
387 * can happen annyway when the reload is the pred of a phi to spill)
389 if (be_is_Reload(to_spill)) {
390 spillinfo->spill = get_irn_n(to_spill, be_pos_Reload_mem);
391 DB((dbg, LEVEL_1, "skip reload, using existing spill %+F\n", spillinfo->spill));
395 assert(!(arch_irn_is(env->arch_env, to_spill, dont_spill)
396 && "Attempt to spill a node marked 'dont_spill'"));
398 /* some backends have virtual noreg/unknown nodes that are not scheduled */
399 if(!sched_is_scheduled(to_spill)) {
400 spillinfo->spill = new_NoMem();
406 * We switch on optimizations here to get CSE. This is needed as the STA
407 * backends has some extra spill phases and we want to make use of those
408 * spills instead of creating new ones.
410 save_optimization_state(&opt);
412 spillinfo->spill = be_spill(env->arch_env, to_spill);
413 restore_optimization_state(&opt);
414 if (! sched_is_scheduled(spillinfo->spill)) {
415 DB((dbg, LEVEL_1, "add spill %+F after %+F\n", spillinfo->spill, to_spill));
416 #ifdef FIRM_STATISTICS
419 sched_add_after_insn(to_spill, spillinfo->spill);
421 DB((dbg, LEVEL_1, "re-using spill %+F after %+F\n", spillinfo->spill, to_spill));
426 void spill_node(spill_env_t *env, spill_info_t *spillinfo);
429 * If the first usage of a Phi result would be out of memory
430 * there is no sense in allocating a register for it.
431 * Thus we spill it and all its operands to the same spill slot.
432 * Therefore the phi/dataB becomes a phi/Memory
434 * @param senv the spill environment
435 * @param phi the Phi node that should be spilled
436 * @param ctx_irn an user of the spilled node
439 void spill_phi(spill_env_t *env, spill_info_t *spillinfo)
441 ir_node *phi = spillinfo->to_spill;
443 int arity = get_irn_arity(phi);
444 ir_node *block = get_nodes_block(phi);
449 DBG((dbg, LEVEL_1, "spilling Phi %+F:\n", phi));
450 /* build a new PhiM */
451 ins = alloca(sizeof(ir_node*) * arity);
452 for(i = 0; i < arity; ++i) {
453 ins[i] = get_irg_bad(env->irg);
455 spillinfo->spill = new_r_Phi(env->irg, block, arity, ins, mode_M);
456 #ifdef FIRM_STATISTICS
457 env->spilled_phi_count++;
460 for(i = 0; i < arity; ++i) {
461 ir_node *arg = get_irn_n(phi, i);
462 spill_info_t *arg_info = get_spillinfo(env, arg);
464 spill_node(env, arg_info);
466 set_irn_n(spillinfo->spill, i, arg_info->spill);
468 DBG((dbg, LEVEL_1, "... done spilling Phi %+F, created PhiM %+F\n", phi, spillinfo->spill));
470 /* rewire reloads from old_spill to phi */
471 if (spillinfo->old_spill != NULL) {
472 const ir_edge_t *edge, *next;
473 ir_node *old_spill = spillinfo->old_spill;
475 DBG((dbg, LEVEL_1, "old spill found, rewiring reloads:\n"));
477 foreach_out_edge_safe(old_spill, edge, next) {
478 ir_node *reload = get_edge_src_irn(edge);
479 int pos = get_edge_src_pos(edge);
481 DBG((dbg, LEVEL_1, "\tset input %d of %+F to %+F\n", pos, reload, spillinfo->spill));
483 assert(be_is_Reload(reload) || is_Phi(reload));
484 set_irn_n(reload, pos, spillinfo->spill);
486 DBG((dbg, LEVEL_1, "\tset input of %+F to BAD\n", old_spill));
487 set_irn_n(old_spill, be_pos_Spill_val, new_Bad());
488 /* sched_remove(old_spill); */
489 spillinfo->old_spill = NULL;
496 * @param senv the spill environment
497 * @param to_spill the node that should be spilled
500 void spill_node(spill_env_t *env, spill_info_t *spillinfo)
504 /* the node should be tagged for spilling already... */
505 if(spillinfo->spill != NULL)
508 to_spill = spillinfo->to_spill;
510 if (is_Phi(to_spill) && ir_nodeset_contains(&env->mem_phis, to_spill)) {
511 spill_phi(env, spillinfo);
513 spill_irn(env, spillinfo);
520 * | _ \ ___ _ __ ___ __ _| |_ ___ _ __(_) __ _| (_)_______
521 * | |_) / _ \ '_ ` _ \ / _` | __/ _ \ '__| |/ _` | | |_ / _ \
522 * | _ < __/ | | | | | (_| | || __/ | | | (_| | | |/ / __/
523 * |_| \_\___|_| |_| |_|\__,_|\__\___|_| |_|\__,_|_|_/___\___|
528 * Tests whether value @p arg is available before node @p reloader
529 * @returns 1 if value is available, 0 otherwise
532 int is_value_available(spill_env_t *env, ir_node *arg, ir_node *reloader)
534 if(is_Unknown(arg) || arg == new_NoMem())
540 if(arg == get_irg_frame(env->irg))
543 /* hack for now (happens when command should be inserted at end of block) */
544 if(is_Block(reloader)) {
549 * Ignore registers are always available
551 if(arch_irn_is(env->arch_env, arg, ignore)) {
555 /* the following test does not work while spilling,
556 * because the liveness info is not adapted yet to the effects of the
557 * additional spills/reloads.
560 /* we want to remat before the insn reloader
561 * thus an arguments is alive if
562 * - it interferes with the reloaders result
563 * - or it is (last-) used by reloader itself
565 if (values_interfere(env->birg->lv, reloader, arg)) {
569 arity = get_irn_arity(reloader);
570 for (i = 0; i < arity; ++i) {
571 ir_node *rel_arg = get_irn_n(reloader, i);
581 * Checks whether the node can principally be rematerialized
584 int is_remat_node(spill_env_t *env, ir_node *node)
586 const arch_env_t *arch_env = env->arch_env;
588 assert(!be_is_Spill(node));
590 if(arch_irn_is(arch_env, node, rematerializable))
597 * Check if a node is rematerializable. This tests for the following conditions:
599 * - The node itself is rematerializable
600 * - All arguments of the node are available or also rematerialisable
601 * - The costs for the rematerialisation operation is less or equal a limit
603 * Returns the costs needed for rematerialisation or something
604 * >= REMAT_COST_INFINITE if remat is not possible.
607 int check_remat_conditions_costs(spill_env_t *env, ir_node *spilled,
608 ir_node *reloader, int parentcosts)
614 if(!is_remat_node(env, spilled))
615 return REMAT_COST_INFINITE;
617 if(be_is_Reload(spilled)) {
620 costs += arch_get_op_estimated_cost(env->arch_env, spilled);
622 if(parentcosts + costs >= env->reload_cost + env->spill_cost) {
623 return REMAT_COST_INFINITE;
627 for(i = 0, arity = get_irn_arity(spilled); i < arity; ++i) {
628 ir_node *arg = get_irn_n(spilled, i);
630 if(is_value_available(env, arg, reloader))
633 /* we have to rematerialize the argument as well */
635 /* we only support rematerializing 1 argument at the moment,
636 * so that we don't have to care about register pressure
638 return REMAT_COST_INFINITE;
642 costs += check_remat_conditions_costs(env, arg, reloader, parentcosts + costs);
643 if(parentcosts + costs >= env->reload_cost + env->spill_cost)
644 return REMAT_COST_INFINITE;
651 * Re-materialize a node.
653 * @param senv the spill environment
654 * @param spilled the node that was spilled
655 * @param reloader a irn that requires a reload
658 ir_node *do_remat(spill_env_t *env, ir_node *spilled, ir_node *reloader)
665 if(is_Block(reloader)) {
668 bl = get_nodes_block(reloader);
671 ins = alloca(get_irn_arity(spilled) * sizeof(ins[0]));
672 for(i = 0, arity = get_irn_arity(spilled); i < arity; ++i) {
673 ir_node *arg = get_irn_n(spilled, i);
675 if(is_value_available(env, arg, reloader)) {
678 ins[i] = do_remat(env, arg, reloader);
679 #ifdef FIRM_STATISTICS
680 /* don't count the recursive call as remat */
686 /* create a copy of the node */
687 res = new_ir_node(get_irn_dbg_info(spilled), env->irg, bl,
688 get_irn_op(spilled), get_irn_mode(spilled),
689 get_irn_arity(spilled), ins);
690 copy_node_attr(spilled, res);
691 new_backedge_info(res);
693 DBG((dbg, LEVEL_1, "Insert remat %+F of %+F before reloader %+F\n", res, spilled, reloader));
695 if (! is_Proj(res)) {
696 /* insert in schedule */
698 sched_add_before(reloader, res);
699 #ifdef FIRM_STATISTICS
707 double be_get_spill_costs(spill_env_t *env, ir_node *to_spill, ir_node *after)
709 ir_node *block = get_nodes_block(after);
710 double freq = get_block_execfreq(env->exec_freq, block);
713 return env->spill_cost * freq;
716 double be_get_reload_costs(spill_env_t *env, ir_node *to_spill, ir_node *before)
718 ir_node *block = get_nodes_block(before);
719 double freq = get_block_execfreq(env->exec_freq, block);
722 /* is the node rematerializable? */
723 int costs = check_remat_conditions_costs(env, to_spill, before, 0);
724 if(costs < env->reload_cost)
728 return env->reload_cost * freq;
731 double be_get_reload_costs_on_edge(spill_env_t *env, ir_node *to_spill,
732 ir_node *block, int pos)
734 ir_node *before = get_block_insertion_point(block, pos);
735 return be_get_reload_costs(env, to_spill, before);
740 * |_ _|_ __ ___ ___ _ __| |_ | _ \ ___| | ___ __ _ __| |___
741 * | || '_ \/ __|/ _ \ '__| __| | |_) / _ \ |/ _ \ / _` |/ _` / __|
742 * | || | | \__ \ __/ | | |_ | _ < __/ | (_) | (_| | (_| \__ \
743 * |___|_| |_|___/\___|_| \__| |_| \_\___|_|\___/ \__,_|\__,_|___/
747 void be_insert_spills_reloads(spill_env_t *env)
749 const arch_env_t *arch_env = env->arch_env;
750 const ir_exec_freq *exec_freq = env->exec_freq;
752 ir_nodeset_iterator_t iter;
755 /* create all phi-ms first, this is needed so, that phis, hanging on
756 spilled phis work correctly */
757 foreach_ir_nodeset(&env->mem_phis, node, iter) {
758 spill_info_t *info = get_spillinfo(env, node);
759 spill_node(env, info);
762 /* process each spilled node */
763 for (si = set_first(env->spills); si; si = set_next(env->spills)) {
765 ir_node *to_spill = si->to_spill;
766 ir_mode *mode = get_irn_mode(to_spill);
767 ir_node **copies = NEW_ARR_F(ir_node*, 0);
768 double all_remat_costs = 0; /** costs when we would remat all nodes */
771 DBG((dbg, LEVEL_1, "\nhandling all reloaders of %+F:\n", to_spill));
773 /* determine possibility of rematerialisations */
775 for (rld = si->reloaders; rld != NULL; rld = rld->next) {
778 int remat_cost_delta;
780 ir_node *reloader = rld->reloader;
782 if(rld->rematted_node != NULL) {
783 DBG((dbg, LEVEL_2, "\tforced remat %+F before %+F\n",
784 rld->rematted_node, reloader));
787 if(rld->remat_cost_delta >= REMAT_COST_INFINITE) {
788 DBG((dbg, LEVEL_2, "\treload before %+F is forbidden\n",
790 all_remat_costs = REMAT_COST_INFINITE;
794 remat_cost = check_remat_conditions_costs(env, to_spill,
796 if(remat_cost >= REMAT_COST_INFINITE) {
797 DBG((dbg, LEVEL_2, "\tremat before %+F not possible\n",
799 rld->remat_cost_delta = REMAT_COST_INFINITE;
800 all_remat_costs = REMAT_COST_INFINITE;
804 remat_cost_delta = remat_cost - env->reload_cost;
805 rld->remat_cost_delta = remat_cost_delta;
806 block = get_nodes_block(reloader);
807 freq = get_block_execfreq(exec_freq, block);
808 all_remat_costs += remat_cost_delta * freq;
809 DBG((dbg, LEVEL_2, "\tremat costs delta before %+F: "
810 "%d (rel %f)\n", reloader, remat_cost_delta,
811 remat_cost_delta * freq));
813 if(all_remat_costs < REMAT_COST_INFINITE) {
814 ir_node *block = get_nodes_block(to_spill);
815 double freq = get_block_execfreq(exec_freq, block);
816 /* we don't need the costs for the spill if we can remat
818 all_remat_costs -= env->spill_cost * freq;
820 DBG((dbg, LEVEL_2, "\tspill costs %d (rel %f)\n",
821 env->spill_cost, env->spill_cost * freq));
824 if(all_remat_costs < 0) {
825 DBG((dbg, LEVEL_1, "\nforcing remats of all reloaders (%f)\n",
831 /* go through all reloads for this spill */
832 for (rld = si->reloaders; rld != NULL; rld = rld->next) {
833 ir_node *copy; /* a reload is a "copy" of the original value */
835 if (rld->rematted_node != NULL) {
836 copy = rld->rematted_node;
837 sched_add_before(rld->reloader, copy);
838 } else if (be_do_remats &&
839 (force_remat || rld->remat_cost_delta < 0)) {
840 copy = do_remat(env, to_spill, rld->reloader);
842 /* make sure we have a spill */
843 if (si->spill == NULL) {
847 /* create a reload */
848 copy = be_reload(arch_env, si->reload_cls, rld->reloader, mode,
850 #ifdef FIRM_STATISTICS
855 DBG((dbg, LEVEL_1, " %+F of %+F before %+F\n",
856 copy, to_spill, rld->reloader));
857 ARR_APP1(ir_node*, copies, copy);
860 /* if we had any reloads or remats, then we need to reconstruct the
861 * SSA form for the spilled value */
862 if (ARR_LEN(copies) > 0) {
863 be_ssa_construction_env_t senv;
864 /* be_lv_t *lv = be_get_birg_liveness(env->birg); */
866 be_ssa_construction_init(&senv, env->birg);
867 be_ssa_construction_add_copy(&senv, to_spill);
868 be_ssa_construction_add_copies(&senv, copies, ARR_LEN(copies));
869 be_ssa_construction_fix_users(&senv, to_spill);
872 /* no need to enable this as long as we invalidate liveness
873 after this function... */
874 be_ssa_construction_update_liveness_phis(&senv);
875 be_liveness_update(to_spill);
876 len = ARR_LEN(copies);
877 for(i = 0; i < len; ++i) {
878 be_liveness_update(lv, copies[i]);
881 be_ssa_construction_destroy(&senv);
885 si->reloaders = NULL;
888 stat_ev_dbl("spill_spills", env->spill_count);
889 stat_ev_dbl("spill_reloads", env->reload_count);
890 stat_ev_dbl("spill_remats", env->remat_count);
891 stat_ev_dbl("spill_spilled_phis", env->spilled_phi_count);
893 /* Matze: In theory be_ssa_construction should take care of the liveness...
894 * try to disable this again in the future */
895 be_liveness_invalidate(env->birg->lv);
897 be_remove_dead_nodes_from_schedule(env->birg);
900 void be_init_spill(void)
902 FIRM_DBG_REGISTER(dbg, "firm.be.spill");
905 BE_REGISTER_MODULE_CONSTRUCTOR(be_init_spill);