added comment
[libfirm] / ir / be / bespill.c
1 /*
2  * Author:      Daniel Grund, Sebastian Hack, Matthias Braun
3  * Date:                29.09.2005
4  * Copyright:   (c) Universitaet Karlsruhe
5  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
6  */
7 #ifdef HAVE_CONFIG_H
8 #include "config.h"
9 #endif
10
11 #include <stdlib.h>
12
13 #include "pset.h"
14 #include "irnode_t.h"
15 #include "ircons_t.h"
16 #include "iredges_t.h"
17 #include "irbackedge_t.h"
18 #include "irprintf.h"
19 #include "ident_t.h"
20 #include "type_t.h"
21 #include "entity_t.h"
22 #include "debug.h"
23 #include "irgwalk.h"
24 #include "array.h"
25 #include "pdeq.h"
26 #include "unionfind.h"
27 #include "execfreq.h"
28
29 #include "belive_t.h"
30 #include "besched_t.h"
31 #include "bespill.h"
32 #include "belive_t.h"
33 #include "benode_t.h"
34 #include "bechordal_t.h"
35 #include "bejavacoal.h"
36 #include "benodesets.h"
37 #include "bespilloptions.h"
38 #include "bestatevent.h"
39
40 // only rematerialise when costs are less than REMAT_COST_LIMIT
41 // TODO determine a good value here...
42 #define REMAT_COST_LIMIT        10
43
44 typedef struct _reloader_t reloader_t;
45
46 struct _reloader_t {
47         reloader_t *next;
48         ir_node *reloader;
49         ir_node *rematted_node;
50 };
51
52 typedef struct _spill_info_t {
53         /** the value that should get spilled */
54         ir_node *spilled_node;
55         /** list of places where the value should get reloaded */
56         reloader_t *reloaders;
57
58         /** the spill node, or a PhiM node */
59         ir_node *spill;
60         /** if we had the value of a phi spilled before but not the phi itself then
61          * this field contains the spill for the phi value */
62         ir_node *old_spill;
63
64         /** the register class in which the reload should be placed */
65         const arch_register_class_t *reload_cls;
66 } spill_info_t;
67
68 struct _spill_env_t {
69         const arch_register_class_t *cls;
70         const arch_env_t *arch_env;
71         const be_chordal_env_t *chordal_env;
72         struct obstack obst;
73         be_irg_t *birg;
74         int spill_cost;     /**< the cost of a single spill node */
75         int reload_cost;    /**< the cost of a reload node */
76         set *spills;        /**< all spill_info_t's, which must be placed */
77         pset *mem_phis;     /**< set of all special spilled phis. allocated and freed separately */
78
79         DEBUG_ONLY(firm_dbg_module_t *dbg;)
80 };
81
82 /**
83  * Compare two spill infos.
84  */
85 static int cmp_spillinfo(const void *x, const void *y, size_t size) {
86         const spill_info_t *xx = x;
87         const spill_info_t *yy = y;
88         return xx->spilled_node != yy->spilled_node;
89 }
90
91 /**
92  * Returns spill info for a specific value (returns NULL if the info doesn't
93  * exist yet)
94  */
95 static spill_info_t *find_spillinfo(const spill_env_t *env, ir_node *value) {
96         spill_info_t info;
97         int hash = nodeset_hash(value);
98
99         info.spilled_node = value;
100
101         return set_find(env->spills, &info, sizeof(info), hash);
102 }
103
104 /**
105  * Returns spill info for a specific value (the value that is to be spilled)
106  */
107 static spill_info_t *get_spillinfo(const spill_env_t *env, ir_node *value) {
108         spill_info_t info, *res;
109         int hash = nodeset_hash(value);
110
111         info.spilled_node = value;
112         res = set_find(env->spills, &info, sizeof(info), hash);
113
114         if (res == NULL) {
115                 info.reloaders = NULL;
116                 info.spill = NULL;
117                 info.old_spill = NULL;
118                 info.reload_cls = NULL;
119                 res = set_insert(env->spills, &info, sizeof(info), hash);
120         }
121
122         return res;
123 }
124
125 DEBUG_ONLY(
126 /* Sets the debug module of a spill environment. */
127 void be_set_spill_env_dbg_module(spill_env_t *env, firm_dbg_module_t *dbg) {
128         env->dbg = dbg;
129 }
130 )
131
132 /* Creates a new spill environment. */
133 spill_env_t *be_new_spill_env(const be_chordal_env_t *chordal_env) {
134         spill_env_t *env        = xmalloc(sizeof(env[0]));
135         env->spills                     = new_set(cmp_spillinfo, 1024);
136         env->cls                        = chordal_env->cls;
137         env->chordal_env        = chordal_env;
138         env->birg           = chordal_env->birg;
139         env->arch_env       = env->chordal_env->birg->main_env->arch_env;
140         env->mem_phis           = pset_new_ptr_default();
141         // TODO, ask backend about costs...
142         env->spill_cost     = 8;
143         env->reload_cost    = 5;
144         obstack_init(&env->obst);
145         return env;
146 }
147
148 /* Deletes a spill environment. */
149 void be_delete_spill_env(spill_env_t *env) {
150         del_set(env->spills);
151         del_pset(env->mem_phis);
152         obstack_free(&env->obst, NULL);
153         free(env);
154 }
155
156 /*
157  *  ____  _                  ____      _                 _
158  * |  _ \| | __ _  ___ ___  |  _ \ ___| | ___   __ _  __| |___
159  * | |_) | |/ _` |/ __/ _ \ | |_) / _ \ |/ _ \ / _` |/ _` / __|
160  * |  __/| | (_| | (_|  __/ |  _ <  __/ | (_) | (_| | (_| \__ \
161  * |_|   |_|\__,_|\___\___| |_| \_\___|_|\___/ \__,_|\__,_|___/
162  *
163  */
164
165 void be_add_remat(spill_env_t *env, ir_node *to_spill, ir_node *before, ir_node *rematted_node, const arch_register_class_t *reload_cls) {
166         spill_info_t *spill_info;
167         reloader_t *reloader;
168
169         spill_info = get_spillinfo(env, to_spill);
170
171         reloader = obstack_alloc(&env->obst, sizeof(reloader[0]));
172         reloader->next = spill_info->reloaders;
173         reloader->reloader = before;
174         reloader->rematted_node = rematted_node;
175
176         spill_info->reloaders = reloader;
177         assert(spill_info->reload_cls == NULL || spill_info->reload_cls == reload_cls);
178         spill_info->reload_cls = reload_cls;
179 }
180
181 void be_add_reload(spill_env_t *env, ir_node *to_spill, ir_node *before, const arch_register_class_t *reload_cls) {
182         spill_info_t *info;
183         reloader_t *rel;
184
185         assert(arch_irn_consider_in_reg_alloc(env->arch_env, env->cls, to_spill));
186
187         info = get_spillinfo(env, to_spill);
188
189         if(is_Phi(to_spill)) {
190                 int i, arity;
191
192                 /* create spillinfos for the phi arguments */
193                 for (i = 0, arity = get_irn_arity(to_spill); i < arity; ++i) {
194                         ir_node *arg = get_irn_n(to_spill, i);
195                         get_spillinfo(env, arg);
196                 }
197
198 #if 1
199                 // hackery... sometimes the morgan algo spilled the value of a phi,
200                 // the belady algo decides later to spill the whole phi, then sees the
201                 // spill node and adds a reload for that spill node, problem is the
202                 // reload gets attach to that same spill (and is totally unnecessary)
203                 if (info->old_spill != NULL &&
204                         (before == info->old_spill || value_dominates(before, info->old_spill))) {
205                         printf("spilledphi hack was needed...\n");
206                         before = sched_next(info->old_spill);
207                 }
208 #endif
209         }
210
211         /* put reload into list */
212         rel           = obstack_alloc(&env->obst, sizeof(rel[0]));
213         rel->next     = info->reloaders;
214         rel->reloader = before;
215         rel->rematted_node = NULL;
216
217         info->reloaders  = rel;
218         assert(info->reload_cls == NULL || info->reload_cls == reload_cls);
219         info->reload_cls = reload_cls;
220 }
221
222 static ir_node *get_reload_insertion_point(ir_node *block, int pos) {
223         ir_node *predblock, *last;
224
225         /* simply add the reload to the beginning of the block if we only have 1 predecessor
226          * (we don't need to check for phis as there can't be any in a block with only 1 pred)
227          */
228         if(get_Block_n_cfgpreds(block) == 1) {
229                 assert(!is_Phi(sched_first(block)));
230                 return sched_first(block);
231         }
232
233         /* We have to reload the value in pred-block */
234         predblock = get_Block_cfgpred_block(block, pos);
235         last = sched_last(predblock);
236
237         /* we might have projs and keepanys behind the jump... */
238         while(is_Proj(last) || be_is_Keep(last)) {
239                 last = sched_prev(last);
240                 assert(!sched_is_end(last));
241         }
242
243         if(!is_cfop(last)) {
244                 ir_graph *irg = get_irn_irg(block);
245                 ir_node *startblock = get_irg_start_block(irg);
246
247                 last = sched_next(last);
248                 // last node must be a cfop, only exception is the start block
249                 assert(last     == startblock);
250         }
251
252         // add the reload before the (cond-)jump
253         return last;
254 }
255
256 void be_add_reload_on_edge(spill_env_t *env, ir_node *to_spill,
257                 ir_node *block, int pos, const arch_register_class_t *reload_cls)
258 {
259         ir_node *before = get_reload_insertion_point(block, pos);
260         be_add_reload(env, to_spill, before, reload_cls);
261 }
262
263 void be_spill_phi(spill_env_t *env, ir_node *node) {
264         spill_info_t* spill;
265         int i, arity;
266
267         assert(is_Phi(node));
268
269         pset_insert_ptr(env->mem_phis, node);
270
271         // create spillinfos for the phi arguments
272         spill = get_spillinfo(env, node);
273         for(i = 0, arity = get_irn_arity(node); i < arity; ++i) {
274                 ir_node *arg = get_irn_n(node, i);
275                 get_spillinfo(env, arg);
276         }
277
278         // if we had a spill for the phi value before, then remove this spill from
279         // schedule, as we will remove it in the insert spill/reload phase
280         if(spill->spill != NULL && !is_Phi(spill->spill)) {
281                 assert(spill->old_spill == NULL);
282                 spill->old_spill = spill->spill;
283                 spill->spill = NULL;
284         }
285 }
286
287 /*
288  *   ____                _         ____        _ _ _
289  *  / ___|_ __ ___  __ _| |_ ___  / ___| _ __ (_) | |___
290  * | |   | '__/ _ \/ _` | __/ _ \ \___ \| '_ \| | | / __|
291  * | |___| | |  __/ (_| | ||  __/  ___) | |_) | | | \__ \
292  *  \____|_|  \___|\__,_|\__\___| |____/| .__/|_|_|_|___/
293  *                                      |_|
294  */
295
296 /**
297  * Schedules a node after an instruction. (That is the place after all projs and phis
298  * that are scheduled after the instruction)
299  * This function also skips phi nodes at the beginning of a block
300  */
301 static void sched_add_after_insn(ir_node *sched_after, ir_node *node) {
302         ir_node *next = sched_next(sched_after);
303         while(is_Proj(next) || is_Phi(next)) {
304                 next = sched_next(next);
305         }
306         assert(next != NULL);
307
308         if(sched_is_end(next)) {
309                 sched_add_after(sched_last(get_nodes_block(sched_after)), node);
310         } else {
311                 sched_add_before(next, node);
312         }
313 }
314
315 /**
316  * Creates a spill.
317  *
318  * @param senv      the spill environment
319  * @param irn       the node that should be spilled
320  * @param ctx_irn   an user of the spilled node
321  *
322  * @return a be_Spill node
323  */
324 static void spill_irn(spill_env_t *env, spill_info_t *spillinfo) {
325         ir_node *to_spill = spillinfo->spilled_node;
326
327         DBG((env->dbg, LEVEL_1, "%+F\n", to_spill));
328
329         /* Trying to spill an already spilled value, no need for a new spill
330          * node then, we can simply connect to the same one for this reload
331          *
332          * (although rematerialization code should handle most of these cases
333          * this can still happen when spilling Phis)
334          */
335         if(be_is_Reload(to_spill)) {
336                 spillinfo->spill = get_irn_n(to_spill, be_pos_Reload_mem);
337                 return;
338         }
339
340         if (arch_irn_is(env->arch_env, to_spill, dont_spill)) {
341                 if (env->chordal_env->opts->vrfy_option == BE_CH_VRFY_WARN)
342                         ir_fprintf(stderr, "Verify warning: spilling 'dont_spill' node %+F\n", to_spill);
343                 else if (env->chordal_env->opts->vrfy_option == BE_CH_VRFY_ASSERT)
344                         assert(0 && "Attempt to spill a node marked 'dont_spill'");
345         }
346
347         spillinfo->spill = be_spill(env->arch_env, to_spill);
348         sched_add_after_insn(to_spill, spillinfo->spill);
349 }
350
351 static void spill_node(spill_env_t *env, spill_info_t *spillinfo);
352
353 /**
354  * If the first usage of a Phi result would be out of memory
355  * there is no sense in allocating a register for it.
356  * Thus we spill it and all its operands to the same spill slot.
357  * Therefore the phi/dataB becomes a phi/Memory
358  *
359  * @param senv      the spill environment
360  * @param phi       the Phi node that should be spilled
361  * @param ctx_irn   an user of the spilled node
362  */
363 static void spill_phi(spill_env_t *env, spill_info_t *spillinfo) {
364         ir_node *phi = spillinfo->spilled_node;
365         int i;
366         int arity = get_irn_arity(phi);
367         ir_node     *block    = get_nodes_block(phi);
368         ir_node     **ins;
369
370         assert(is_Phi(phi));
371
372         /* build a new PhiM */
373         ins = alloca(sizeof(ir_node*) * arity);
374         for(i = 0; i < arity; ++i) {
375                 ins[i] = get_irg_bad(env->chordal_env->irg);
376         }
377         spillinfo->spill = new_r_Phi(env->chordal_env->irg, block, arity, ins, mode_M);
378
379         for(i = 0; i < arity; ++i) {
380                 ir_node *arg = get_irn_n(phi, i);
381                 spill_info_t *arg_info = get_spillinfo(env, arg);
382
383                 spill_node(env, arg_info);
384
385                 set_irn_n(spillinfo->spill, i, arg_info->spill);
386         }
387
388         // rewire reloads from old_spill to phi
389         if(spillinfo->old_spill != NULL) {
390                 const ir_edge_t *edge, *next;
391                 ir_node *old_spill = spillinfo->old_spill;
392
393                 foreach_out_edge_safe(old_spill, edge, next) {
394                         ir_node* reload = get_edge_src_irn(edge);
395                         assert(be_is_Reload(reload) || is_Phi(reload));
396                         set_irn_n(reload, get_edge_src_pos(edge), spillinfo->spill);
397                 }
398                 set_irn_n(old_spill, be_pos_Spill_val, new_Bad());
399                 //sched_remove(old_spill);
400                 spillinfo->old_spill = NULL;
401         }
402 }
403
404 /**
405  * Spill a node.
406  *
407  * @param senv      the spill environment
408  * @param to_spill  the node that should be spilled
409  */
410 static void spill_node(spill_env_t *env, spill_info_t *spillinfo) {
411         ir_node *to_spill;
412
413         // the node should be tagged for spilling already...
414         if(spillinfo->spill != NULL)
415                 return;
416
417         to_spill = spillinfo->spilled_node;
418         if (is_Phi(to_spill) && pset_find_ptr(env->mem_phis, spillinfo->spilled_node)) {
419                 spill_phi(env, spillinfo);
420         } else {
421                 spill_irn(env, spillinfo);
422         }
423 }
424
425 /*
426  *
427  *  ____                      _            _       _ _
428  * |  _ \ ___ _ __ ___   __ _| |_ ___ _ __(_) __ _| (_)_______
429  * | |_) / _ \ '_ ` _ \ / _` | __/ _ \ '__| |/ _` | | |_  / _ \
430  * |  _ <  __/ | | | | | (_| | ||  __/ |  | | (_| | | |/ /  __/
431  * |_| \_\___|_| |_| |_|\__,_|\__\___|_|  |_|\__,_|_|_/___\___|
432  *
433  */
434
435 /**
436  * Tests whether value @p arg is available before node @p reloader
437  * @returns 1 if value is available, 0 otherwise
438  */
439 static int is_value_available(spill_env_t *env, ir_node *arg, ir_node *reloader) {
440         if(is_Unknown(arg) || arg == new_NoMem())
441                 return 1;
442
443         if(be_is_Spill(arg))
444                 return 1;
445
446         if(arg == get_irg_frame(env->chordal_env->irg))
447                 return 1;
448
449         // hack for now (happens when command should be inserted at end of block)
450         if(is_Block(reloader)) {
451                 return 0;
452         }
453
454         /* the following test does not work while spilling,
455          * because the liveness info is not adapted yet to the effects of the
456          * additional spills/reloads.
457          *
458          * So we can only do this test for ignore registers (of our register class)
459          */
460         if(arch_get_irn_reg_class(env->arch_env, arg, -1) == env->cls
461            && arch_irn_is(env->arch_env, arg, ignore)) {
462                 int i, arity;
463
464                 /* we want to remat before the insn reloader
465                  * thus an arguments is alive if
466                  *   - it interferes with the reloaders result
467                  *   - or it is (last-) used by reloader itself
468                  */
469                 if (values_interfere(env->birg->lv, reloader, arg)) {
470                         return 1;
471                 }
472
473                 arity = get_irn_arity(reloader);
474                 for (i = 0; i < arity; ++i) {
475                         ir_node *rel_arg = get_irn_n(reloader, i);
476                         if (rel_arg == arg)
477                                 return 1;
478                 }
479         }
480
481         return 0;
482 }
483
484 /**
485  * Checks whether the node can principally be rematerialized
486  */
487 static int is_remat_node(spill_env_t *env, ir_node *node) {
488         const arch_env_t *arch_env = env->arch_env;
489
490         assert(!be_is_Spill(node));
491
492         if(arch_irn_is(arch_env, node, rematerializable)) {
493                 return 1;
494         }
495
496         if(be_is_StackParam(node))
497                 return 1;
498
499         return 0;
500 }
501
502 /**
503  * Check if a node is rematerializable. This tests for the following conditions:
504  *
505  * - The node itself is rematerializable
506  * - All arguments of the node are available or also rematerialisable
507  * - The costs for the rematerialisation operation is less or equal a limit
508  *
509  * Returns the costs needed for rematerialisation or something
510  * > REMAT_COST_LIMIT if remat is not possible.
511  */
512 static int check_remat_conditions_costs(spill_env_t *env, ir_node *spilled, ir_node *reloader, int parentcosts) {
513         int i, arity;
514         int argremats;
515         int costs = 0;
516
517         if(!is_remat_node(env, spilled))
518                 return REMAT_COST_LIMIT;
519
520         if(be_is_Reload(spilled)) {
521                 costs += 2;
522         } else {
523                 costs += arch_get_op_estimated_cost(env->arch_env, spilled);
524         }
525         if(parentcosts + costs >= REMAT_COST_LIMIT) {
526                 return REMAT_COST_LIMIT;
527         }
528
529         argremats = 0;
530         for(i = 0, arity = get_irn_arity(spilled); i < arity; ++i) {
531                 ir_node *arg = get_irn_n(spilled, i);
532
533                 if(is_value_available(env, arg, reloader))
534                         continue;
535
536                 // we have to rematerialize the argument as well...
537                 if(argremats >= 1) {
538                         /* we only support rematerializing 1 argument at the moment,
539                          * so that we don't have to care about register pressure
540                          */
541                         return REMAT_COST_LIMIT;
542                 }
543                 argremats++;
544
545                 costs += check_remat_conditions_costs(env, arg, reloader, parentcosts + costs);
546                 if(parentcosts + costs >= REMAT_COST_LIMIT)
547                         return REMAT_COST_LIMIT;
548         }
549
550         return costs;
551 }
552
553 static int check_remat_conditions(spill_env_t *env, ir_node *spilled, ir_node *reloader) {
554         int costs = check_remat_conditions_costs(env, spilled, reloader, 0);
555
556         return costs < REMAT_COST_LIMIT;
557 }
558
559 /**
560  * Re-materialize a node.
561  *
562  * @param senv      the spill environment
563  * @param spilled   the node that was spilled
564  * @param reloader  a irn that requires a reload
565  */
566 static ir_node *do_remat(spill_env_t *env, ir_node *spilled, ir_node *reloader) {
567         int i, arity;
568         ir_node *res;
569         ir_node *bl;
570         ir_node **ins;
571
572         if(is_Block(reloader)) {
573                 bl = reloader;
574         } else {
575                 bl = get_nodes_block(reloader);
576         }
577
578         ins = alloca(get_irn_arity(spilled) * sizeof(ins[0]));
579         for(i = 0, arity = get_irn_arity(spilled); i < arity; ++i) {
580                 ir_node *arg = get_irn_n(spilled, i);
581
582                 if(is_value_available(env, arg, reloader)) {
583                         ins[i] = arg;
584                 } else {
585                         ins[i] = do_remat(env, arg, reloader);
586                 }
587         }
588
589         /* create a copy of the node */
590         res = new_ir_node(get_irn_dbg_info(spilled), env->chordal_env->irg, bl,
591                 get_irn_op(spilled),
592                 get_irn_mode(spilled),
593                 get_irn_arity(spilled),
594                 ins);
595         copy_node_attr(spilled, res);
596         new_backedge_info(res);
597         sched_reset(res);
598
599         DBG((env->dbg, LEVEL_1, "Insert remat %+F before reloader %+F\n", res, reloader));
600
601         /* insert in schedule */
602         sched_add_before(reloader, res);
603
604         return res;
605 }
606
607 int be_get_reload_costs(spill_env_t *env, ir_node *to_spill, ir_node *before) {
608         spill_info_t *spill_info;
609
610         if(be_do_remats) {
611                 // is the node rematerializable?
612                 int costs = check_remat_conditions_costs(env, to_spill, before, 0);
613                 if(costs < REMAT_COST_LIMIT)
614                         return costs;
615         }
616
617         // do we already have a spill?
618         spill_info = find_spillinfo(env, to_spill);
619         if(spill_info != NULL && spill_info->spill != NULL)
620                 return env->reload_cost;
621
622         return env->spill_cost + env->reload_cost;
623 }
624
625 int be_get_reload_costs_on_edge(spill_env_t *env, ir_node *to_spill, ir_node *block, int pos) {
626         ir_node *before = get_reload_insertion_point(block, pos);
627         return be_get_reload_costs(env, to_spill, before);
628 }
629
630 /*
631  *  ___                     _     ____      _                 _
632  * |_ _|_ __  ___  ___ _ __| |_  |  _ \ ___| | ___   __ _  __| |___
633  *  | || '_ \/ __|/ _ \ '__| __| | |_) / _ \ |/ _ \ / _` |/ _` / __|
634  *  | || | | \__ \  __/ |  | |_  |  _ <  __/ | (_) | (_| | (_| \__ \
635  * |___|_| |_|___/\___|_|   \__| |_| \_\___|_|\___/ \__,_|\__,_|___/
636  *
637  */
638
639 void be_insert_spills_reloads(spill_env_t *env) {
640         const arch_env_t *arch_env = env->arch_env;
641         int              remats    = 0;
642         int              reloads   = 0;
643         int              spills    = 0;
644         spill_info_t     *si;
645
646         /* process each spilled node */
647         for (si = set_first(env->spills); si; si = set_next(env->spills)) {
648                 reloader_t *rld;
649                 ir_mode    *mode   = get_irn_mode(si->spilled_node);
650                 pset       *values = pset_new_ptr(16);
651
652                 /* go through all reloads for this spill */
653                 for (rld = si->reloaders; rld; rld = rld->next) {
654                         ir_node *new_val;
655
656                         if(rld->rematted_node != NULL) {
657                                 new_val = rld->rematted_node;
658                                 remats++;
659                                 sched_add_before(rld->reloader, new_val);
660                         } else if (be_do_remats && check_remat_conditions(env, si->spilled_node, rld->reloader)) {
661                                 new_val = do_remat(env, si->spilled_node, rld->reloader);
662                                 remats++;
663                         }
664                         else {
665                                 /* make sure we have a spill */
666                                 if (si->spill == NULL) {
667                                         spill_node(env, si);
668                                         spills++;
669                                 }
670
671                                 /* create a reload */
672                                 new_val = be_reload(arch_env, si->reload_cls, rld->reloader, mode, si->spill);
673                                 reloads++;
674                         }
675
676                         DBG((env->dbg, LEVEL_1, " %+F of %+F before %+F\n", new_val, si->spilled_node, rld->reloader));
677                         pset_insert_ptr(values, new_val);
678                 }
679
680                 if (pset_count(values) > 0) {
681                         /* introduce copies, rewire the uses */
682                         pset_insert_ptr(values, si->spilled_node);
683                         be_ssa_constr_set_ignore(env->birg->dom_front, env->birg->lv, values, env->mem_phis);
684                 }
685
686                 del_pset(values);
687
688                 si->reloaders = NULL;
689         }
690
691 #ifdef FIRM_STATISTICS
692         if (be_stat_ev_is_active()) {
693                 be_stat_ev("spill_spills", spills);
694                 be_stat_ev("spill_reloads", reloads);
695                 be_stat_ev("spill_remats", remats);
696         }
697 #endif /* FIRM_STATISTICS */
698
699         be_remove_dead_nodes_from_schedule(env->chordal_env->irg);
700         //be_liveness_recompute(env->birg->lv);
701         be_invalidate_liveness(env->birg);
702 }