d07da2f076b6012e329001b5e2faa731d34725dd
[libfirm] / ir / be / bespillslots.c
1 /*
2  * Author:      Matthias Braun
3  * Date:                26.7.06
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 "set.h"
14
15 #include "irgwalk.h"
16 #include "ircons.h"
17 #include "irprintf.h"
18 #include "execfreq.h"
19 #include "unionfind.h"
20 #include "type.h"
21 #include "irdump_t.h"
22
23 #include "benode_t.h"
24 #include "bespillslots.h"
25 #include "bechordal_t.h"
26 #include "bejavacoal.h"
27
28
29 #define DBG_COALESCING          1
30 #define DBG_INTERFERENCES       2
31
32 DEBUG_ONLY(
33 static firm_dbg_module_t *dbg = NULL;
34 )
35
36 typedef struct _spill_t {
37         ir_node *spill;
38         /** regclass of the spilled value */
39         const arch_register_class_t *cls;
40         /** index into spillslot_unionfind unionfind structure */
41         int spillslot;
42 } spill_t;
43
44 typedef struct _affinity_edge_t {
45         double affinity;
46         int slot1, slot2;
47 } affinity_edge_t;
48
49 typedef struct _ss_env_t {
50         struct obstack obst;
51         const be_chordal_env_t *chordal_env;
52         set *spills;
53         ir_node **reloads;
54         affinity_edge_t **affinity_edges;
55         set *memperms;
56 } ss_env_t;
57
58 /** Compare 2 affinity edges (used in quicksort) */
59 static int cmp_affinity(const void *d1, const void *d2) {
60         const affinity_edge_t *e1 = d1;
61         const affinity_edge_t *e2 = d2;
62
63         return e1->affinity < e2->affinity ? -1 : 1;
64 }
65
66 int cmp_spill(const void* d1, const void* d2, size_t size) {
67         const spill_t* s1 = d1;
68         const spill_t* s2 = d2;
69         return s1->spill != s2->spill;
70 }
71
72 static spill_t *get_spill(ss_env_t *env, ir_node *node) {
73         spill_t spill, *res;
74         int hash = HASH_PTR(node);
75
76         spill.spill = node;
77         res = set_find(env->spills, &spill, sizeof(spill), hash);
78
79         return res;
80 }
81
82 /*
83  *   ____      _ _           _     ____        _ _ _
84  *  / ___|___ | | | ___  ___| |_  / ___| _ __ (_) | |___
85  * | |   / _ \| | |/ _ \/ __| __| \___ \| '_ \| | | / __|
86  * | |__| (_) | | |  __/ (__| |_   ___) | |_) | | | \__ \
87  *  \____\___/|_|_|\___|\___|\__| |____/| .__/|_|_|_|___/
88  *                                      |_|
89  */
90
91 static spill_t *collect_spill(ss_env_t *env, ir_node *node, const arch_register_class_t *cls) {
92         spill_t spill, *res;
93         int hash = HASH_PTR(node);
94
95         assert(be_is_Spill(node));
96
97         spill.spill = node;
98         res = set_find(env->spills, &spill, sizeof(spill), hash);
99
100         if(res == NULL) {
101                 spill.spillslot = set_count(env->spills);
102                 spill.cls = cls;
103                 res = set_insert(env->spills, &spill, sizeof(spill), hash);
104         } else {
105                 assert(cls == res->cls);
106         }
107
108         return res;
109 }
110
111 static spill_t *collect_memphi(ss_env_t *env, ir_node *node, const arch_register_class_t *cls) {
112         int i, arity;
113         spill_t spill, *res;
114         int hash = HASH_PTR(node);
115
116         assert(is_Phi(node));
117
118         spill.spill = node;
119         res = set_find(env->spills, &spill, sizeof(spill), hash);
120         if(res != NULL) {
121                 return res;
122         }
123
124         spill.spillslot = set_count(env->spills);
125         spill.cls = cls;
126         res = set_insert(env->spills, &spill, sizeof(spill), hash);
127
128         // is 1 of the arguments a spill?
129         for(i = 0, arity = get_irn_arity(node); i < arity; ++i) {
130                 affinity_edge_t *affinty_edge;
131                 ir_node* arg = get_irn_n(node, i);
132                 spill_t* arg_spill;
133
134                 if(be_is_Spill(arg)) {
135                         arg_spill = collect_spill(env, arg, cls);
136                 } else {
137                         // if it wasn't a spill then it must be a Mem-Phi
138                         assert(is_Phi(arg));
139                         arg_spill = collect_memphi(env, arg, cls);
140                 }
141
142                 // add an affinity edge
143                 affinty_edge = obstack_alloc(&env->obst, sizeof(affinty_edge[0]));
144                 affinty_edge->affinity = get_block_execfreq(env->chordal_env->exec_freq, get_nodes_block(arg));
145                 affinty_edge->slot1 = res->spillslot;
146                 affinty_edge->slot2 = arg_spill->spillslot;
147                 ARR_APP1(affinity_edge_t*, env->affinity_edges, affinty_edge);
148         }
149
150         return res;
151 }
152
153 /**
154  * This walker function searches for reloads and collects all the spills
155  * and memphis attached to them.
156  */
157 static void collect_spills_walker(ir_node *node, void *data) {
158         ss_env_t *env = data;
159
160         if(be_is_Reload(node)) {
161                 ir_node *spill = get_irn_n(node, be_pos_Reload_mem);
162                 const arch_env_t *arch_env = env->chordal_env->birg->main_env->arch_env;
163                 const arch_register_class_t *cls = arch_get_irn_reg_class(arch_env, node, -1);
164
165                 if(is_Phi(spill)) {
166                         collect_memphi(env, spill, cls);
167                 } else {
168                         collect_spill(env, spill, cls);
169                 }
170                 ARR_APP1(ir_node*, env->reloads, node);
171         }
172 }
173
174 /*
175  *   ____            _                      ____  _       _
176  *  / ___|___   __ _| | ___  ___  ___ ___  / ___|| | ___ | |_ ___
177  * | |   / _ \ / _` | |/ _ \/ __|/ __/ _ \ \___ \| |/ _ \| __/ __|
178  * | |__| (_) | (_| | |  __/\__ \ (_|  __/  ___) | | (_) | |_\__ \
179  *  \____\___/ \__,_|_|\___||___/\___\___| |____/|_|\___/ \__|___/
180  */
181
182 static int merge_interferences(ss_env_t *env, bitset_t** interferences, int* spillslot_unionfind, int s1, int s2)
183 {
184         int res;
185         int i;
186         int spillcount;
187
188         // merge spillslots and interferences
189         res = uf_union(spillslot_unionfind, s1, s2);
190         // we assume that we always merge s2 to s1 so swap s1, s2 if necessary
191         if(res != 0) {
192                 int t = s1;
193                 s1 = s2;
194                 s2 = t;
195         }
196
197         bitset_or(interferences[s1], interferences[s2]);
198
199         // update other interferences
200         spillcount = set_count(env->spills);
201         for(i = 0; i < spillcount; ++i) {
202                 bitset_t *intfs = interferences[i];
203                 if(bitset_is_set(intfs, s2))
204                         bitset_set(intfs, s1);
205         }
206
207         return res;
208 }
209
210 #if 0
211
212 static void dump_interference_graph(ss_env_t *env, bitset_t **interferences, const char* suffix) {
213         char name[256];
214         int i;
215         int spillcount;
216         spill_t *spill;
217         FILE *f;
218         static int cnt = 0;
219
220         snprintf(name, sizeof(name), "%d-%s-spillslots-%s.vcg", cnt++, get_irg_dump_name(env->chordal_env->birg->irg), suffix);
221
222         f = fopen(name, "w");
223         assert(f != NULL);
224
225         fprintf(f, "graph: {\n");
226
227         spillcount = set_count(env->spills);
228         for(spill = set_first(env->spills), i = 0; spill != NULL; spill = set_next(env->spills), ++i) {
229                 int slotid = spill->spillslot;
230                 fprintf(f, "\tnode: { title: \"n%d\" label: \"%d\" }\n", i, slotid);
231         }
232
233         for(i = 0; i < ARR_LEN(env->affinity_edges); ++i) {
234                 affinity_edge_t *edge = env->affinity_edges[i];
235                 fprintf(f, "\tedge: { sourcename: \"n%d\" targetname: \"n%d\" color: green }\n", edge->slot1, edge->slot2);
236         }
237
238         for(i = 0; i < spillcount; ++i) {
239                 int i2;
240                 for(i2 = 0; i2 < spillcount; ++i2) {
241                         if(bitset_is_set(interferences[i], i2)) {
242                                 fprintf(f, "\tedge: { sourcename: \"n%d\" targetname: \"n%d\" color: red }\n", i, i2);
243                         }
244                 }
245         }
246
247         fprintf(f, "}\n");
248         fclose(f);
249 }
250
251 static void show_stats(ss_env_t *env) {
252         int spillcount;
253         int slotcount;
254         int *slotused;
255         spill_t *spill;
256
257         spillcount = set_count(env->spills);
258         fprintf(stderr, "%s: Collected %d spills\n", get_irg_dump_name(env->chordal_env->birg->irg), spillcount);
259
260         slotused = alloca(spillcount * sizeof(slotused[0]));
261         memset(slotused, 0, spillcount * sizeof(slotused[0]));
262
263         slotcount = 0;
264         for(spill = set_first(env->spills); spill != NULL; spill = set_next(env->spills)) {
265                 int slot = spill->spillslot;
266                 if(slotused[slot] == 0) {
267                         slotused[slot] = 1;
268                         slotcount++;
269                 }
270         }
271
272         fprintf(stderr, "%s: Coalesced to %d spillslots\n", get_irg_dump_name(env->chordal_env->birg->irg), slotcount);
273 }
274
275 #endif
276
277 static void assign_spillslots(ss_env_t *env);
278
279 /**
280  * A greedy coalescing algorithm for spillslots:
281  *  1. Sort the list of affinity edges
282  *  2. Try to merge slots with affinity edges (most expensive slots first)
283  *  3. Try to merge everything else that is possible
284  */
285 static void do_greedy_coalescing(ss_env_t *env)
286 {
287         int spillcount;
288         spill_t **spilllist;
289         spill_t *spill;
290         int i, i2;
291         int affinity_edge_count;
292         bitset_t **interferences;
293         int* spillslot_unionfind;
294
295         spillcount = set_count(env->spills);
296         if(spillcount == 0)
297                 return;
298
299         DBG((dbg, DBG_COALESCING, "Coalescing %d spillslots\n", spillcount));
300
301         interferences = alloca(spillcount * sizeof(interferences[0]));
302         spillslot_unionfind = alloca(spillcount * sizeof(spillslot_unionfind[0]));
303         spilllist = alloca(spillcount * sizeof(spilllist[0]));
304
305         uf_init(spillslot_unionfind, 0, spillcount);
306
307         DEBUG_ONLY(
308                 memset(spilllist, 0, spillcount * sizeof(spilllist[0]));
309         );
310
311         for(spill = set_first(env->spills), i = 0; spill != NULL; spill = set_next(env->spills), ++i) {
312                 assert(spill->spillslot < spillcount);
313                 spilllist[spill->spillslot] = spill;
314         }
315
316         for(i = 0; i < spillcount; ++i) {
317                 interferences[i] = bitset_alloca(spillcount);
318         }
319
320         // construct interferences
321         for(i = 0; i < spillcount; ++i) {
322                 for(i2 = i+1; i2 < spillcount; ++i2) {
323                         if(values_interfere(env->chordal_env->lv, spilllist[i]->spill, spilllist[i2]->spill)) {
324                                 DBG((dbg, DBG_INTERFERENCES, "Slot %d and %d interfere\n", i, i2));
325                                 bitset_set(interferences[i], i2);
326                                 bitset_set(interferences[i2], i);
327                         }
328                 }
329         }
330
331         // sort affinity edges
332         affinity_edge_count = ARR_LEN(env->affinity_edges);
333         qsort(env->affinity_edges, affinity_edge_count, sizeof(env->affinity_edges[0]), cmp_affinity);
334
335         //dump_interference_graph(env, interferences, "before");
336
337         // try to merge affine nodes
338         for(i = 0; i < affinity_edge_count; ++i) {
339                 const affinity_edge_t *edge = env->affinity_edges[i];
340                 int s1 = uf_find(spillslot_unionfind, edge->slot1);
341                 int s2 = uf_find(spillslot_unionfind, edge->slot2);
342
343                 /* test if values interfere */
344                 if(bitset_is_set(interferences[s1], s2)) {
345                         assert(bitset_is_set(interferences[s2], s1));
346                         continue;
347                 }
348
349                 DBG((dbg, DBG_COALESCING, "Merging %d and %d because of affinity edge\n", s1, s2));
350
351                 merge_interferences(env, interferences, spillslot_unionfind, s1, s2);
352         }
353
354         // try to merge as much remaining spillslots as possible
355         for(i = 0; i < spillcount; ++i) {
356                 int s1 = uf_find(spillslot_unionfind, i);
357                 if(s1 != i)
358                         continue;
359
360                 for(i2 = i+1; i2 < spillcount; ++i2) {
361                         int s2 = uf_find(spillslot_unionfind, i2);
362                         if(s2 != i2)
363                                 continue;
364
365                         /* test if values interfere
366                          * we have to test n1-n2 and n2-n1, because only 1 side gets updated
367                          * when node merging occurs
368                          */
369                         if(bitset_is_set(interferences[s1], s2)) {
370                                 assert(bitset_is_set(interferences[s2], s1));
371                                 continue;
372                         }
373
374                         DBG((dbg, DBG_COALESCING, "Merging %d and %d because it is possible\n", s1, s2));
375
376                         if(merge_interferences(env, interferences, spillslot_unionfind, s1, s2) != 0) {
377                                 // we can break the loop here, because s2 is the new supernode now
378                                 // and we'll test s2 again later anyway
379                                 break;
380                         }
381                 }
382         }
383
384         // assign spillslots
385         for(i = 0; i < spillcount; ++i) {
386                 spill_t *spill = spilllist[i];
387
388                 spill->spillslot = uf_find(spillslot_unionfind, i);
389         }
390
391         //dump_interference_graph(env, interferences, "after");
392 }
393
394 static void do_java_coalescing(ss_env_t *env)
395 {
396         int spillcount;
397         spill_t **spilllist;
398         spill_t *spill;
399         int i, i2;
400         be_java_coal_t *coal;
401
402         spillcount = set_count(env->spills);
403         if(spillcount == 0)
404                 return;
405
406         spilllist = alloca(spillcount * sizeof(spilllist[0]));
407
408         DEBUG_ONLY(
409                 memset(spilllist, 0, spillcount * sizeof(spilllist[0]));
410         );
411
412         coal = be_java_coal_init("spillslot coalescing", spillcount, spillcount, 1);
413
414         for(spill = set_first(env->spills), i = 0; spill != NULL; spill = set_next(env->spills), ++i) {
415                 assert(spill->spillslot < spillcount);
416                 DEBUG_ONLY(assert(spilllist[spill->spillslot] == NULL));
417                 spilllist[spill->spillslot] = spill;
418
419                 be_java_coal_set_color(coal, spill->spillslot, spill->spillslot);
420         }
421
422         // construct interferences
423         for(i = 0; i < spillcount; ++i) {
424                 for(i2 = i+1; i2 < spillcount; ++i2) {
425                         if(values_interfere(env->chordal_env->lv, spilllist[i]->spill, spilllist[i2]->spill)) {
426                                 be_java_coal_add_int_edge(coal, i, i2);
427                         }
428                 }
429         }
430
431         for(i = 0; i < ARR_LEN(env->affinity_edges); ++i) {
432                 const affinity_edge_t *edge = env->affinity_edges[i];
433                 int n = edge->slot1;
434                 int m = edge->slot2;
435                 int costs = (int) (edge->affinity * 10000);
436                 be_java_coal_add_aff_edge(coal, n, m, costs);
437         }
438
439         be_java_coal_coalesce(coal);
440
441         // construct spillslots
442         for(i = 0; i < spillcount; ++i) {
443                 spill_t *spill = spilllist[i];
444                 spill->spillslot = be_java_coal_get_color(coal, i);
445         }
446         be_java_coal_destroy(coal);
447 }
448
449 /*
450  *     _            _               _____       _   _ _   _
451  *    / \   ___ ___(_) __ _ _ __   | ____|_ __ | |_(_) |_(_) ___  ___
452  *   / _ \ / __/ __| |/ _` | '_ \  |  _| | '_ \| __| | __| |/ _ \/ __|
453  *  / ___ \\__ \__ \ | (_| | | | | | |___| | | | |_| | |_| |  __/\__ \
454  * /_/   \_\___/___/_|\__, |_| |_| |_____|_| |_|\__|_|\__|_|\___||___/
455  *                    |___/
456  */
457
458 typedef struct _spill_slot_t {
459         int size;
460         int align;
461         entity   *entity;
462 } spill_slot_t;
463
464 typedef struct _memperm_entry_t {
465         ir_node* node;
466         int pos;
467         entity *in;
468         entity *out;
469         struct _memperm_entry_t *next;
470 } memperm_entry_t;
471
472 typedef struct _memperm_t {
473         ir_node *block;
474         int entrycount;
475         memperm_entry_t *entries;
476 } memperm_t;
477
478 int cmp_memperm(const void* d1, const void* d2, size_t size) {
479         const memperm_t* e1 = d1;
480         const memperm_t* e2 = d2;
481         return e1->block != e2->block;
482 }
483
484 static memperm_t *get_memperm(ss_env_t *env, ir_node *block) {
485         memperm_t entry, *res;
486         int hash;
487
488         entry.block = block;
489         hash = HASH_PTR(block);
490
491         res = set_find(env->memperms, &entry, sizeof(entry), hash);
492
493         if(res == NULL) {
494                 entry.entrycount = 0;
495                 entry.entries = NULL;
496                 res = set_insert(env->memperms, &entry, sizeof(entry), hash);
497         }
498
499         return res;
500 }
501
502 static entity* create_stack_entity(ss_env_t *env, spill_slot_t *slot) {
503         ir_type* frame = get_irg_frame_type(env->chordal_env->irg);
504         entity* res = frame_alloc_area(frame, slot->size, slot->align, 0);
505
506         slot->entity = res;
507
508         return res;
509 }
510
511 static int get_spillslotsize_for_spill(ss_env_t *env, spill_t *spill) {
512         const ir_mode *mode = arch_register_class_mode(spill->cls);
513
514         return get_mode_size_bytes(mode);
515 }
516
517 static int get_spillslotalign_for_spill(ss_env_t *env, spill_t *spill) {
518         const arch_isa_t *isa = env->chordal_env->birg->main_env->arch_env->isa;
519
520         return arch_isa_get_reg_class_alignment(isa, spill->cls);
521 }
522
523 /**
524  * Enlarges a spillslot (if necessary) so that it can carry a value of size
525  * @p othersize and alignment @p otheralign.
526  */
527 static void enlarge_spillslot(spill_slot_t *slot, int otheralign, int othersize) {
528         if(othersize > slot->size) {
529                 slot->size = othersize;
530         }
531         if(otheralign > slot->align) {
532                 if(otheralign % slot->align != 0)
533                         slot->align *= otheralign;
534                 else
535                         slot->align = otheralign;
536         } else if(slot->align % otheralign != 0) {
537                 slot->align *= otheralign;
538         }
539 }
540
541 /**
542  * Create stack entities for the spillslots and assign them to the spill and
543  * reload nodes.
544  */
545 static void assign_spillslots(ss_env_t *env) {
546         int i;
547         int spillcount;
548         spill_t *spill;
549         spill_slot_t* spillslots;
550
551         spillcount = set_count(env->spills);
552         spillslots = alloca(spillcount * sizeof(spillslots[0]));
553
554         memset(spillslots, 0, spillcount * sizeof(spillslots[0]));
555
556         // construct spillslots
557         for(spill = set_first(env->spills); spill != NULL; spill = set_next(env->spills)) {
558                 int slotid = spill->spillslot;
559                 spill_slot_t *slot = & (spillslots[slotid]);
560                 int align = get_spillslotalign_for_spill(env, spill);
561                 int size = get_spillslotsize_for_spill(env, spill);
562
563                 if(slot->align == 0 && slot->size == 0) {
564                         slot->align = align;
565                         slot->size = size;
566                 } else {
567                         enlarge_spillslot(slot, align, size);
568                 }
569         }
570
571         for(spill = set_first(env->spills); spill != NULL; spill = set_next(env->spills)) {
572                 spill_slot_t *slot;
573                 ir_node *node = spill->spill;
574                 int slotid = spill->spillslot;
575
576                 slot = &spillslots[slotid];
577                 if(slot->entity == NULL) {
578                         create_stack_entity(env, slot);
579                 }
580
581                 if(be_is_Spill(node)) {
582                         be_set_frame_entity(node, slot->entity);
583                 } else {
584                         int i, arity;
585
586                         // should be a PhiM
587                         assert(is_Phi(node));
588
589                         for(i = 0, arity = get_irn_arity(node); i < arity; ++i) {
590                                 ir_node *arg = get_irn_n(node, i);
591                                 spill_t *argspill;
592                                 int argslotid;
593
594                                 argspill = get_spill(env, arg);
595                                 assert(argspill != NULL);
596
597                                 argslotid = argspill->spillslot;
598                                 if(slotid != argslotid) {
599                                         memperm_t *memperm;
600                                         memperm_entry_t *entry;
601                                         spill_slot_t *argslot = &spillslots[argslotid];
602                                         if(argslot->entity == NULL) {
603                                                 create_stack_entity(env, argslot);
604                                         }
605
606                                         memperm = get_memperm(env, get_nodes_block(arg));
607
608                                         entry = obstack_alloc(&env->obst, sizeof(entry[0]));
609                                         entry->node = node;
610                                         entry->pos = i;
611                                         entry->in = argslot->entity;
612                                         entry->out = slot->entity;
613                                         entry->next = memperm->entries;
614                                         memperm->entrycount++;
615                                         memperm->entries = entry;
616                                 }
617                         }
618                 }
619         }
620
621         for(i = 0; i < ARR_LEN(env->reloads); ++i) {
622                 const ir_node* reload = env->reloads[i];
623                 ir_node* spillnode = get_irn_n(reload, be_pos_Reload_mem);
624                 spill_t *spill = get_spill(env, spillnode);
625                 const spill_slot_t *slot = & spillslots[spill->spillslot];
626
627                 assert(slot->entity != NULL);
628
629                 be_set_frame_entity(reload, slot->entity);
630         }
631 }
632
633 static void create_memperms(ss_env_t *env) {
634         memperm_t *memperm;
635
636         for(memperm = set_first(env->memperms); memperm != NULL; memperm = set_next(env->memperms)) {
637                 int i;
638                 memperm_entry_t *entry;
639                 ir_node** nodes = alloca(memperm->entrycount * sizeof(nodes[0]));
640                 ir_node* mempermnode;
641
642                 assert(memperm->entrycount > 0);
643
644                 for(entry = memperm->entries, i = 0; entry != NULL; entry = entry->next, ++i) {
645                         ir_node* arg = get_irn_n(entry->node, entry->pos);
646                         nodes[i] = arg;
647                 }
648
649                 mempermnode = be_new_MemPerm(env->chordal_env->birg->main_env->arch_env, env->chordal_env->irg, memperm->block,
650                         memperm->entrycount, nodes);
651
652                 for(entry = memperm->entries, i = 0; entry != NULL; entry = entry->next, ++i) {
653                         ir_node *proj;
654                         ir_node* arg = get_irn_n(entry->node, entry->pos);
655
656                         be_set_MemPerm_in_entity(mempermnode, i, entry->in);
657                         be_set_MemPerm_out_entity(mempermnode, i, entry->out);
658                         proj = new_Proj(mempermnode, get_irn_mode(arg), i);
659                         set_irn_n(arg, entry->pos, proj);
660                 }
661                 ir_printf("Memperm created in block %+F\n", memperm->block);
662         }
663 }
664
665 void be_coalesce_spillslots(const be_chordal_env_t *chordal_env) {
666         ss_env_t env;
667
668         obstack_init(&env.obst);
669         env.chordal_env = chordal_env;
670         env.spills = new_set(cmp_spill, 10);
671         env.reloads = NEW_ARR_F(ir_node*, 0);
672         env.affinity_edges = NEW_ARR_F(affinity_edge_t*, 0);
673         env.memperms = new_set(cmp_memperm, 10);
674         FIRM_DBG_REGISTER(dbg, "firm.be.spillslots");
675         //firm_dbg_set_mask(dbg, DBG_COALESCING);
676
677         /* Get initial spill slots */
678         irg_walk_graph(chordal_env->irg, NULL, collect_spills_walker, &env);
679
680         do_greedy_coalescing(&env);
681         //do_java_coalescing(&env);
682
683         assign_spillslots(&env);
684
685         create_memperms(&env);
686
687         //show_stats(&env);
688
689         del_set(env.memperms);
690         DEL_ARR_F(env.reloads);
691         DEL_ARR_F(env.affinity_edges);
692         del_set(env.spills);
693         obstack_free(&env.obst, NULL);
694 }