e530328397846600b1332c6ef9dc308e8a84b584
[libfirm] / ir / be / bespillbelady.c
1 /**
2  * Author:      Daniel Grund
3  * Date:                20.09.2005
4  * Copyright:   (c) Universitaet Karlsruhe
5  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
6  *
7  */
8 #ifdef HAVE_CONFIG_H
9 #include "config.h"
10 #endif
11
12 #ifdef HAVE_ALLOCA_H
13 #include <alloca.h>
14 #endif
15
16 #ifdef HAVE_MALLOC_H
17 #include <malloc.h>
18 #endif
19
20 #include "obst.h"
21 #include "set.h"
22 #include "pset.h"
23 #include "irprintf_t.h"
24 #include "irgraph.h"
25 #include "irnode.h"
26 #include "irmode.h"
27 #include "irgwalk.h"
28 #include "iredges_t.h"
29 #include "ircons_t.h"
30 #include "irprintf.h"
31
32 #include "beutil.h"
33 #include "bearch.h"
34 #include "bespillbelady.h"
35 #include "beuses_t.h"
36 #include "besched_t.h"
37 #include "beirgmod.h"
38 #include "belive_t.h"
39 #include "benode_t.h"
40 #include "bechordal_t.h"
41
42 #define DBG_SPILL   1
43 #define DBG_WSETS   2
44 #define DBG_FIX     4
45 #define DBG_DECIDE  8
46 #define DBG_START  16
47 #define DBG_SLOTS  32
48 #define DBG_TRACE  64
49 #define DBG_WORKSET 128
50 #define DEBUG_LVL 0 //(DBG_START | DBG_DECIDE | DBG_WSETS | DBG_FIX | DBG_SPILL)
51 DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
52
53 /**
54  * An association between a node and a point in time.
55  */
56 typedef struct _loc_t {
57   ir_node *irn;        /**< A node. */
58   unsigned time;       /**< A use time (see beuses.h). */
59 } loc_t;
60
61 typedef struct _workset_t {
62         int len;                        /**< current length */
63         loc_t vals[0];          /**< inlined array of the values/distances in this working set */
64 } workset_t;
65
66 typedef struct _belady_env_t {
67         struct obstack ob;
68         const be_chordal_env_t *cenv;
69         const arch_env_t *arch;
70         const arch_register_class_t *cls;
71         int n_regs;                     /** number of regs in this reg-class */
72
73         workset_t *ws;          /**< the main workset used while processing a block. ob-allocated */
74         be_uses_t *uses;        /**< env for the next-use magic */
75         ir_node *instr;         /**< current instruction */
76         unsigned instr_nr;      /**< current instruction number (relative to block start) */
77         pset *used;
78
79         spill_env_t *senv;      /**< see bespill.h */
80 } belady_env_t;
81
82 static int loc_compare(const void *a, const void *b)
83 {
84         const loc_t *p = a;
85         const loc_t *q = b;
86         return p->time - q->time;
87 }
88
89 void workset_print(const workset_t *w)
90 {
91         int i;
92
93         for(i = 0; i < w->len; ++i) {
94                 ir_fprintf(stderr, "%+F %d\n", w->vals[i].irn, w->vals[i].time);
95         }
96 }
97
98 /**
99  * Alloc a new workset on obstack @p ob with maximum size @p max
100  */
101 static INLINE workset_t *new_workset(belady_env_t *env, struct obstack *ob) {
102         workset_t *res;
103         size_t size = sizeof(*res) + (env->n_regs)*sizeof(res->vals[0]);
104         res = obstack_alloc(ob, size);
105         memset(res, 0, size);
106         return res;
107 }
108
109 /**
110  * Alloc a new instance on obstack and make it equal to @param ws
111  */
112 static INLINE workset_t *workset_clone(belady_env_t *env, struct obstack *ob, workset_t *ws) {
113         workset_t *res;
114         size_t size = sizeof(*res) + (env->n_regs)*sizeof(res->vals[0]);
115         res = obstack_alloc(ob, size);
116         memcpy(res, ws, size);
117         return res;
118 }
119
120 /**
121  * Do NOT alloc anything. Make @param tgt equal to @param src.
122  * returns @param tgt for convenience
123  */
124 static INLINE workset_t *workset_copy(belady_env_t *env, workset_t *tgt, workset_t *src) {
125         size_t size = sizeof(*src) + (env->n_regs)*sizeof(src->vals[0]);
126         memcpy(tgt, src, size);
127         return tgt;
128 }
129
130 /**
131  * Overwrites the current content array of @param ws with the
132  * @param count locations given at memory @param locs.
133  * Set the length of @param ws to count.
134  */
135 static INLINE void workset_bulk_fill(workset_t *workset, int count, const loc_t *locs) {
136         workset->len = count;
137         memcpy(&(workset->vals[0]), locs, count * sizeof(locs[0]));
138 }
139
140 /**
141  * Inserts the value @p val into the workset, iff it is not
142  * already contained. The workset must not be full.
143  */
144 static INLINE void workset_insert(belady_env_t *env, workset_t *ws, ir_node *val) {
145         int i;
146         /* check for current regclass */
147         if (!arch_irn_consider_in_reg_alloc(env->arch, env->cls, val)) {
148                 DBG((dbg, DBG_WORKSET, "Dropped %+F\n", val));
149                 return;
150         }
151
152         /* check if val is already contained */
153         for(i=0; i<ws->len; ++i)
154                 if (ws->vals[i].irn == val)
155                         return;
156
157         /* insert val */
158         assert(ws->len < env->n_regs && "Workset already full!");
159         ws->vals[ws->len++].irn = val;
160 }
161
162 /**
163  * Removes all entries from this workset
164  */
165 static INLINE void workset_clear(workset_t *ws) {
166         ws->len = 0;
167 }
168
169 /**
170  * Removes the value @p val from the workset if present.
171  */
172 static INLINE void workset_remove(workset_t *ws, ir_node *val) {
173         int i;
174         for(i=0; i<ws->len; ++i) {
175                 if (ws->vals[i].irn == val) {
176                         ws->vals[i] = ws->vals[--ws->len];
177                         return;
178                 }
179         }
180 }
181
182 static INLINE int workset_contains(const workset_t *ws, const ir_node *val) {
183         int i;
184         for(i=0; i<ws->len; ++i) {
185                 if (ws->vals[i].irn == val)
186                         return 1;
187         }
188
189         return 0;
190 }
191
192 /**
193  * Iterates over all values in the working set.
194  * @p ws The workset to iterate
195  * @p v  A variable to put the current value in
196  * @p i  An integer for internal use
197  */
198 #define workset_foreach(ws, v, i)       for(i=0; \
199                                                                                 v=(i < ws->len) ? ws->vals[i].irn : NULL, i < ws->len; \
200                                                                                 ++i)
201
202 #define workset_set_time(ws, i, t) (ws)->vals[i].time=t
203 #define workset_get_time(ws, i) (ws)->vals[i].time
204 #define workset_set_length(ws, length) (ws)->len = length
205 #define workset_get_length(ws) ((ws)->len)
206 #define workset_get_val(ws, i) ((ws)->vals[i].irn)
207 #define workset_sort(ws) qsort((ws)->vals, (ws)->len, sizeof((ws)->vals[0]), loc_compare);
208
209 typedef struct _block_info_t {
210         workset_t *ws_start, *ws_end;
211         int processed;
212 } block_info_t;
213
214
215 static INLINE void *new_block_info(struct obstack *ob) {
216         block_info_t *res = obstack_alloc(ob, sizeof(*res));
217         res->ws_start = NULL;
218         res->ws_end = NULL;
219         res->processed = 0;
220
221         return res;
222 }
223
224 #define get_block_info(blk)                     ((block_info_t *)get_irn_link(blk))
225 #define set_block_info(blk, info)       set_irn_link(blk, info)
226
227 /**
228  * @return The distance to the next use or 0 if irn has dont_spill flag set
229  */
230 static INLINE unsigned get_distance(belady_env_t *env, const ir_node *from, unsigned from_step, const ir_node *def, int skip_from_uses)
231 {
232         int flags = arch_irn_get_flags(env->arch, def);
233         unsigned dist;
234
235         assert(! (flags & arch_irn_flags_ignore));
236
237         /* We have to keep nonspillable nodes in the workingset */
238         if(flags & arch_irn_flags_dont_spill)
239                 return 0;
240
241         dist = be_get_next_use(env->uses, from, from_step, def, skip_from_uses);
242
243         if(USES_IS_INFINITE(dist))
244                 dist = USES_INFINITY;
245
246         return dist;
247 }
248
249 /**
250  * Fix to remove dead nodes (especially don't spill nodes) from workset.
251  */
252 static void fix_dead_values(workset_t *ws, ir_node *irn) {
253         int idx;
254         ir_node *node;
255         ir_node *block = get_nodes_block(irn);
256
257         DBG((dbg, DBG_DECIDE, "fixing dead values at %+F:\n", irn));
258
259         workset_foreach(ws, node, idx) {
260                 const ir_edge_t *edge;
261                 int             fixme = 1;
262
263                 /* skip already fixed nodes */
264                 if (workset_get_time(ws, idx) == INT_MAX)
265                         continue;
266
267                 /* check all users */
268                 foreach_out_edge(node, edge) {
269                         ir_node *user = get_edge_src_irn(edge);
270
271                         if ((get_nodes_block(user) != block)                           ||  /* user is in a different block */
272                                 (sched_is_scheduled(user) && sched_comes_after(irn, user)) ||  /* user is scheduled after irn */
273                                 user == irn)                                                   /* irn is the user */
274                         {                                                                  /* => don't fix distance */
275                                 fixme = 0;
276                                 break;
277                         }
278                 }
279
280                 /* all users scheduled prior to current irn in in same block as irn -> fix */
281                 if (fixme) {
282                         workset_set_time(ws, idx, INT_MAX);
283                         DBG((dbg, DBG_DECIDE, "\tfixing time for %+F to INT_MAX\n", node));
284                 }
285         }
286
287 }
288
289 /**
290  * Performs the actions necessary to grant the request that:
291  * - new_vals can be held in registers
292  * - as few as possible other values are disposed
293  * - the worst values get disposed
294  *
295  * @p is_usage indicates that the values in new_vals are used (not defined)
296  * In this case reloads must be performed
297  */
298 static void displace(belady_env_t *env, workset_t *new_vals, int is_usage) {
299         ir_node *val;
300         int     i, len, max_allowed, demand, iter;
301
302         workset_t *ws         = env->ws;
303         ir_node   **to_insert = alloca(env->n_regs * sizeof(*to_insert));
304
305         /*
306                 1. Identify the number of needed slots and the values to reload
307         */
308         demand = 0;
309         workset_foreach(new_vals, val, iter) {
310                 /* mark value as used */
311                 if (is_usage)
312                         pset_insert_ptr(env->used, val);
313
314                 if (! workset_contains(ws, val)) {
315                         DBG((dbg, DBG_DECIDE, "    insert %+F\n", val));
316                         to_insert[demand++] = val;
317                         if (is_usage)
318                                 be_add_reload(env->senv, val, env->instr);
319                 }
320                 else {
321                         assert(is_usage || "Defined value already in workset?!?");
322                         DBG((dbg, DBG_DECIDE, "    skip %+F\n", val));
323                 }
324         }
325         DBG((dbg, DBG_DECIDE, "    demand = %d\n", demand));
326
327         /*
328                 2. Make room for at least 'demand' slots
329         */
330         len         = workset_get_length(ws);
331         max_allowed = env->n_regs - demand;
332
333         DBG((dbg, DBG_DECIDE, "    disposing %d values\n", ws->len - max_allowed));
334
335         /* Only make more free room if we do not have enough */
336         if (len > max_allowed) {
337                 /* get current next-use distance */
338                 for (i = 0; i < ws->len; ++i) {
339                         unsigned dist = get_distance(env, env->instr, env->instr_nr, workset_get_val(ws, i), !is_usage);
340                         workset_set_time(ws, i, dist);
341                 }
342
343                 /*
344                         FIX for don't spill nodes:
345                         Problem is that get_distance always returns 0 for those nodes even if they are not
346                         needed anymore (all their usages have already been visited).
347                         Even if we change this behavior, get_distance doesn't distinguish between not
348                         used anymore (dead) and live out of block.
349                         Solution: Set distances of all nodes having all their usages in schedule prior to
350                         current instruction to MAX_INT.
351                 */
352                 fix_dead_values(ws, env->instr);
353
354                 /* sort entries by increasing nextuse-distance*/
355                 workset_sort(ws);
356
357                 /*
358                         Logic for not needed live-ins: If a value is disposed
359                         before its first usage, remove it from start workset
360                         We don't do this for phis though
361                 */
362                 for (i = max_allowed; i < ws->len; ++i) {
363                         ir_node *irn = ws->vals[i].irn;
364
365             if (is_Phi(irn))
366                 continue;
367
368                         if (! pset_find_ptr(env->used, irn)) {
369                                 ir_node   *curr_bb  = get_nodes_block(env->instr);
370                                 workset_t *ws_start = get_block_info(curr_bb)->ws_start;
371                                 workset_remove(ws_start, irn);
372
373                                 DBG((dbg, DBG_DECIDE, "    dispose %+F dumb\n", irn));
374                         }
375                         else {
376                                 DBG((dbg, DBG_DECIDE, "    dispose %+F\n", irn));
377                         }
378                 }
379
380                 /* kill the last 'demand' entries in the array */
381                 workset_set_length(ws, max_allowed);
382         }
383
384         /*
385                 3. Insert the new values into the workset
386         */
387         for (i = 0; i < demand; ++i)
388                 workset_insert(env, env->ws, to_insert[i]);
389 }
390
391 static void belady(ir_node *blk, void *env);
392
393 /*
394  * Computes set of live-ins for each block with multiple predecessors
395  * and notifies spill algorithm which phis need to be spilled
396  */
397 static void spill_phi_walker(ir_node *block, void *data) {
398         belady_env_t *env = data;
399         block_info_t *block_info;
400         ir_node *first, *irn;
401         loc_t loc, *starters;
402         int i, len, ws_count;
403
404         if(get_Block_n_cfgpreds(block) == 1 && get_irg_start_block(get_irn_irg(block)) != block)
405                 return;
406
407         block_info = new_block_info(&env->ob);
408         set_block_info(block, block_info);
409
410         /* Collect all values living at start of block */
411         starters = NEW_ARR_F(loc_t, 0);
412
413         /* rebuild schedule time information, because it seems to be broken */
414         sched_renumber(block);
415
416         DBG((dbg, DBG_START, "Living at start of %+F:\n", block));
417         first = sched_first(block);
418         sched_foreach(block, irn) {
419                 if(!is_Phi(irn))
420                         break;
421                 if(!arch_irn_consider_in_reg_alloc(env->arch, env->cls, irn))
422                         continue;
423
424                 loc.irn = irn;
425                 loc.time = get_distance(env, first, 0, irn, 0);
426                 ARR_APP1(loc_t, starters, loc);
427                 DBG((dbg, DBG_START, "    %+F:\n", irn));
428         }
429
430         be_lv_foreach(env->cenv->lv, block, be_lv_state_in, i) {
431                 ir_node *irn = be_lv_get_irn(env->cenv->lv, block, i);
432                 if (!arch_irn_consider_in_reg_alloc(env->arch, env->cls, irn))
433                         continue;
434
435                 loc.irn = irn;
436                 loc.time = get_distance(env, first, 0, irn, 0);
437                 ARR_APP1(loc_t, starters, loc);
438                 DBG((dbg, DBG_START, "    %+F:\n", irn));
439         }
440
441         // Sort start values by first use
442         qsort(starters, ARR_LEN(starters), sizeof(starters[0]), loc_compare);
443
444         /* Copy the best ones from starters to start workset */
445         ws_count = MIN(ARR_LEN(starters), env->n_regs);
446         block_info->ws_start = new_workset(env, &env->ob);
447         workset_bulk_fill(block_info->ws_start, ws_count, starters);
448
449         /* The phis of this block which are not in the start set have to be spilled later. */
450         for (i = ws_count, len = ARR_LEN(starters); i < len; ++i) {
451                 irn = starters[i].irn;
452                 if (!is_Phi(irn) || get_nodes_block(irn) != block)
453                         continue;
454
455                 be_spill_phi(env->senv, irn);
456         }
457
458         DEL_ARR_F(starters);
459 }
460
461 /**
462  * Collects all values live-in at block @p blk and all phi results in this block.
463  * Then it adds the best values (at most n_regs) to the blocks start_workset.
464  * The phis among the remaining values get spilled: Introduce psudo-copies of
465  *  their args to break interference and make it possible to spill them to the
466  *  same spill slot.
467  */
468 static block_info_t *compute_block_start_info(belady_env_t *env, ir_node *block) {
469         ir_node *pred_block;
470         block_info_t *res, *pred_info;
471
472         /* Have we seen this block before? */
473         res = get_block_info(block);
474         if (res)
475                 return res;
476
477         /* Create the block info for this block. */
478         res = new_block_info(&env->ob);
479         set_block_info(block, res);
480
481         /* Use endset of predecessor block as startset */
482         assert(get_Block_n_cfgpreds(block) == 1 && block != get_irg_start_block(get_irn_irg(block)));
483         pred_block = get_Block_cfgpred_block(block, 0);
484         pred_info = get_block_info(pred_block);
485
486         /* if pred block has not been processed yet, do it now */
487         if (pred_info == NULL || pred_info->processed == 0) {
488                 belady(pred_block, env);
489                 pred_info = get_block_info(pred_block);
490         }
491
492         /* now we have an end_set of pred */
493         assert(pred_info->ws_end && "The recursive call (above) is supposed to compute an end_set");
494         res->ws_start = workset_clone(env, &env->ob, pred_info->ws_end);
495
496         return res;
497 }
498
499
500 /**
501  * For the given block @p blk, decide for each values
502  * whether it is used from a register or is reloaded
503  * before the use.
504  */
505 static void belady(ir_node *block, void *data) {
506         belady_env_t *env = data;
507         workset_t *new_vals;
508         ir_node *irn;
509         int iter;
510         block_info_t *block_info;
511
512         /* make sure we have blockinfo (with startset) */
513         block_info = get_block_info(block);
514         if (block_info == NULL)
515                 block_info = compute_block_start_info(env, block);
516
517         /* Don't do a block twice */
518         if(block_info->processed)
519                 return;
520
521         /* get the starting workset for this block */
522         DBG((dbg, DBG_DECIDE, "\n"));
523         DBG((dbg, DBG_DECIDE, "Decide for %+F\n", block));
524
525         workset_copy(env, env->ws, block_info->ws_start);
526         DBG((dbg, DBG_WSETS, "Start workset for %+F:\n", block));
527         workset_foreach(env->ws, irn, iter)
528                 DBG((dbg, DBG_WSETS, "  %+F\n", irn));
529
530         /* process the block from start to end */
531         DBG((dbg, DBG_WSETS, "Processing...\n"));
532         env->used = pset_new_ptr_default();
533         env->instr_nr = 0;
534         new_vals = new_workset(env, &env->ob);
535         sched_foreach(block, irn) {
536                 int i, arity;
537                 assert(workset_get_length(env->ws) <= env->n_regs && "Too much values in workset!");
538
539                 /* projs are handled with the tuple value.
540                  * Phis are no real instr (see insert_starters())
541                  * instr_nr does not increase */
542                 if (is_Proj(irn) || is_Phi(irn)) {
543                         DBG((dbg, DBG_DECIDE, "  ...%+F skipped\n", irn));
544                         continue;
545                 }
546                 DBG((dbg, DBG_DECIDE, "  ...%+F\n", irn));
547
548                 /* set instruction in the workset */
549                 env->instr = irn;
550
551                 /* allocate all values _used_ by this instruction */
552                 workset_clear(new_vals);
553                 for(i = 0, arity = get_irn_arity(irn); i < arity; ++i) {
554                         workset_insert(env, new_vals, get_irn_n(irn, i));
555                 }
556                 displace(env, new_vals, 1);
557
558                 /* allocate all values _defined_ by this instruction */
559                 workset_clear(new_vals);
560                 if (get_irn_mode(irn) == mode_T) { /* special handling for tuples and projs */
561                         ir_node *proj;
562                         for(proj=sched_next(irn); is_Proj(proj); proj=sched_next(proj))
563                                 workset_insert(env, new_vals, proj);
564                 } else {
565                         workset_insert(env, new_vals, irn);
566                 }
567                 displace(env, new_vals, 0);
568
569                 env->instr_nr++;
570         }
571         del_pset(env->used);
572
573         /* Remember end-workset for this block */
574         block_info->ws_end = workset_clone(env, &env->ob, env->ws);
575         block_info->processed = 1;
576         DBG((dbg, DBG_WSETS, "End workset for %+F:\n", block));
577         workset_foreach(block_info->ws_end, irn, iter)
578                 DBG((dbg, DBG_WSETS, "  %+F\n", irn));
579 }
580
581 /**
582  * 'decide' is block-local and makes assumptions
583  * about the set of live-ins. Thus we must adapt the
584  * live-outs to the live-ins at each block-border.
585  */
586 static void fix_block_borders(ir_node *blk, void *data) {
587         belady_env_t *env = data;
588         workset_t *wsb;
589         int i, max, iter, iter2;
590
591         DBG((dbg, DBG_FIX, "\n"));
592         DBG((dbg, DBG_FIX, "Fixing %+F\n", blk));
593
594         wsb = get_block_info(blk)->ws_start;
595
596         /* process all pred blocks */
597         for (i=0, max=get_irn_arity(blk); i<max; ++i) {
598                 ir_node *irnb, *irnp, *pred = get_Block_cfgpred_block(blk, i);
599                 workset_t *wsp = get_block_info(pred)->ws_end;
600
601                 DBG((dbg, DBG_FIX, "  Pred %+F\n", pred));
602
603                 workset_foreach(wsb, irnb, iter) {
604                         /* if irnb is a phi of the current block we reload
605                          * the corresponding argument, else irnb itself */
606                         if(is_Phi(irnb) && blk == get_nodes_block(irnb)) {
607                                 irnb = get_irn_n(irnb, i);
608
609                                 // we might have unknowns as argument for the phi
610                                 if(!arch_irn_consider_in_reg_alloc(env->arch, env->cls, irnb))
611                                         continue;
612                         }
613
614                         /* Unknowns are available everywhere */
615                         if(get_irn_opcode(irnb) == iro_Unknown)
616                                 continue;
617
618                         /* check if irnb is in a register at end of pred */
619                         workset_foreach(wsp, irnp, iter2) {
620                                 if (irnb == irnp)
621                                         goto next_value;
622                         }
623
624                         /* irnb is not in memory at the end of pred, so we have to reload it */
625                         DBG((dbg, DBG_FIX, "    reload %+F\n", irnb));
626                         be_add_reload_on_edge(env->senv, irnb, blk, i);
627
628 next_value:
629                         /*epsilon statement :)*/;
630                 }
631         }
632 }
633
634 void be_spill_belady(const be_chordal_env_t *chordal_env) {
635         be_spill_belady_spill_env(chordal_env, NULL);
636 }
637
638 void be_spill_belady_spill_env(const be_chordal_env_t *chordal_env, spill_env_t *spill_env) {
639         belady_env_t env;
640
641         FIRM_DBG_REGISTER(dbg, "firm.be.spill.belady");
642         //firm_dbg_set_mask(dbg, DBG_START);
643
644         /* init belady env */
645         obstack_init(&env.ob);
646         env.cenv      = chordal_env;
647         env.arch      = chordal_env->birg->main_env->arch_env;
648         env.cls       = chordal_env->cls;
649         env.n_regs    = env.cls->n_regs - be_put_ignore_regs(chordal_env->birg, chordal_env->cls, NULL);
650         env.ws        = new_workset(&env, &env.ob);
651         env.uses      = be_begin_uses(chordal_env->irg, chordal_env->exec_freq, chordal_env->lv);
652         if(spill_env == NULL) {
653                 env.senv = be_new_spill_env(chordal_env);
654         } else {
655                 env.senv = spill_env;
656         }
657         DEBUG_ONLY(be_set_spill_env_dbg_module(env.senv, dbg);)
658
659         DBG((dbg, LEVEL_1, "running on register class: %s\n", env.cls->name));
660
661         be_clear_links(chordal_env->irg);
662         /* Decide which phi nodes will be spilled and place copies for them into the graph */
663         irg_block_walk_graph(chordal_env->irg, spill_phi_walker, NULL, &env);
664         /* Fix high register pressure with belady algorithm */
665         irg_block_walk_graph(chordal_env->irg, NULL, belady, &env);
666         /* belady was block-local, fix the global flow by adding reloads on the edges */
667         irg_block_walk_graph(chordal_env->irg, fix_block_borders, NULL, &env);
668         /* Insert spill/reload nodes into the graph and fix usages */
669         be_insert_spills_reloads(env.senv);
670
671         /* clean up */
672         if(spill_env == NULL)
673                 be_delete_spill_env(env.senv);
674         be_end_uses(env.uses);
675         obstack_free(&env.ob, NULL);
676 }