added another test file
[libfirm] / ir / be / bespill.c
1 /**
2  * Author:      Daniel Grund, Sebastian Hack
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 "ident_t.h"
18 #include "type_t.h"
19 #include "entity_t.h"
20 #include "debug.h"
21 #include "irgwalk.h"
22 #include "array.h"
23
24 #include "belive_t.h"
25 #include "besched_t.h"
26 #include "bespill.h"
27 #include "benode_t.h"
28 #include "bechordal_t.h"
29
30 #undef REMAT
31 /* This enables re-computation of values. Current state: Unfinished and buggy. */
32 #undef BUGGY_REMAT
33
34 typedef struct _reloader_t reloader_t;
35 typedef struct _spill_info_t spill_info_t;
36
37 struct _reloader_t {
38         reloader_t *next;
39         ir_node *reloader;
40 };
41
42 struct _spill_info_t {
43         ir_node *spilled_node;
44         reloader_t *reloaders;
45 };
46
47 typedef struct _spill_ctx_t {
48         ir_node *spilled;  /**< The spilled node. */
49         ir_node *user;     /**< The node this spill is for. */
50         ir_node *spill;    /**< The spill itself. */
51 } spill_ctx_t;
52
53 struct _spill_env_t {
54         const arch_register_class_t *cls;
55         const be_chordal_env_t *chordal_env;
56         struct obstack obst;
57         set *spill_ctxs;
58         set *spills;                            /**< all spill_info_t's, which must be placed */
59         pset *mem_phis;                         /**< set of all special spilled phis. allocated and freed separately */
60         decide_irn_t is_mem_phi;        /**< callback func to decide if a phi needs special spilling */
61         void *data;                                     /**< data passed to all callbacks */
62         DEBUG_ONLY(firm_dbg_module_t *dbg;)
63 };
64
65 static int cmp_spillctx(const void *a, const void *b, size_t n) {
66         const spill_ctx_t *p = a;
67         const spill_ctx_t *q = b;
68         return !(p->user == q->user && p->spilled == q->spilled);
69 }
70
71 static int cmp_spillinfo(const void *x, const void *y, size_t size) {
72         const spill_info_t *xx = x;
73         const spill_info_t *yy = y;
74         return ! (xx->spilled_node == yy->spilled_node);
75 }
76
77 DEBUG_ONLY(
78 void be_set_spill_env_dbg_module(spill_env_t *env, firm_dbg_module_t *dbg) {
79         env->dbg = dbg;
80 }
81 );
82
83 spill_env_t *be_new_spill_env(const be_chordal_env_t *chordal_env, decide_irn_t is_mem_phi, void *data) {
84         spill_env_t *env = xmalloc(sizeof(env[0]));
85         env->spill_ctxs  = new_set(cmp_spillctx, 1024);
86         env->spills      = new_set(cmp_spillinfo, 1024);
87         env->cls         = chordal_env->cls;
88         env->is_mem_phi  = is_mem_phi;
89         env->data        = data;
90         env->chordal_env = chordal_env;
91         obstack_init(&env->obst);
92         return env;
93 }
94
95 void be_delete_spill_env(spill_env_t *senv) {
96         del_set(senv->spill_ctxs);
97         del_set(senv->spills);
98         obstack_free(&senv->obst, NULL);
99         free(senv);
100 }
101
102 static spill_ctx_t *be_get_spill_ctx(set *sc, ir_node *to_spill, ir_node *ctx_irn) {
103         spill_ctx_t templ;
104
105         templ.spilled = to_spill;
106         templ.user    = ctx_irn;
107         templ.spill   = NULL;
108
109         return set_insert(sc, &templ, sizeof(templ), HASH_COMBINE(HASH_PTR(to_spill), HASH_PTR(ctx_irn)));
110 }
111
112 static ir_node *be_spill_irn(spill_env_t *senv, ir_node *irn, ir_node *ctx_irn) {
113         spill_ctx_t *ctx;
114         DBG((senv->dbg, LEVEL_1, "%+F in ctx %+F\n", irn, ctx_irn));
115
116         ctx = be_get_spill_ctx(senv->spill_ctxs, irn, ctx_irn);
117         if(!ctx->spill) {
118                 const be_main_env_t *env = senv->chordal_env->birg->main_env;
119                 ctx->spill = be_spill(env->arch_env, irn, ctx_irn);
120         }
121
122         return ctx->spill;
123 }
124
125 /**
126  * If the first usage of a phi result would be out of memory
127  * there is no sense in allocating a register for it.
128  * Thus we spill it and all its operands to the same spill slot.
129  * Therefore the phi/dataB becomes a phi/Memory
130  */
131 static ir_node *be_spill_phi(spill_env_t *senv, ir_node *phi, ir_node *ctx_irn) {
132         int i, n = get_irn_arity(phi);
133         ir_node **ins, *bl = get_nodes_block(phi);
134         ir_graph *irg = senv->chordal_env->irg;
135         spill_ctx_t *ctx;
136
137         assert(is_Phi(phi));
138         DBG((senv->dbg, LEVEL_1, "%+F in ctx %+F\n", phi, ctx_irn));
139
140         /* search an existing spill for this context */
141         ctx = be_get_spill_ctx(senv->spill_ctxs, phi, ctx_irn);
142
143         /* if not found spill the phi */
144         if(!ctx->spill) {
145                 /* build a new PhiM with dummy in-array */
146     NEW_ARR_A(ir_node *, ins, n);
147                 for(i=0; i<n; ++i)
148                         ins[i] = new_r_Unknown(irg, mode_M);
149                 ctx->spill = new_r_Phi(senv->chordal_env->irg, bl, n, ins, mode_M);
150
151                 /* re-wire the phiM */
152                 for(i=0; i<n; ++i) {
153                         ir_node *arg = get_irn_n(phi, i);
154                         ir_node *sub_res;
155
156                         if(is_Phi(arg) && pset_find_ptr(senv->mem_phis, arg))
157                                 sub_res = be_spill_phi(senv, arg, ctx_irn);
158                         else
159                                 sub_res = be_spill_irn(senv, arg, ctx_irn);
160
161                         set_irn_n(ctx->spill, i, sub_res);
162                 }
163         }
164         return ctx->spill;
165 }
166
167 static ir_node *be_spill_node(spill_env_t *senv, ir_node *to_spill) {
168         ir_node *res;
169         if (pset_find_ptr(senv->mem_phis, to_spill))
170                 res = be_spill_phi(senv, to_spill, to_spill);
171         else
172                 res = be_spill_irn(senv, to_spill, to_spill);
173
174         return res;
175 }
176
177 static void phi_walker(ir_node *irn, void *env) {
178         spill_env_t *senv = env;
179         const arch_env_t *arch = senv->chordal_env->birg->main_env->arch_env;
180
181         if (is_Phi(irn) && arch_irn_has_reg_class(arch, irn, 0, senv->cls)
182                         && senv->is_mem_phi(irn, senv->data)) {
183                 DBG((senv->dbg, LEVEL_1, "  %+F\n", irn));
184                 pset_insert_ptr(senv->mem_phis, irn);
185         }
186 }
187
188 #ifdef REMAT
189
190 #ifdef BUGGY_REMAT
191
192 static int check_remat_conditions(spill_env_t *senv, ir_node *spill, ir_node *spilled, ir_node *reloader) {
193         int pos, max;
194
195         /* check for 'normal' spill and general remat condition */
196         if (!be_is_Spill(spill) || !arch_irn_is(senv->chordal_env->birg->main_env->arch_env, spilled, rematerializable))
197                 return 0;
198
199         /* check availability of original arguments */
200         if (is_Block(reloader)) {
201
202                 /* we want to remat at the end of a block.
203                  * thus all arguments must be alive at the end of the block
204                  */
205                 for (pos=0, max=get_irn_arity(spilled); pos<max; ++pos) {
206                         ir_node *arg = get_irn_n(spilled, pos);
207                         if (!is_live_end(reloader, arg))
208                                 return 0;
209                 }
210
211         } else {
212
213                 /* we want to remat before the insn reloader
214                  * thus an arguments is alive if
215                  *   - it interferes with the reloaders result
216                  * or
217                  *   - or it is (last-) used by reloader itself
218                  */
219                 for (pos=0, max=get_irn_arity(spilled); pos<max; ++pos) {
220                         ir_node *arg = get_irn_n(spilled, pos);
221                         int i, m;
222
223                         if (values_interfere(reloader, arg))
224                                 goto is_alive;
225
226                         for (i=0, m=get_irn_arity(reloader); i<m; ++i) {
227                                 ir_node *rel_arg = get_irn_n(reloader, i);
228                                 if (rel_arg == arg)
229                                         goto is_alive;
230                         }
231
232                         /* arg is not alive before reloader */
233                         return 0;
234
235 is_alive:       ;
236
237                 }
238
239         }
240
241         return 1;
242 }
243
244 #else /* BUGGY_REMAT */
245
246 static int check_remat_conditions(spill_env_t *senv, ir_node *spill, ir_node *spilled, ir_node *reloader) {
247         const arch_env_t *aenv = senv->chordal_env->birg->main_env->arch_env;
248
249         return get_irn_arity(spilled) == 0 &&
250                    be_is_Spill(spill) &&
251                    arch_irn_is(aenv, spilled, rematerializable);
252 }
253
254 #endif /* BUGGY_REMAT */
255
256 static ir_node *do_remat(spill_env_t *senv, ir_node *spilled, ir_node *reloader) {
257         ir_node *res;
258         ir_node *bl = (is_Block(reloader)) ? reloader : get_nodes_block(reloader);
259
260         /* recompute the value */
261         res = new_ir_node(get_irn_dbg_info(spilled), senv->chordal_env->irg, bl,
262                 get_irn_op(spilled),
263                 get_irn_mode(spilled),
264                 get_irn_arity(spilled),
265                 get_irn_in(spilled));
266         copy_node_attr(spilled, res);
267
268         DBG((senv->dbg, LEVEL_1, "Insert remat %+F before reloader %+F\n", res, reloader));
269
270         /* insert in schedule */
271         if (is_Block(reloader)) {
272                 ir_node *insert = sched_skip(reloader, 0, sched_skip_cf_predicator, (void *) senv->chordal_env->birg->main_env->arch_env);
273                 sched_add_after(insert, res);
274         } else {
275                 sched_add_before(reloader, res);
276         }
277
278         return res;
279 }
280
281 #endif
282
283 void be_insert_spills_reloads(spill_env_t *senv, pset *reload_set) {
284         const arch_env_t *aenv = senv->chordal_env->birg->main_env->arch_env;
285         ir_graph *irg          = senv->chordal_env->irg;
286         ir_node *irn;
287         spill_info_t *si;
288
289         /* get all special spilled phis */
290         DBG((senv->dbg, LEVEL_1, "Mem-phis:\n"));
291         senv->mem_phis = pset_new_ptr_default();
292         irg_walk_graph(senv->chordal_env->irg, phi_walker, NULL, senv);
293
294         /* Add reloads for mem_phis */
295         /* BETTER: These reloads (1) should only be inserted, if they are really needed */
296         DBG((senv->dbg, LEVEL_1, "Reloads for mem-phis:\n"));
297         for(irn = pset_first(senv->mem_phis); irn; irn = pset_next(senv->mem_phis)) {
298                 const ir_edge_t *e;
299                 DBG((senv->dbg, LEVEL_1, " Mem-phi %+F\n", irn));
300                 foreach_out_edge(irn, e) {
301                         ir_node *user = e->src;
302                         if (is_Phi(user) && !pset_find_ptr(senv->mem_phis, user)) {
303                                         ir_node *use_bl = get_nodes_block(user);
304                                         DBG((senv->dbg, LEVEL_1, " non-mem-phi user %+F\n", user));
305                                         be_add_reload_on_edge(senv, irn, use_bl, e->pos); /* (1) */
306                         }
307                 }
308         }
309
310         /* process each spilled node */
311         DBG((senv->dbg, LEVEL_1, "Insert spills and reloads:\n"));
312         for(si = set_first(senv->spills); si; si = set_next(senv->spills)) {
313                 reloader_t *rld;
314                 ir_mode *mode = get_irn_mode(si->spilled_node);
315                 pset *values = pset_new_ptr(16);
316
317                 /* go through all reloads for this spill */
318                 for(rld = si->reloaders; rld; rld = rld->next) {
319                         ir_node *new_val;
320
321                         /* the spill for this reloader */
322                         ir_node *spill   = be_spill_node(senv, si->spilled_node);
323
324 #ifdef REMAT
325                         if (check_remat_conditions(senv, spill, si->spilled_node, rld->reloader))
326                                 new_val = do_remat(senv, si->spilled_node, rld->reloader);
327                         else
328 #endif
329                                 /* do a reload */
330                                 new_val = be_reload(aenv, senv->cls, rld->reloader, mode, spill);
331
332                         DBG((senv->dbg, LEVEL_1, " %+F of %+F before %+F\n", new_val, si->spilled_node, rld->reloader));
333                         pset_insert_ptr(values, new_val);
334                         if(reload_set)
335                                 pset_insert_ptr(reload_set, new_val);
336                 }
337
338                 /* introduce copies, rewire the uses */
339                 assert(pset_count(values) > 0 && "???");
340                 pset_insert_ptr(values, si->spilled_node);
341                 be_ssa_constr_set_ignore(senv->chordal_env->dom_front, values, senv->mem_phis);
342
343                 del_pset(values);
344         }
345
346         for(irn = pset_first(senv->mem_phis); irn; irn = pset_next(senv->mem_phis)) {
347                 int i, n;
348                 for(i = 0, n = get_irn_arity(irn); i < n; ++i)
349                         set_irn_n(irn, i, new_r_Bad(senv->chordal_env->irg));
350                 sched_remove(irn);
351         }
352
353         del_pset(senv->mem_phis);
354 }
355
356 void be_add_reload(spill_env_t *senv, ir_node *to_spill, ir_node *before) {
357         spill_info_t templ, *res;
358         reloader_t *rel;
359
360         templ.spilled_node = to_spill;
361         templ.reloaders    = NULL;
362         res = set_insert(senv->spills, &templ, sizeof(templ), HASH_PTR(to_spill));
363
364         rel           = obstack_alloc(&senv->obst, sizeof(rel[0]));
365         rel->reloader = before;
366         rel->next     = res->reloaders;
367         res->reloaders = rel;
368 }
369
370 void be_add_reload_on_edge(spill_env_t *senv, ir_node *to_spill, ir_node *bl, int pos) {
371         ir_node *insert_bl = get_irn_arity(bl) == 1 ? sched_first(bl) : get_Block_cfgpred_block(bl, pos);
372         be_add_reload(senv, to_spill, insert_bl);
373 }
374
375
376
377 /****************************************
378
379         SPILL SLOT MANAGEMENT AND OPTS
380
381 ****************************************/
382
383 typedef struct _spill_slot_t {
384         unsigned size;
385         unsigned align;
386         pset *members;
387         ir_mode *largest_mode;  /* the mode of all members with largest size */
388 } spill_slot_t;
389
390 typedef struct _ss_env_t {
391         struct obstack ob;
392         be_chordal_env_t *cenv;
393         pmap *slots;            /* maps spill_contexts to spill_slots */
394         pmap *types;    /* maps modes to types */
395         DEBUG_ONLY(firm_dbg_module_t *dbg;)
396 } ss_env_t;
397
398 /**
399  * Walker: compute the spill slots
400  */
401 static void compute_spill_slots_walker(ir_node *spill, void *env) {
402         ss_env_t *ssenv = env;
403         ir_node *ctx;
404         pmap_entry *entry;
405         spill_slot_t *ss;
406
407         if (!be_is_Spill(spill))
408                 return;
409
410         /* check, if this spill is for a context already known */
411         ctx = be_get_Spill_context(spill);
412         entry = pmap_find(ssenv->slots, ctx);
413
414         if (!entry) {
415                 struct _arch_env_t *arch_env     = ssenv->cenv->birg->main_env->arch_env;
416                 ir_node *spilled                 = get_irn_n(spill, be_pos_Spill_val);
417                 const arch_register_t *reg       = arch_get_irn_register(arch_env, spilled);
418                 const arch_register_class_t *cls = arch_register_get_class(reg);
419                 ir_mode *largest_mode            = arch_register_class_mode(cls);
420
421                 /* this is a new spill context */
422                 ss = obstack_alloc(&ssenv->ob, sizeof(*ss));
423                 ss->members      = pset_new_ptr(8);
424                 ss->largest_mode = largest_mode;
425                 ss->size         = get_mode_size_bytes(ss->largest_mode);
426                 ss->align        = arch_isa_get_reg_class_alignment(arch_env->isa, cls);
427                 pmap_insert(ssenv->slots, ctx, ss);
428         } else {
429                 ir_node *irn;
430                 /* values with the same spill_ctx must go into the same spill slot */
431                 ss = entry->value;
432                 assert(ss->size == (unsigned)get_mode_size_bytes(get_irn_mode(get_irn_n(spill, be_pos_Spill_val))) && "Different sizes for the same spill slot are not allowed yet.");
433                 for (irn = pset_first(ss->members); irn; irn = pset_next(ss->members)) {
434                         /* use values_interfere here, because it uses the dominance check,
435                            which does work for values in memory */
436                         assert(!values_interfere(spill, irn) && "Spills for the same spill slot must not interfere!");
437                 }
438         }
439
440         pset_insert_ptr(ss->members, spill);
441 }
442
443 /**
444  * qsort compare function, sort spill slots by size.
445  */
446 static int ss_sorter(const void *v1, const void *v2) {
447         const spill_slot_t *ss1 = v1;
448         const spill_slot_t *ss2 = v2;
449         return ((int) ss2->size) - ((int) ss1->size);
450 }
451
452
453 /**
454  * This function should optimize the spill slots.
455  *  - Coalescing of multiple slots
456  *  - Ordering the slots
457  *
458  * Input slots are in @p ssenv->slots
459  * @p size The count of initial spill slots in @p ssenv->slots
460  *         This also is the size of the preallocated array @p ass
461  *
462  * @return An array of spill slots @p ass in specific order
463  **/
464 static void optimize_slots(ss_env_t *ssenv, int size, spill_slot_t **ass) {
465         int i, o, used_slots;
466         pmap_entry *entr;
467
468         i=0;
469         pmap_foreach(ssenv->slots, entr)
470                 ass[i++] = entr->value;
471
472         /* Sort the array to minimize fragmentation and cache footprint.
473            Large slots come first */
474         qsort(ass, size, sizeof(ass[0]), ss_sorter);
475
476         /* For each spill slot:
477                 - assign a new offset to this slot
478             - xor find another slot to coalesce with */
479         used_slots = 0;
480         for (i=0; i<size; ++i) { /* for each spill slot */
481                 ir_node *n1;
482                 int tgt_slot = -1;
483
484                 DBG((ssenv->dbg, LEVEL_1, "Spill slot %d members:\n", i));
485                 for(n1 = pset_first(ass[i]->members); n1; n1 = pset_next(ass[i]->members))
486                         DBG((ssenv->dbg, LEVEL_1, "  %+F\n", n1));
487
488
489                 for (o=0; o < used_slots && tgt_slot == -1; ++o) { /* for each offset-assigned spill slot */
490                         /* check inter-slot-pairs for interference */
491                         ir_node *n2;
492                         for(n1 = pset_first(ass[i]->members); n1; n1 = pset_next(ass[i]->members))
493                                 for(n2 = pset_first(ass[o]->members); n2; n2 = pset_next(ass[o]->members))
494                                         if(values_interfere(n1, n2)) {
495                                                 pset_break(ass[i]->members);
496                                                 pset_break(ass[o]->members);
497                                                 DBG((ssenv->dbg, LEVEL_1, "    Interf %+F -- %+F\n", n1, n2));
498                                                 goto interf_detected;
499                                         }
500
501                         /* if we are here, there is no interference between ass[i] and ass[o] */
502                         tgt_slot = o;
503
504 interf_detected: /*nothing*/ ;
505                 }
506
507                 /* now the members of ass[i] join the members of ass[tgt_slot] */
508
509                 /* do we need a new slot? */
510                 if (tgt_slot == -1) {
511                         tgt_slot = used_slots;
512                         used_slots++;
513
514                         /* init slot */
515                         if (tgt_slot != i) {
516                                 ass[tgt_slot]->size = ass[i]->size;
517                                 del_pset(ass[tgt_slot]->members);
518                                 ass[tgt_slot]->members = pset_new_ptr(8);
519                         }
520                 }
521
522                 /* copy the members to the target pset */
523                 /* NOTE: If src and tgt pset are the same, inserting while iterating is not allowed */
524                 if (tgt_slot != i)
525                         for(n1 = pset_first(ass[i]->members); n1; n1 = pset_next(ass[i]->members))
526                                         pset_insert_ptr(ass[tgt_slot]->members, n1);
527         }
528 }
529
530 #define ALIGN_SPILL_AREA 16
531 #define pset_foreach(pset, elm)  for(elm=pset_first(pset); elm; elm=pset_next(pset))
532
533 /**
534  * Returns a spill type for a mode. Keep them in a map to reduce
535  * the number of types.
536  *
537  * @param types  a map containing all created types
538  * @param ss     the spill slot
539  *
540  * Note that type types should are identical for every mode.
541  * This rule might break if two different register classes return the same
542  * mode but different alignments.
543  */
544 static ir_type *get_spill_type(pmap *types, spill_slot_t *ss) {
545   pmap_entry *e = pmap_find(types, ss->largest_mode);
546   ir_type *res;
547
548   if (! e) {
549                 char buf[64];
550     snprintf(buf, sizeof(buf), "spill_slot_type_%s", get_mode_name(ss->largest_mode));
551     res = new_type_primitive(new_id_from_str(buf), ss->largest_mode);
552                 set_type_alignment_bytes(res, ss->align);
553     pmap_insert(types, ss->largest_mode, res);
554   }
555   else {
556     res = e->value;
557                 assert(get_type_alignment_bytes(res) == (int)ss->align);
558         }
559   return res;
560 }
561
562 /**
563  * Create spill slot entities on the frame type.
564  *
565  * @param ssenv   the spill environment
566  * @param n       number of spill slots
567  * @param ss      array of spill slots
568  */
569 static void assign_entities(ss_env_t *ssenv, int n_slots, spill_slot_t *ss[]) {
570         int i, offset, frame_align;
571         ir_type *frame = get_irg_frame_type(ssenv->cenv->irg);
572
573         /* aligning by increasing frame size */
574         offset = get_type_size_bits(frame) / 8;
575         offset = round_up2(offset, ALIGN_SPILL_AREA);
576         set_type_size_bytes(frame, -1);
577
578         /* create entities and assign offsets according to size and alignment*/
579         for (i = 0; i < n_slots; ++i) {
580                 char buf[64];
581                 ident *name;
582                 entity *spill_ent;
583                 ir_node *irn;
584
585                 /* build entity */
586                 snprintf(buf, sizeof(buf), "spill_slot_%d", i);
587                 name = new_id_from_str(buf);
588
589                 spill_ent = new_entity(frame, name, get_spill_type(ssenv->types, ss[i]));
590
591                 /* align */
592                 offset = round_up2(offset, ss[i]->align);
593                 /* set */
594                 set_entity_offset_bytes(spill_ent, offset);
595                 /* next possible offset */
596                 offset += round_up2(ss[i]->size, ss[i]->align);
597
598                 pset_foreach(ss[i]->members, irn)
599                         be_set_Spill_entity(irn, spill_ent);
600         }
601
602         /* set final size of stack frame */
603         frame_align = get_type_alignment_bytes(frame);
604         set_type_size_bytes(frame, round_up2(offset, frame_align));
605 }
606
607 void be_compute_spill_offsets(be_chordal_env_t *cenv) {
608         ss_env_t ssenv;
609         spill_slot_t **ss;
610         int ss_size;
611         pmap_entry *pme;
612
613         obstack_init(&ssenv.ob);
614         ssenv.cenv  = cenv;
615         ssenv.slots = pmap_create();
616         ssenv.types = pmap_create();
617         FIRM_DBG_REGISTER(ssenv.dbg, "ir.be.spillslots");
618
619         /* Get initial spill slots */
620         irg_walk_graph(cenv->irg, NULL, compute_spill_slots_walker, &ssenv);
621
622         /* Build an empty array for optimized spill slots */
623         ss_size = pmap_count(ssenv.slots);
624         ss = obstack_alloc(&ssenv.ob, ss_size * sizeof(*ss));
625         optimize_slots(&ssenv, ss_size, ss);
626
627         /* Integrate slots into the stack frame entity */
628         assign_entities(&ssenv, ss_size, ss);
629
630         /* Clean up */
631         pmap_foreach(ssenv.slots, pme)
632         del_pset(((spill_slot_t *)pme->value)->members);
633         pmap_destroy(ssenv.slots);
634         pmap_destroy(ssenv.types);
635         obstack_free(&ssenv.ob, NULL);
636
637         be_copy_entities_to_reloads(cenv->irg);
638 }